Add specs

This commit is contained in:
Matt Colyer
2013-10-08 16:23:34 -07:00
parent 33cf5dda15
commit ffdfe63a4e
8 changed files with 44 additions and 19 deletions

View File

@@ -151,7 +151,9 @@ describe "the `atom` global", ->
expect(keymap.bindingsForElement(element3)['ctrl-y']).toBeUndefined()
describe "menu loading", ->
beforeEach -> atom.contextMenu.definitions = []
beforeEach ->
atom.contextMenu.definitions = []
atom.menu.template = []
describe "when the metadata does not contain a 'menus' manifest", ->
it "loads all the .cson/.json files in the menus directory", ->
@@ -161,6 +163,8 @@ describe "the `atom` global", ->
atom.activatePackage("package-with-menus")
expect(atom.menu.template[0].label).toBe "Second to Last"
expect(atom.menu.template[1].label).toBe "Last"
expect(atom.contextMenu.definitionsForElement(element)[0].label).toBe "Menu item 1"
expect(atom.contextMenu.definitionsForElement(element)[1].label).toBe "Menu item 2"
expect(atom.contextMenu.definitionsForElement(element)[2].label).toBe "Menu item 3"
@@ -173,6 +177,8 @@ describe "the `atom` global", ->
atom.activatePackage("package-with-menus-manifest")
expect(atom.menu.template[0].label).toBe "Second to Last"
expect(atom.menu.template[1].label).toBe "Last"
expect(atom.contextMenu.definitionsForElement(element)[0].label).toBe "Menu item 2"
expect(atom.contextMenu.definitionsForElement(element)[1].label).toBe "Menu item 1"
expect(atom.contextMenu.definitionsForElement(element)[2]).toBeUndefined()

View File

@@ -1,3 +1,7 @@
"context-menu":
".test-1":
"Menu item 1": "command-1"
'menu': [
{ 'label': 'Last' }
]
'context-menu':
'.test-1':
'Menu item 1': 'command-1'

View File

@@ -1,3 +1,7 @@
"context-menu":
".test-1":
"Menu item 2": "command-2"
'menu': [
{ 'label': 'Second to Last' }
]
'context-menu':
'.test-1':
'Menu item 2': 'command-2'

View File

@@ -1,3 +1,3 @@
"context-menu":
".test-1":
"Menu item 3": "command-3"
'context-menu':
'.test-1':
'Menu item 3': 'command-3'

View File

@@ -1,3 +1,7 @@
"context-menu":
".test-1":
"Menu item 1": "command-1"
'menu': [
{ 'label': 'Second to Last' }
]
'context-menu':
'.test-1':
'Menu item 1': 'command-1'

View File

@@ -1,3 +1,7 @@
"context-menu":
".test-1":
"Menu item 2": "command-2"
'menu': [
{ 'label': 'Last' }
]
'context-menu':
'.test-1':
'Menu item 2': 'command-2'

View File

@@ -1,3 +1,3 @@
"context-menu":
".test-1":
"Menu item 3": "command-3"
'context-menu':
'.test-1':
'Menu item 3': 'command-3'

View File

@@ -50,6 +50,9 @@ beforeEach ->
bindingSetsToRestore = _.clone(keymap.bindingSets)
bindingSetsByFirstKeystrokeToRestore = _.clone(keymap.bindingSetsByFirstKeystroke)
# prevent specs from modifying Atom's menus
spyOn(atom.menu, 'sendToBrowserProcess')
# reset config before each spec; don't load or save from/to `config.json`
config = new Config
resourcePath: window.resourcePath