generated from well-known-components/template-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Coverage was complaining because of a mismatch in a type without…
… timeout
- Loading branch information
1 parent
9a0cfdc
commit 127d54f
Showing
5 changed files
with
56 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
module.exports = { | ||
transform: { | ||
"^.+\\.(ts|tsx)$": ["ts-jest", {tsconfig: "test/tsconfig.json"}] | ||
'^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: 'test/tsconfig.json' }] | ||
}, | ||
moduleFileExtensions: ["ts", "js"], | ||
coverageDirectory: "coverage", | ||
collectCoverageFrom: ["src/**/*.ts", "src/**/*.js"], | ||
testMatch: ["**/*.spec.(ts)"], | ||
testEnvironment: "node", | ||
moduleFileExtensions: ['ts', 'js'], | ||
coverageDirectory: 'coverage', | ||
collectCoverageFrom: ['src/**/*.ts', 'src/**/*.js', '!src/migrations/**'], | ||
testMatch: ['**/*.spec.(ts)'], | ||
testEnvironment: 'node' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { WsNotAuthenticatedUserData, WsUserData } from '../types' | ||
|
||
export function isNotAuthenticated(data: WsUserData): data is WsNotAuthenticatedUserData { | ||
return !data.auth | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { WsUserData, WsNotAuthenticatedUserData } from '../../../src/types' | ||
import { isNotAuthenticated } from '../../../src/utils/wsUserData' | ||
import { IUWebSocketEventMap } from '../../../src/utils/UWebSocketTransport' | ||
import { Emitter } from 'mitt' | ||
|
||
describe('wsUserData', () => { | ||
describe('isNotAuthenticated', () => { | ||
it('should return false if the user is authenticated', () => { | ||
const data: WsUserData = { | ||
auth: true, | ||
isConnected: false, | ||
eventEmitter: { emit: jest.fn() } as unknown as Emitter<IUWebSocketEventMap>, | ||
address: '0x123' | ||
} | ||
|
||
expect(isNotAuthenticated(data)).toBe(false) | ||
}) | ||
|
||
it('should return true with the correct type if the user is not authenticated', () => { | ||
const data: WsUserData = { | ||
auth: false, | ||
isConnected: false | ||
} | ||
|
||
expect(isNotAuthenticated(data)).toBe(true) | ||
}) | ||
}) | ||
}) |