-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for dynamically removing timeline nodes
- Loading branch information
1 parent
4e88af1
commit 9b55e9d
Showing
1 changed file
with
66 additions
and
0 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 |
---|---|---|
|
@@ -75,6 +75,72 @@ describe("Timeline", () => { | |
expect(timeline.children.length).toEqual(2); | ||
}); | ||
|
||
it("respects dynamically removed end child node descriptions", async () => { | ||
TestPlugin.setManualFinishTrialMode(); | ||
|
||
const timelineDescription: TimelineArray = [ | ||
{ type: TestPlugin }, | ||
{ type: TestPlugin }, | ||
{ timeline: [{ type: TestPlugin }] }, | ||
]; | ||
const timeline = createTimeline(timelineDescription); | ||
|
||
const runPromise = timeline.run(); | ||
expect(timeline.children.length).toEqual(1); // Only the first child is instantiated because they are incrementally instantiated now | ||
|
||
timelineDescription.pop(); | ||
await TestPlugin.finishTrial(); | ||
await TestPlugin.finishTrial(); | ||
await runPromise; | ||
|
||
expect(timeline.children.length).toEqual(2); | ||
expect(timeline.children).toEqual([expect.any(Trial), expect.any(Trial)]); | ||
}); | ||
|
||
it("respects dynamically removed first child node descriptions", async () => { | ||
TestPlugin.setManualFinishTrialMode(); | ||
|
||
const timelineDescription: TimelineArray = [ | ||
{ type: TestPlugin }, | ||
{ timeline: [{ type: TestPlugin }] }, | ||
{ type: TestPlugin }, | ||
]; | ||
const timeline = createTimeline(timelineDescription); | ||
|
||
const runPromise = timeline.run(); | ||
expect(timeline.children.length).toEqual(1); | ||
|
||
timelineDescription.shift(); | ||
await TestPlugin.finishTrial(); | ||
await TestPlugin.finishTrial(); | ||
await runPromise; | ||
|
||
expect(timeline.children.length).toEqual(2); | ||
expect(timeline.children).toEqual([expect.any(Timeline), expect.any(Trial)]); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jodeleeuw
Member
|
||
}); | ||
|
||
it("respects dynamically removed middle child node descriptions", async () => { | ||
TestPlugin.setManualFinishTrialMode(); | ||
|
||
const timelineDescription: TimelineArray = [ | ||
{ type: TestPlugin }, | ||
{ timeline: [{ type: TestPlugin }] }, | ||
{ type: TestPlugin }, | ||
]; | ||
const timeline = createTimeline(timelineDescription); | ||
|
||
const runPromise = timeline.run(); | ||
expect(timeline.children.length).toEqual(1); | ||
|
||
timelineDescription.splice(1, 1); | ||
await TestPlugin.finishTrial(); | ||
await TestPlugin.finishTrial(); | ||
await runPromise; | ||
|
||
expect(timeline.children.length).toEqual(2); | ||
expect(timeline.children).toEqual([expect.any(Trial), expect.any(Trial)]); | ||
}); | ||
|
||
describe("with `pause()` and `resume()` calls`", () => { | ||
beforeEach(() => { | ||
TestPlugin.setManualFinishTrialMode(); | ||
|
This test fails! The received children are
[expect.any(Trial), expect.any(Trial)]
and I'm not sure which is wrong between the code and the test