Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 771a9f1

Browse files
author
Max Brunsfeld
authored
Merge pull request #155 from atom/mb-handle-async-save
Don't assume that save is synchronous in specs
2 parents 88f4355 + dad6a6f commit 771a9f1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

spec/whitespace-spec.coffee

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,12 @@ describe "Whitespace", ->
347347
buffer.setText("foo \nbar\t \n\nbaz")
348348

349349
it "saves the file without removing any trailing whitespace", ->
350-
atom.commands.dispatch(workspaceElement, 'whitespace:save-with-trailing-whitespace')
351-
expect(buffer.getText()).toBe "foo \nbar\t \n\nbaz"
352-
expect(buffer.isModified()).toBe false
350+
waitsFor (done) ->
351+
buffer.onDidSave ->
352+
expect(buffer.getText()).toBe "foo \nbar\t \n\nbaz"
353+
expect(buffer.isModified()).toBe false
354+
done()
355+
atom.commands.dispatch(workspaceElement, 'whitespace:save-with-trailing-whitespace')
353356

354357
describe "when the 'whitespace:save-without-trailing-whitespace' command is run", ->
355358
beforeEach ->
@@ -358,9 +361,12 @@ describe "Whitespace", ->
358361
buffer.setText("foo \nbar\t \n\nbaz")
359362

360363
it "saves the file and removes any trailing whitespace", ->
361-
atom.commands.dispatch(workspaceElement, 'whitespace:save-without-trailing-whitespace')
362-
expect(buffer.getText()).toBe "foo\nbar\n\nbaz"
363-
expect(buffer.isModified()).toBe false
364+
waitsFor (done) ->
365+
buffer.onDidSave ->
366+
expect(buffer.getText()).toBe "foo\nbar\n\nbaz"
367+
expect(buffer.isModified()).toBe false
368+
done()
369+
atom.commands.dispatch(workspaceElement, 'whitespace:save-without-trailing-whitespace')
364370

365371
describe "when the 'whitespace:convert-tabs-to-spaces' command is run", ->
366372
it "removes leading \\t characters and replaces them with spaces using the configured tab length", ->

0 commit comments

Comments
 (0)