forked from ealush/vest
-
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.
feat(vest): add state subscription (ealush#606)
- Loading branch information
Showing
6 changed files
with
110 additions
and
1 deletion.
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
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
24 changes: 24 additions & 0 deletions
24
packages/vest/src/core/suite/__tests__/__snapshots__/subscribe.test.js.snap
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,24 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`suite.subscribe Should call handler on suite subscription initialization 1`] = ` | ||
Array [ | ||
Object { | ||
"suiteState": Object { | ||
"usePending": Object { | ||
"lagging": Array [], | ||
"pending": Array [], | ||
}, | ||
"useSuiteId": Object { | ||
"id": "1", | ||
"name": undefined, | ||
}, | ||
"useTestCallbacks": Object { | ||
"doneCallbacks": Array [], | ||
"fieldCallbacks": Array [], | ||
}, | ||
"useTestObjects": Array [], | ||
}, | ||
"type": "suiteSubscribeInit", | ||
}, | ||
] | ||
`; |
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,31 @@ | ||
import vest from 'vest'; | ||
|
||
describe('suite.subscribe', () => { | ||
let suite; | ||
let handler; | ||
beforeEach(() => { | ||
handler = jest.fn(); | ||
suite = vest.create(() => { | ||
|
||
}); | ||
|
||
}); | ||
|
||
it('Should call handler on suite subscription initialization', () => { | ||
|
||
suite(); | ||
|
||
expect(handler).toHaveBeenCalledTimes(0); | ||
suite.subscribe(handler); | ||
expect(handler).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('Should call handler on suite subscription initialization', () => { | ||
|
||
suite(); | ||
|
||
suite.subscribe(handler); | ||
expect(handler.mock.calls[0]).toMatchSnapshot(); | ||
}); | ||
|
||
}); |
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