-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from Dashlane/fix/create-event-bus-return-type
Fix/createEventBus return type
- Loading branch information
Showing
6 changed files
with
1,167 additions
and
1,820 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { InitialOptionsTsJest } from "ts-jest/dist/types"; | ||
|
||
const config: InitialOptionsTsJest = { | ||
globals: { | ||
"ts-jest": { | ||
tsconfig: "tsconfig.json", | ||
}, | ||
}, | ||
moduleFileExtensions: ["ts", "js"], | ||
preset: "ts-jest", | ||
rootDir: "test", | ||
testMatch: ["**/*.spec.ts"], | ||
verbose: true, | ||
}; | ||
export default config; |
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
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,32 @@ | ||
import { expectTypeOf } from 'expect-type' | ||
import { createEventBus } from '../src/Events' | ||
import { Slot, slot } from '../src/Slot' | ||
|
||
describe('createEventBus', () => { | ||
type Events = { | ||
numberToString: Slot<number, string> | ||
eventToIgnore: Slot<void, void> | ||
} | ||
|
||
type FilteredEvents = { | ||
numberToString: Slot<number, string> | ||
} | ||
|
||
const events: Events = { | ||
numberToString: slot<number, string>(), | ||
eventToIgnore: slot<void, void>(), | ||
} | ||
|
||
it('should return the right types regardless of an ingnoredEvents list being passed or not', () => { | ||
const eventBus = createEventBus({ events }) | ||
const eventBusWithIgnored = createEventBus({ | ||
events, | ||
ignoredEvents: ['eventToIgnore'], | ||
}) | ||
|
||
expectTypeOf(eventBus).toEqualTypeOf<Events>() | ||
expectTypeOf(eventBus).not.toEqualTypeOf<FilteredEvents>() | ||
expectTypeOf(eventBusWithIgnored).not.toEqualTypeOf<Events>() | ||
expectTypeOf(eventBusWithIgnored).toEqualTypeOf<FilteredEvents>() | ||
}) | ||
}) |
Oops, something went wrong.