mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 16:26:08 +08:00
fix(specs): fix FeatureUsage spec
Summary: Damn async TaskQueue Test Plan: fixed Reviewers: juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D3888
This commit is contained in:
parent
9c3dd29c10
commit
f33667e1a1
|
@ -1,5 +1,6 @@
|
||||||
import pathwatcher from 'pathwatcher';
|
import pathwatcher from 'pathwatcher';
|
||||||
import ReactTestUtils from 'react-addons-test-utils';
|
import ReactTestUtils from 'react-addons-test-utils';
|
||||||
|
import {TaskQueue} from 'nylas-exports'
|
||||||
// TODO the local-sync package should be moved as part of nylas-mail core,
|
// TODO the local-sync package should be moved as part of nylas-mail core,
|
||||||
// instead of being a separate package
|
// instead of being a separate package
|
||||||
import {destroyTestDatabase} from '../../internal_packages/local-sync/spec/helpers'
|
import {destroyTestDatabase} from '../../internal_packages/local-sync/spec/helpers'
|
||||||
|
@ -29,6 +30,11 @@ class MasterAfterEach {
|
||||||
NylasEnv.styles.restoreSnapshot(styleElementsToRestore);
|
NylasEnv.styles.restoreSnapshot(styleElementsToRestore);
|
||||||
|
|
||||||
this.removeAllSpies();
|
this.removeAllSpies();
|
||||||
|
if (TaskQueue._queue.length > 0) {
|
||||||
|
console.inspect(TaskQueue._queue)
|
||||||
|
TaskQueue._queue = []
|
||||||
|
throw new Error("Your test forgot to clean up the TaskQueue")
|
||||||
|
}
|
||||||
waits(0);
|
waits(0);
|
||||||
}); // yield to ui thread to make screen update more frequently
|
}); // yield to ui thread to make screen update more frequently
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {TaskQueueStatusStore} from 'nylas-exports'
|
import {TaskQueue, TaskQueueStatusStore} from 'nylas-exports'
|
||||||
import FeatureUsageStore from '../../src/flux/stores/feature-usage-store'
|
import FeatureUsageStore from '../../src/flux/stores/feature-usage-store'
|
||||||
import Task from '../../src/flux/tasks/task'
|
import Task from '../../src/flux/tasks/task'
|
||||||
import SendFeatureUsageEventTask from '../../src/flux/tasks/send-feature-usage-event-task'
|
import SendFeatureUsageEventTask from '../../src/flux/tasks/send-feature-usage-event-task'
|
||||||
|
@ -53,6 +53,10 @@ describe("FeatureUsageStore", function featureUsageStoreSpec() {
|
||||||
spyOn(TaskQueueStatusStore, "waitForPerformLocal").andReturn(Promise.resolve())
|
spyOn(TaskQueueStatusStore, "waitForPerformLocal").andReturn(Promise.resolve())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
TaskQueue._queue = []
|
||||||
|
})
|
||||||
|
|
||||||
it("returns the num remaining if successful", async () => {
|
it("returns the num remaining if successful", async () => {
|
||||||
let numLeft = await FeatureUsageStore.useFeature('is-usable');
|
let numLeft = await FeatureUsageStore.useFeature('is-usable');
|
||||||
expect(numLeft).toBe(1)
|
expect(numLeft).toBe(1)
|
||||||
|
|
Loading…
Reference in a new issue