From ffdfe63a4e2706d99601939f0f51a994ce1cdbc4 Mon Sep 17 00:00:00 2001 From: Matt Colyer Date: Tue, 8 Oct 2013 16:23:34 -0700 Subject: [PATCH] Add specs --- spec/atom-spec.coffee | 8 +++++++- .../package-with-menus-manifest/menus/menu-1.cson | 10 +++++++--- .../package-with-menus-manifest/menus/menu-2.cson | 10 +++++++--- .../package-with-menus-manifest/menus/menu-3.cson | 6 +++--- .../packages/package-with-menus/menus/menu-1.cson | 10 +++++++--- .../packages/package-with-menus/menus/menu-2.cson | 10 +++++++--- .../packages/package-with-menus/menus/menu-3.cson | 6 +++--- spec/spec-helper.coffee | 3 +++ 8 files changed, 44 insertions(+), 19 deletions(-) diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index 2819e21bd..7e766f0d9 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -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() diff --git a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-1.cson b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-1.cson index 0e7e344cf..98edb7e5e 100644 --- a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-1.cson +++ b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-1.cson @@ -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' diff --git a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-2.cson b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-2.cson index 415bcf74f..876a4f623 100644 --- a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-2.cson +++ b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-2.cson @@ -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' diff --git a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-3.cson b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-3.cson index 7296e4418..83b77430a 100644 --- a/spec/fixtures/packages/package-with-menus-manifest/menus/menu-3.cson +++ b/spec/fixtures/packages/package-with-menus-manifest/menus/menu-3.cson @@ -1,3 +1,3 @@ -"context-menu": - ".test-1": - "Menu item 3": "command-3" +'context-menu': + '.test-1': + 'Menu item 3': 'command-3' diff --git a/spec/fixtures/packages/package-with-menus/menus/menu-1.cson b/spec/fixtures/packages/package-with-menus/menus/menu-1.cson index 0e7e344cf..6cb447eb1 100644 --- a/spec/fixtures/packages/package-with-menus/menus/menu-1.cson +++ b/spec/fixtures/packages/package-with-menus/menus/menu-1.cson @@ -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' diff --git a/spec/fixtures/packages/package-with-menus/menus/menu-2.cson b/spec/fixtures/packages/package-with-menus/menus/menu-2.cson index 415bcf74f..be2419a56 100644 --- a/spec/fixtures/packages/package-with-menus/menus/menu-2.cson +++ b/spec/fixtures/packages/package-with-menus/menus/menu-2.cson @@ -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' diff --git a/spec/fixtures/packages/package-with-menus/menus/menu-3.cson b/spec/fixtures/packages/package-with-menus/menus/menu-3.cson index 7296e4418..83b77430a 100644 --- a/spec/fixtures/packages/package-with-menus/menus/menu-3.cson +++ b/spec/fixtures/packages/package-with-menus/menus/menu-3.cson @@ -1,3 +1,3 @@ -"context-menu": - ".test-1": - "Menu item 3": "command-3" +'context-menu': + '.test-1': + 'Menu item 3': 'command-3' diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index db907b685..3b9253085 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -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