How to trigger a command from plugin code?



I created a command with atom.workspaceView.command, and it worked fine, apart from not being documented in the api.

Now I would like to add a test for it, but I couldn’t find a way to trigger the command on my code.
Looking at atom code, it [seems that the method sendCommand is under atomWindow, but I can’t find a way to get this object.

In all other packages I checked, the test is done with a keyboard shortcut. But this command don’t have a keyboard shortcut.

Help or pointers would be greatly appreciated.


You can look in my package tabs-to-spaces for some examples:

The method is atom.workspaceView.trigger(). I modeled my specs after the specs in the whitespace package.


Update. Now use:

editorView = atom.views.getView(editor)
atom.commands.dispatch(editorView, 'core:move-left')