Skip to content

Commit

Permalink
fix: move tests into root/test/ directory
Browse files Browse the repository at this point in the history
  • Loading branch information
dancastillo committed Aug 5, 2024
1 parent 1af4cfc commit 8c7b81b
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "@fastify/passport",
"version": "2.5.0",
"description": "Simple, unobtrusive authentication for Fastify.",
"main": "dist/index.js",
"main": "dist/src/index.js",
"type": "commonjs",
"types": "dist/index.d.ts",
"types": "dist/src/index.d.ts",
"scripts": {
"build": "rimraf ./dist && mkdir dist && tsc --outDir dist && git rev-parse HEAD > BUILD_SHA",
"build": "rimraf ./dist && tsc && git rev-parse HEAD > BUILD_SHA",
"lint": "eslint \"*/**/*.{js,ts,tsx}\"",
"lint:fix": "prettier --loglevel warn --write \"src/**/*.{ts,tsx}\" && eslint \"*/**/*.{js,ts,tsx}\" --quiet --fix",
"prepublishOnly": "npm run build",
Expand Down
3 changes: 0 additions & 3 deletions src/test/esm/default-esm-export.mjs

This file was deleted.

3 changes: 0 additions & 3 deletions src/test/esm/named-esm-export.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/authorize.test.ts → test/authorize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, describe } from 'node:test'
import assert from 'node:assert'
import { RouteHandlerMethod } from 'fastify'
import { expectType } from 'tsd'
import { Strategy } from '../strategies'
import { Strategy } from '../src/strategies'
import { generateTestUser, getConfiguredTestServer } from './helpers'

export class TestThirdPartyStrategy extends Strategy {
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions test/esm/default-esm-export.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import passport from '../../dist/src/index.js'

passport.initialize()
4 changes: 2 additions & 2 deletions src/test/esm/esm.test.ts → test/esm/esm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { join } from 'node:path'

describe('Native ESM import', () => {
test('should be able to use default export', () => {
const { status } = spawnSync('node', [join(__dirname, '../../../src/test/esm', 'default-esm-export.mjs')])
const { status } = spawnSync('node', [join(__dirname, '../../../test/esm', 'default-esm-export.mjs')])
assert.strictEqual(status, 0)
})

test('should be able to use named export', () => {
const { status } = spawnSync('node', [join(__dirname, '../../../src/test/esm', 'named-esm-export.mjs')])
const { status } = spawnSync('node', [join(__dirname, '../../../test/esm', 'named-esm-export.mjs')])

assert.strictEqual(status, 0)
})
Expand Down
3 changes: 3 additions & 0 deletions test/esm/named-esm-export.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Strategy } from '../../dist/src/index.js'

class MS extends Strategy {}
6 changes: 3 additions & 3 deletions src/test/helpers.ts → test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { join } from 'node:path'
import fastify, { FastifyInstance } from 'fastify'
import fastifySecureSession, { SecureSessionPluginOptions } from '@fastify/secure-session'
import fastifyCookie from '@fastify/cookie'
import Authenticator, { AuthenticatorOptions } from '../Authenticator'
import { Strategy } from '../strategies'
import Authenticator, { AuthenticatorOptions } from '../src/Authenticator'
import { Strategy } from '../src/strategies'
import { InjectOptions, Response as LightMyRequestResponse } from 'light-my-request'
import parseCookies from 'set-cookie-parser'
import { IncomingMessage } from 'node:http'
import { FastifyRegisterOptions } from 'fastify/types/register'
import { fastifySession, FastifySessionOptions } from '@fastify/session'

const SecretKey = fs.readFileSync(join(__dirname, '../../src/test', 'secure.key'))
const SecretKey = fs.readFileSync(join(__dirname, '../../test', 'secure.key'))

let counter = 0
export const generateTestUser = () => ({ name: 'test', id: String(counter++) })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, describe } from 'node:test'
import assert from 'node:assert'
import { Strategy } from '../strategies'
import { Strategy } from '../src/strategies'
import { TestThirdPartyStrategy } from './authorize.test'
import { getConfiguredTestServer, getRegisteredTestServer, TestStrategy } from './helpers'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, describe, beforeEach } from 'node:test'
import assert from 'node:assert'
import { FastifyInstance } from 'fastify'
import { Authenticator } from '../Authenticator'
import { Strategy } from '../strategies'
import { Authenticator } from '../src/Authenticator'
import { Strategy } from '../src/strategies'
import { getTestServer, TestBrowserSession } from './helpers'

let counter: number
Expand Down
6 changes: 3 additions & 3 deletions src/test/passport.test.ts → test/passport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { test, describe } from 'node:test'
import assert from 'node:assert'
import got from 'got'
import { AddressInfo } from 'net'
import { AuthenticateOptions } from '../AuthenticationRoute'
import Authenticator from '../Authenticator'
import { Strategy } from '../strategies'
import { AuthenticateOptions } from '../src/AuthenticationRoute'
import Authenticator from '../src/Authenticator'
import { Strategy } from '../src/strategies'
import { getConfiguredTestServer, getRegisteredTestServer, getTestServer, TestStrategy } from './helpers'

const testSuite = (sessionPluginName: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, describe, mock } from 'node:test'
import assert from 'node:assert'
import { FastifyRequest } from 'fastify'
import { SerializeFunction } from '../Authenticator'
import { SecureSessionManager } from '../session-managers/SecureSessionManager'
import { SerializeFunction } from '../src/Authenticator'
import { SecureSessionManager } from '../src/session-managers/SecureSessionManager'

describe('SecureSessionManager', () => {
test('should throw an Error if no parameter was passed', () => {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, describe, mock } from 'node:test'
import assert from 'node:assert'
import { FastifyInstance } from 'fastify'
import { FastifyRequest } from 'fastify/types/request'
import Authenticator from '../Authenticator'
import Authenticator from '../src/Authenticator'
import { getTestServer, TestDatabaseStrategy, TestStrategy } from './helpers'

const testSuite = (sessionPluginName: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, describe } from 'node:test'
import assert from 'node:assert'
import { SerializeFunction } from '../Authenticator'
import { SessionStrategy } from '../strategies/SessionStrategy'
import { SerializeFunction } from '../src/Authenticator'
import { SessionStrategy } from '../src/strategies/SessionStrategy'

describe('SessionStrategy', () => {
test('should throw an Error if no parameter was passed', () => {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/test/strategy.test.ts → test/strategy.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, describe } from 'node:test'
import assert from 'node:assert'
import Authenticator from '../Authenticator'
import Authenticator from '../src/Authenticator'
import { getConfiguredTestServer, TestStrategy } from './helpers'
import { Strategy } from '../strategies'
import { Strategy } from '../src/strategies'

const testSuite = (sessionPluginName: string) => {
describe(`${sessionPluginName} tests`, () => {
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"noImplicitAny": false,
"removeComments": true,
"noUnusedLocals": true,
"rootDir": "./src",
"rootDir": ".",
"resolveJsonModule": true,
"newLine": "lf",
"noFallthroughCasesInSwitch": true,
Expand All @@ -22,5 +22,5 @@
"skipLibCheck": true,
"lib": ["ESNext"]
},
"include": ["src"]
"include": ["src", "test"]
}

0 comments on commit 8c7b81b

Please sign in to comment.