Skip to content

Commit 065f4c4

Browse files
committed
Avoid dependency on shared state
The test was passing only when run in isolation.
1 parent 3ad3852 commit 065f4c4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

spec/text-editor-spec.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ describe('TextEditor', () => {
2020
await atom.packages.activatePackage('language-javascript')
2121
})
2222

23-
it('generates unique ids for each editor', () => {
24-
// Deserialized editors are initialized with an id:
25-
new TextEditor({id: 0})
26-
new TextEditor({id: 1})
27-
new TextEditor({id: 2})
28-
// Initializing an editor without an id causes a new id to be generated:
29-
const generatedId = new TextEditor().id
30-
expect(generatedId).toBe(3)
23+
it('generates unique ids for each editor', async () => {
24+
// Deserialized editors are initialized with the serialized id. We can
25+
// initialize an editor with what we expect to be the next id:
26+
const deserialized = new TextEditor({id: editor.id+1})
27+
expect(deserialized.id).toEqual(editor.id+1)
28+
29+
// The id generator should skip the id used up by the deserialized one:
30+
const fresh = new TextEditor()
31+
expect(fresh.id).toNotEqual(deserialized.id)
3132
})
3233

3334
describe('when the editor is deserialized', () => {

0 commit comments

Comments
 (0)