       buffer.setText("foo   \nbar\t   \n\nbaz")
 
     it "removes the trailing whitespace in the active editor", ->
-      atom.workspaceView.trigger 'whitespace:remove-trailing-whitespace'
+      atom.commands.dispatch(workspaceElement, 'whitespace:remove-trailing-whitespace')
       expect(buffer.getText()).toBe "foo\nbar\n\nbaz"
 
     it "does not attempt to remove whitespace when the package is deactivated", ->

path = require 'path'
fs = require 'fs-plus'
{WorkspaceView} = require 'atom'
temp = require 'temp'

describe "Whitespace", ->
  [editor, buffer] = []

  beforeEach ->
    directory = temp.mkdirSync()
    atom.project.setPath(directory)
    atom.workspaceView = new WorkspaceView()
    atom.workspace = atom.workspaceView.model
    filePath = path.join(directory, 'atom-whitespace.txt')
    fs.writeFileSync(filePath, '')
    fs.writeFileSync(path.join(directory, 'sample.txt'), 'Some text.\n')


  describe "when the editor is split", ->
    it "does not throw exceptions when the editor is saved after the split is closed (regression)", ->
      atom.workspace.getActivePane().splitRight(copyActiveItem: true)
      atom.workspace.getPanes()[0].destroyItems()

      editor = atom.workspace.activePaneItem
