From 137e09eb510f2c9f989e7813fd177edf99442b94 Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Thu, 1 Oct 2015 21:39:44 -0700 Subject: [PATCH] refactor(spec) move spec-nylas to spec --- .gitignore | 2 +- build/Gruntfile.coffee | 6 +- build/tasks/build-task.coffee | 1 - .../spec/nylas-sync-worker-pool-spec.coffee | 2 +- spec-nylas/fixtures/css.css | 5 - spec-nylas/fixtures/module-cache/file.json | 3 - spec-nylas/fixtures/sample.less | 8 - spec/6to5-spec.coffee | 41 - .../action-bridge-spec.coffee | 0 {spec-nylas => spec}/atom-spec.coffee | 0 .../auto-update-manager-spec.coffee | 0 .../buffered-process-spec.coffee | 0 {spec-nylas => spec}/clipboard-spec.coffee | 0 spec/command-installer-spec.coffee | 34 - spec/command-registry-spec.coffee | 218 --- .../component-registry-spec.coffee | 0 .../components/evented-iframe-spec.cjsx | 0 ...elect-list-interaction-handler-spec.coffee | 0 ...lect-split-interaction-handler-spec.coffee | 0 .../tokenizing-text-field-spec.cjsx | 0 spec/config-spec.coffee | 1670 ----------------- spec/context-menu-manager-spec.coffee | 181 -- .../database-object-registry-spec.coffee | 0 .../database-view-spec.coffee | 0 {spec-nylas => spec}/dom-utils-spec.coffee | 0 spec/fixtures/6to5/double-quotes.js | 3 - spec/fixtures/6to5/invalid.js | 3 - spec/fixtures/6to5/single-quotes.js | 3 - spec/fixtures/coffee.coffee | 23 - .../fixtures/db-test-model.coffee | 0 spec/fixtures/dir/a | 3 - spec/fixtures/dir/a-dir/oh-git | 1 - spec/fixtures/dir/b | 1 - spec/fixtures/dir/file1 | 0 .../fixtures/emails/correct_sig.txt | 0 .../fixtures/emails/email_1.html | 0 .../fixtures/emails/email_10.html | 0 .../fixtures/emails/email_10_stripped.html | 0 .../fixtures/emails/email_11.html | 0 .../fixtures/emails/email_11_stripped.html | 0 .../fixtures/emails/email_12.html | 0 .../fixtures/emails/email_12_stripped.html | 0 .../fixtures/emails/email_13.html | 0 .../fixtures/emails/email_13_stripped.html | 0 .../fixtures/emails/email_14.html | 0 .../fixtures/emails/email_14_stripped.html | 0 .../fixtures/emails/email_15.html | 0 .../fixtures/emails/email_15_stripped.html | 0 .../fixtures/emails/email_16.html | 0 .../fixtures/emails/email_16_stripped.html | 0 .../fixtures/emails/email_1_1.txt | 0 .../fixtures/emails/email_1_2.txt | 0 .../fixtures/emails/email_1_3.txt | 0 .../fixtures/emails/email_1_4.txt | 0 .../fixtures/emails/email_1_5.txt | 0 .../fixtures/emails/email_1_6.txt | 0 .../fixtures/emails/email_1_7.txt | 0 .../fixtures/emails/email_1_8.txt | 0 .../fixtures/emails/email_1_stripped.html | 0 .../fixtures/emails/email_2.html | 0 .../fixtures/emails/email_2_1.txt | 0 .../fixtures/emails/email_2_stripped.html | 0 .../fixtures/emails/email_3.html | 0 .../fixtures/emails/email_3_stripped.html | 0 .../fixtures/emails/email_4.html | 0 .../fixtures/emails/email_4_stripped.html | 0 .../fixtures/emails/email_5.html | 0 .../fixtures/emails/email_5_stripped.html | 0 .../fixtures/emails/email_6.html | 0 .../fixtures/emails/email_6_stripped.html | 0 .../fixtures/emails/email_7.html | 0 .../fixtures/emails/email_7_stripped.html | 0 .../fixtures/emails/email_8.html | 0 .../fixtures/emails/email_8_stripped.html | 0 .../fixtures/emails/email_9.html | 0 .../fixtures/emails/email_9_stripped.html | 0 .../fixtures/emails/email_BlackBerry.txt | 0 .../fixtures/emails/email_bullets.txt | 0 .../fixtures/emails/email_iPhone.txt | 0 ..._multi_word_sent_from_my_mobile_device.txt | 0 .../email_sent_from_my_not_signature.txt | 0 spec/fixtures/git/ignore.git/HEAD | 1 - spec/fixtures/git/ignore.git/config | 6 - spec/fixtures/git/ignore.git/index | Bin 137 -> 0 bytes spec/fixtures/git/ignore.git/info/exclude | 1 - .../65/a457425a679cbe9adf0d2741785d3ceabb44a7 | Bin 50 -> 0 bytes .../e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 | Bin 15 -> 0 bytes .../ef/046e9eecaa5255ea5e9817132d4001724d6ae1 | Bin 132 -> 0 bytes .../fixtures/git/ignore.git/refs/heads/master | 1 - spec/fixtures/git/master.git/HEAD | 1 - spec/fixtures/git/master.git/config | 6 - spec/fixtures/git/master.git/index | Bin 137 -> 0 bytes .../65/a457425a679cbe9adf0d2741785d3ceabb44a7 | Bin 50 -> 0 bytes .../e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 | Bin 15 -> 0 bytes .../ef/046e9eecaa5255ea5e9817132d4001724d6ae1 | Bin 132 -> 0 bytes .../fixtures/git/master.git/refs/heads/master | 1 - spec/fixtures/git/working-dir/.gitignore | 2 - spec/fixtures/git/working-dir/a.txt | 0 spec/fixtures/git/working-dir/git.git/HEAD | 1 - spec/fixtures/git/working-dir/git.git/config | 6 - spec/fixtures/git/working-dir/git.git/index | Bin 334 -> 0 bytes .../06/15f9a45968b3515e0a202530ef9f61aba26b6c | Bin 110 -> 0 bytes .../16/735fb793d7b038818219c4b8c6295346e20eef | Bin 164 -> 0 bytes .../52/f56457b6fca045ce41bb9d32e6ca79d23192af | Bin 166 -> 0 bytes .../5b/24ab4c3baadf534242b1acc220c8fa051b9b20 | Bin 79 -> 0 bytes .../65/a457425a679cbe9adf0d2741785d3ceabb44a7 | Bin 50 -> 0 bytes .../66/dc9051da651c15d98d017a88658263cab28f02 | Bin 24 -> 0 bytes .../8a/9c86f1cb1f14b8f436eb91f4b052c8802ca99e | 1 - .../e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 | Bin 15 -> 0 bytes .../ec/5e386905ff2d36e291086a1207f2585aaa8920 | Bin 50 -> 0 bytes .../ef/046e9eecaa5255ea5e9817132d4001724d6ae1 | Bin 132 -> 0 bytes .../fe/bde178cdf35e9df6279d87aa27590c6d92e354 | Bin 139 -> 0 bytes .../ff/c8218bd2240a0cb92f6f02548d45784428349b | Bin 28 -> 0 bytes .../git/working-dir/git.git/refs/heads/master | 1 - .../index.coffee | 0 .../index.coffee | 0 .../index.coffee | 0 .../index.coffee | 0 .../package.cson | 0 .../keymaps/broken.json | 0 .../package.json | 0 .../package-with-config-defaults/index.coffee | 0 .../package-with-config-schema/index.coffee | 0 .../index.coffee | 0 .../package.json | 0 .../package-with-deactivate/index.coffee | 0 .../index.coffee | 0 .../index.coffee | 0 .../package.json | 0 .../keymaps/keymap.cson | 0 .../package-with-empty-keymap/package.json | 0 .../package-with-empty-menu/menus/menu.cson | 0 .../package-with-empty-menu/package.json | 0 .../grammars/alittle.cson | 0 .../package-with-grammars/grammars/alot.cson | 0 .../main.js | 0 .../native-module/build/Release/native.node | 0 .../node_modules/native-module/main.js | 0 .../node_modules/native-module/package.json | 0 .../package.json | 0 .../packages/package-with-index/index.coffee | 0 .../grammars/grammar.cson | 0 .../package-with-invalid-styles/package.json | 0 .../styles/index.less | 0 .../keymaps/keymap-1.json | 0 .../keymaps/keymap-2.cson | 0 .../keymaps/keymap-3.cson | 0 .../package.cson | 0 .../keymaps/keymap-1.cson | 0 .../keymaps/keymap-2.cson | 0 .../keymaps/keymap-3.cjson | 0 .../package-with-main/main-module.coffee | 0 .../packages/package-with-main/package.cson | 0 .../menus/menu-1.cson | 0 .../menus/menu-2.cson | 0 .../menus/menu-3.cson | 0 .../package-with-menus-manifest/package.cson | 0 .../package-with-menus/menus/menu-1.cson | 0 .../package-with-menus/menus/menu-2.cson | 0 .../package-with-menus/menus/menu-3.cson | 0 .../package-with-models/main-module.coffee | 0 .../packages/package-with-models/package.cson | 0 .../index.coffee | 0 .../package.json | 0 .../package-with-serialization/index.coffee | 0 .../package-with-serialize-error/index.coffee | 0 .../package-with-serialize-error/package.cson | 0 .../package-with-settings/settings/omg.cson | 0 .../package.cson | 0 .../styles/1.css | 0 .../styles/2.less | 0 .../styles/3.css | 0 .../packages/package-with-styles/styles/1.css | 0 .../package-with-styles/styles/2.less | 0 .../styles/3.test-context.css | 0 .../packages/package-with-styles/styles/4.css | 0 .../package.cson | 0 .../package-without-module/package.cson | 0 .../package.json | 0 .../styles/editor.less | 0 .../styles/ui-variables.less | 0 .../packages/theme-with-index-css/index.css | 0 .../theme-with-index-css/package.json | 0 .../packages/theme-with-index-less/index.less | 0 .../theme-with-index-less/package.json | 0 .../theme-with-invalid-styles/index.less | 0 .../theme-with-invalid-styles/package.json | 0 .../theme-with-package-file/package.json | 0 .../theme-with-package-file/styles/first.css | 0 .../theme-with-package-file/styles/last.css | 0 .../styles/second.less | 0 .../theme-with-syntax-variables/package.json | 0 .../styles/editor.less | 0 .../theme-with-ui-variables/package.json | 0 .../styles/editor.less | 0 .../styles/ui-variables.less | 0 .../theme-without-package-file/styles/a.css | 0 .../theme-without-package-file/styles/b.css | 0 .../theme-without-package-file/styles/c.less | 0 .../theme-without-package-file/styles/d.csv | 0 spec/fixtures/sample-with-comments.js | 20 - .../sample-with-tabs-and-initial-comment.js | 8 - spec/fixtures/sample.js | 13 - spec/fixtures/sample.txt | 1 - spec/fixtures/shebang | 3 - .../fixtures/task-spec-handler.coffee | 0 spec/fixtures/two-hundred.txt | 200 -- spec/language-mode-spec.coffee | 491 ----- .../launch-services-spec.coffee | 0 {spec-nylas => spec}/menu-manager-spec.coffee | 0 .../model-view-selection-spec.coffee | 0 {spec-nylas => spec}/model-view-spec.coffee | 0 .../models/contact-spec.coffee | 0 {spec-nylas => spec}/models/event-spec.coffee | 0 {spec-nylas => spec}/models/file-spec.coffee | 0 .../models/message-spec.coffee | 0 {spec-nylas => spec}/models/model-spec.coffee | 0 {spec-nylas => spec}/models/query-spec.coffee | 0 .../models/thread-spec.coffee | 0 {spec-nylas => spec}/module-cache-spec.coffee | 2 +- spec/notification-manager-spec.coffee | 57 - spec/notification-spec.coffee | 47 - {spec-nylas => spec}/nylas-api-spec.coffee | 0 .../nylas-protocol-handler-spec.coffee | 0 .../package-manager-spec.coffee | 0 {spec-nylas => spec}/package-spec.coffee | 0 .../quoted-html-parser-spec.coffee | 0 .../quoted-plain-text-parser-spec.coffee | 0 spec/space-pen-extensions-spec.coffee | 41 - spec/spec-suite.coffee | 5 +- spec/squirrel-update-spec.coffee | 104 - .../stores/account-store-spec.coffee | 0 .../stores/contact-store-spec.coffee | 0 .../database-setup-query-builder-spec.coffee | 0 .../stores/database-store-spec.coffee | 0 .../stores/draft-store-proxy-spec.coffee | 0 .../stores/draft-store-spec.coffee | 0 .../stores/event-store-spec.coffee | 0 .../stores/file-download-store-spec.coffee | 0 .../stores/file-upload-store-spec.coffee | 0 .../stores/focused-contacts-store-spec.coffee | 0 .../stores/focused-content-store-spec.coffee | 0 .../focused-mail-view-store-spec.coffee | 0 .../stores/message-store-spec.coffee | 0 .../stores/metadata-store-spec.coffee | 0 .../stores/task-queue-spec.coffee | 0 .../stores/unread-count-store-spec.coffee | 0 .../style-manager-spec.coffee | 0 .../styles-element-spec.coffee | 0 .../tasks/change-folder-task-spec.coffee | 0 .../tasks/change-labels-task-spec.coffee | 0 .../tasks/change-mail-task-spec.coffee | 0 .../tasks/change-starred-task-spec.coffee | 0 .../tasks/change-unread-task-spec.coffee | 0 .../tasks/event-rsvp-spec.coffee | 0 .../tasks/file-upload-task-spec.coffee | 0 .../tasks/mark-message-read-spec.coffee | 0 .../tasks/remove-thread-helper-spec.coffee | 0 .../tasks/send-draft-spec.coffee | 0 .../tasks/syncback-category-task-spec.coffee | 0 .../tasks/syncback-draft-spec.coffee | 0 {spec-nylas => spec}/tasks/task-spec.coffee | 0 {spec-nylas => spec}/test_utils.coffee | 0 .../theme-manager-spec.coffee | 0 {spec-nylas => spec}/undo-manager-spec.coffee | 0 {spec-nylas => spec}/utils-spec.coffee | 0 spec/window-spec.coffee | 287 --- spec/workspace-spec.coffee | 1031 ---------- src/browser/main.coffee | 4 +- src/browser/main.js | 4 +- src/flux/stores/database-store.coffee | 2 +- src/global/nylas-exports.coffee | 2 +- src/package-manager.coffee | 2 +- 273 files changed, 13 insertions(+), 4547 deletions(-) delete mode 100644 spec-nylas/fixtures/css.css delete mode 100644 spec-nylas/fixtures/module-cache/file.json delete mode 100644 spec-nylas/fixtures/sample.less delete mode 100644 spec/6to5-spec.coffee rename {spec-nylas => spec}/action-bridge-spec.coffee (100%) rename {spec-nylas => spec}/atom-spec.coffee (100%) rename {spec-nylas => spec}/auto-update-manager-spec.coffee (100%) rename {spec-nylas => spec}/buffered-process-spec.coffee (100%) rename {spec-nylas => spec}/clipboard-spec.coffee (100%) delete mode 100644 spec/command-installer-spec.coffee delete mode 100644 spec/command-registry-spec.coffee rename {spec-nylas => spec}/component-registry-spec.coffee (100%) rename {spec-nylas => spec}/components/evented-iframe-spec.cjsx (100%) rename {spec-nylas => spec}/components/multiselect-list-interaction-handler-spec.coffee (100%) rename {spec-nylas => spec}/components/multiselect-split-interaction-handler-spec.coffee (100%) rename {spec-nylas => spec}/components/tokenizing-text-field-spec.cjsx (100%) delete mode 100644 spec/config-spec.coffee delete mode 100644 spec/context-menu-manager-spec.coffee rename {spec-nylas => spec}/database-object-registry-spec.coffee (100%) rename {spec-nylas => spec}/database-view-spec.coffee (100%) rename {spec-nylas => spec}/dom-utils-spec.coffee (100%) delete mode 100644 spec/fixtures/6to5/double-quotes.js delete mode 100644 spec/fixtures/6to5/invalid.js delete mode 100644 spec/fixtures/6to5/single-quotes.js delete mode 100644 spec/fixtures/coffee.coffee rename {spec-nylas => spec}/fixtures/db-test-model.coffee (100%) delete mode 100644 spec/fixtures/dir/a delete mode 100644 spec/fixtures/dir/a-dir/oh-git delete mode 100644 spec/fixtures/dir/b delete mode 100644 spec/fixtures/dir/file1 rename {spec-nylas => spec}/fixtures/emails/correct_sig.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_1.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_10.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_10_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_11.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_11_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_12.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_12_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_13.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_13_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_14.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_14_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_15.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_15_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_16.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_16_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_1_1.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_1_2.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_1_3.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_1_4.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_1_5.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_1_6.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_1_7.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_1_8.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_1_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_2.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_2_1.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_2_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_3.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_3_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_4.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_4_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_5.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_5_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_6.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_6_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_7.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_7_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_8.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_8_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_9.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_9_stripped.html (100%) rename {spec-nylas => spec}/fixtures/emails/email_BlackBerry.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_bullets.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_iPhone.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_multi_word_sent_from_my_mobile_device.txt (100%) rename {spec-nylas => spec}/fixtures/emails/email_sent_from_my_not_signature.txt (100%) delete mode 100644 spec/fixtures/git/ignore.git/HEAD delete mode 100644 spec/fixtures/git/ignore.git/config delete mode 100644 spec/fixtures/git/ignore.git/index delete mode 100644 spec/fixtures/git/ignore.git/info/exclude delete mode 100644 spec/fixtures/git/ignore.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 delete mode 100644 spec/fixtures/git/ignore.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 delete mode 100644 spec/fixtures/git/ignore.git/objects/ef/046e9eecaa5255ea5e9817132d4001724d6ae1 delete mode 100644 spec/fixtures/git/ignore.git/refs/heads/master delete mode 100644 spec/fixtures/git/master.git/HEAD delete mode 100644 spec/fixtures/git/master.git/config delete mode 100644 spec/fixtures/git/master.git/index delete mode 100644 spec/fixtures/git/master.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 delete mode 100644 spec/fixtures/git/master.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 delete mode 100644 spec/fixtures/git/master.git/objects/ef/046e9eecaa5255ea5e9817132d4001724d6ae1 delete mode 100644 spec/fixtures/git/master.git/refs/heads/master delete mode 100644 spec/fixtures/git/working-dir/.gitignore delete mode 100644 spec/fixtures/git/working-dir/a.txt delete mode 100644 spec/fixtures/git/working-dir/git.git/HEAD delete mode 100644 spec/fixtures/git/working-dir/git.git/config delete mode 100644 spec/fixtures/git/working-dir/git.git/index delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/06/15f9a45968b3515e0a202530ef9f61aba26b6c delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/16/735fb793d7b038818219c4b8c6295346e20eef delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/52/f56457b6fca045ce41bb9d32e6ca79d23192af delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/5b/24ab4c3baadf534242b1acc220c8fa051b9b20 delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/66/dc9051da651c15d98d017a88658263cab28f02 delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/8a/9c86f1cb1f14b8f436eb91f4b052c8802ca99e delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/ec/5e386905ff2d36e291086a1207f2585aaa8920 delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/ef/046e9eecaa5255ea5e9817132d4001724d6ae1 delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/fe/bde178cdf35e9df6279d87aa27590c6d92e354 delete mode 100644 spec/fixtures/git/working-dir/git.git/objects/ff/c8218bd2240a0cb92f6f02548d45784428349b delete mode 100644 spec/fixtures/git/working-dir/git.git/refs/heads/master rename {spec-nylas => spec}/fixtures/packages/package-that-throws-an-exception/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-that-throws-on-activate/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-that-throws-on-deactivate/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-activation-commands/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-activation-commands/package.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-broken-keymap/keymaps/broken.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-broken-package-json/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-config-defaults/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-config-schema/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-consumed-services/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-consumed-services/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-deactivate/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-deprecated-pane-item-method/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-empty-activation-commands/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-empty-activation-commands/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-empty-keymap/keymaps/keymap.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-empty-keymap/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-empty-menu/menus/menu.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-empty-menu/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-grammars/grammars/alittle.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-grammars/grammars/alot.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-incompatible-native-module/main.js (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-incompatible-native-module/node_modules/native-module/build/Release/native.node (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-incompatible-native-module/node_modules/native-module/main.js (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-incompatible-native-module/node_modules/native-module/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-incompatible-native-module/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-index/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-injection-selector/grammars/grammar.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-invalid-styles/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-invalid-styles/styles/index.less (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-keymaps-manifest/keymaps/keymap-1.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-keymaps-manifest/keymaps/keymap-2.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-keymaps-manifest/keymaps/keymap-3.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-keymaps-manifest/package.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-keymaps/keymaps/keymap-1.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-keymaps/keymaps/keymap-2.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-keymaps/keymaps/keymap-3.cjson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-main/main-module.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-main/package.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-menus-manifest/menus/menu-1.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-menus-manifest/menus/menu-2.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-menus-manifest/menus/menu-3.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-menus-manifest/package.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-menus/menus/menu-1.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-menus/menus/menu-2.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-menus/menus/menu-3.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-models/main-module.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-models/package.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-provided-services/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-provided-services/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-serialization/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-serialize-error/index.coffee (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-serialize-error/package.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-settings/settings/omg.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-style-sheets-manifest/package.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-style-sheets-manifest/styles/1.css (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-style-sheets-manifest/styles/2.less (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-style-sheets-manifest/styles/3.css (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-styles/styles/1.css (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-styles/styles/2.less (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-styles/styles/3.test-context.css (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-styles/styles/4.css (100%) rename {spec-nylas => spec}/fixtures/packages/package-with-stylesheets-manifest/package.cson (100%) rename {spec-nylas => spec}/fixtures/packages/package-without-module/package.cson (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-incomplete-ui-variables/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-incomplete-ui-variables/styles/editor.less (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-incomplete-ui-variables/styles/ui-variables.less (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-index-css/index.css (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-index-css/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-index-less/index.less (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-index-less/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-invalid-styles/index.less (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-invalid-styles/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-package-file/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-package-file/styles/first.css (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-package-file/styles/last.css (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-package-file/styles/second.less (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-syntax-variables/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-syntax-variables/styles/editor.less (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-ui-variables/package.json (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-ui-variables/styles/editor.less (100%) rename {spec-nylas => spec}/fixtures/packages/theme-with-ui-variables/styles/ui-variables.less (100%) rename {spec-nylas => spec}/fixtures/packages/theme-without-package-file/styles/a.css (100%) rename {spec-nylas => spec}/fixtures/packages/theme-without-package-file/styles/b.css (100%) rename {spec-nylas => spec}/fixtures/packages/theme-without-package-file/styles/c.less (100%) rename {spec-nylas => spec}/fixtures/packages/theme-without-package-file/styles/d.csv (100%) delete mode 100644 spec/fixtures/sample-with-comments.js delete mode 100644 spec/fixtures/sample-with-tabs-and-initial-comment.js delete mode 100644 spec/fixtures/sample.js delete mode 100644 spec/fixtures/sample.txt delete mode 100644 spec/fixtures/shebang rename {spec-nylas => spec}/fixtures/task-spec-handler.coffee (100%) delete mode 100644 spec/fixtures/two-hundred.txt delete mode 100644 spec/language-mode-spec.coffee rename {spec-nylas => spec}/launch-services-spec.coffee (100%) rename {spec-nylas => spec}/menu-manager-spec.coffee (100%) rename {spec-nylas => spec}/model-view-selection-spec.coffee (100%) rename {spec-nylas => spec}/model-view-spec.coffee (100%) rename {spec-nylas => spec}/models/contact-spec.coffee (100%) rename {spec-nylas => spec}/models/event-spec.coffee (100%) rename {spec-nylas => spec}/models/file-spec.coffee (100%) rename {spec-nylas => spec}/models/message-spec.coffee (100%) rename {spec-nylas => spec}/models/model-spec.coffee (100%) rename {spec-nylas => spec}/models/query-spec.coffee (100%) rename {spec-nylas => spec}/models/thread-spec.coffee (100%) rename {spec-nylas => spec}/module-cache-spec.coffee (97%) delete mode 100644 spec/notification-manager-spec.coffee delete mode 100644 spec/notification-spec.coffee rename {spec-nylas => spec}/nylas-api-spec.coffee (100%) rename {spec-nylas => spec}/nylas-protocol-handler-spec.coffee (100%) rename {spec-nylas => spec}/package-manager-spec.coffee (100%) rename {spec-nylas => spec}/package-spec.coffee (100%) rename {spec-nylas => spec}/quoted-html-parser-spec.coffee (100%) rename {spec-nylas => spec}/quoted-plain-text-parser-spec.coffee (100%) delete mode 100644 spec/space-pen-extensions-spec.coffee delete mode 100644 spec/squirrel-update-spec.coffee rename {spec-nylas => spec}/stores/account-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/contact-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/database-setup-query-builder-spec.coffee (100%) rename {spec-nylas => spec}/stores/database-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/draft-store-proxy-spec.coffee (100%) rename {spec-nylas => spec}/stores/draft-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/event-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/file-download-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/file-upload-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/focused-contacts-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/focused-content-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/focused-mail-view-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/message-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/metadata-store-spec.coffee (100%) rename {spec-nylas => spec}/stores/task-queue-spec.coffee (100%) rename {spec-nylas => spec}/stores/unread-count-store-spec.coffee (100%) rename {spec-nylas => spec}/style-manager-spec.coffee (100%) rename {spec-nylas => spec}/styles-element-spec.coffee (100%) rename {spec-nylas => spec}/tasks/change-folder-task-spec.coffee (100%) rename {spec-nylas => spec}/tasks/change-labels-task-spec.coffee (100%) rename {spec-nylas => spec}/tasks/change-mail-task-spec.coffee (100%) rename {spec-nylas => spec}/tasks/change-starred-task-spec.coffee (100%) rename {spec-nylas => spec}/tasks/change-unread-task-spec.coffee (100%) rename {spec-nylas => spec}/tasks/event-rsvp-spec.coffee (100%) rename {spec-nylas => spec}/tasks/file-upload-task-spec.coffee (100%) rename {spec-nylas => spec}/tasks/mark-message-read-spec.coffee (100%) rename {spec-nylas => spec}/tasks/remove-thread-helper-spec.coffee (100%) rename {spec-nylas => spec}/tasks/send-draft-spec.coffee (100%) rename {spec-nylas => spec}/tasks/syncback-category-task-spec.coffee (100%) rename {spec-nylas => spec}/tasks/syncback-draft-spec.coffee (100%) rename {spec-nylas => spec}/tasks/task-spec.coffee (100%) rename {spec-nylas => spec}/test_utils.coffee (100%) rename {spec-nylas => spec}/theme-manager-spec.coffee (100%) rename {spec-nylas => spec}/undo-manager-spec.coffee (100%) rename {spec-nylas => spec}/utils-spec.coffee (100%) delete mode 100644 spec/window-spec.coffee delete mode 100644 spec/workspace-spec.coffee diff --git a/.gitignore b/.gitignore index 34d69debb..27632eba6 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ spec/fixtures/evil-files/ yoursway-create-dmg *nylas-private-* -!spec-nylas/fixtures/packages/package-with-incompatible-native-module/node_modules +!spec/fixtures/packages/package-with-incompatible-native-module/node_modules #emacs *~ diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index aa09bfc25..1c5e709b1 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -206,9 +206,8 @@ module.exports = (grunt) -> 'dot-nylas/**/*.coffee' 'src/**/*.coffee' 'src/**/*.cjsx' + 'spec/**/*.cjsx' 'spec/**/*.coffee' - 'spec-nylas/**/*.cjsx' - 'spec-nylas/**/*.coffee' ] coffeelint: @@ -226,9 +225,8 @@ module.exports = (grunt) -> 'build/Gruntfile.coffee' ] test: [ + 'spec/**/*.cjsx' 'spec/**/*.coffee' - 'spec-nylas/**/*.cjsx' - 'spec-nylas/**/*.coffee' ] static: [ 'static/**/*.coffee' diff --git a/build/tasks/build-task.coffee b/build/tasks/build-task.coffee index afcf6285b..947ec0bb4 100644 --- a/build/tasks/build-task.coffee +++ b/build/tasks/build-task.coffee @@ -160,7 +160,6 @@ module.exports = (grunt) -> cp directory, path.join(appDir, directory), filter: filterPackage cp 'spec', path.join(appDir, 'spec') - cp 'spec-nylas', path.join(appDir, 'spec-nylas') cp 'examples', path.join(appDir, 'examples') cp 'src', path.join(appDir, 'src'), filter: /.+\.(cson|coffee|cjsx|jsx)$/ cp 'static', path.join(appDir, 'static') diff --git a/internal_packages/worker-sync/spec/nylas-sync-worker-pool-spec.coffee b/internal_packages/worker-sync/spec/nylas-sync-worker-pool-spec.coffee index 4d94921d1..ee70e9f4f 100644 --- a/internal_packages/worker-sync/spec/nylas-sync-worker-pool-spec.coffee +++ b/internal_packages/worker-sync/spec/nylas-sync-worker-pool-spec.coffee @@ -117,4 +117,4 @@ describe "NylasSyncWorkerPool", -> expect(DatabaseStore.unpersistModel).toHaveBeenCalledWith(@thread) describe "handleModelResponse", -> - # SEE spec-nylas/nylas-api-spec.coffee + # SEE spec/nylas-api-spec.coffee diff --git a/spec-nylas/fixtures/css.css b/spec-nylas/fixtures/css.css deleted file mode 100644 index d5ae97e68..000000000 --- a/spec-nylas/fixtures/css.css +++ /dev/null @@ -1,5 +0,0 @@ -body { - font-size: 1234px; - width: 110%; - font-weight: bold !important; -} diff --git a/spec-nylas/fixtures/module-cache/file.json b/spec-nylas/fixtures/module-cache/file.json deleted file mode 100644 index c8c4105eb..000000000 --- a/spec-nylas/fixtures/module-cache/file.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "foo": "bar" -} diff --git a/spec-nylas/fixtures/sample.less b/spec-nylas/fixtures/sample.less deleted file mode 100644 index a076a9d01..000000000 --- a/spec-nylas/fixtures/sample.less +++ /dev/null @@ -1,8 +0,0 @@ -@color: #4D926F; - -#header { - color: @color; -} -h2 { - color: @color; -} \ No newline at end of file diff --git a/spec/6to5-spec.coffee b/spec/6to5-spec.coffee deleted file mode 100644 index 2cb8d1ba6..000000000 --- a/spec/6to5-spec.coffee +++ /dev/null @@ -1,41 +0,0 @@ -to5 = require '../src/6to5' -crypto = require 'crypto' - -describe "6to5 transpiler support", -> - describe "::create6to5VersionAndOptionsDigest", -> - it "returns a digest for the library version and specified options", -> - defaultOptions = - blacklist: [ - 'useStrict' - ] - experimental: true - optional: [ - 'asyncToGenerator' - ] - reactCompat: true - sourceMap: 'inline' - version = '3.0.14' - shasum = crypto.createHash('sha1') - shasum.update('6to5-core', 'utf8') - shasum.update('\0', 'utf8') - shasum.update(version, 'utf8') - shasum.update('\0', 'utf8') - shasum.update('{"blacklist": ["useStrict",],"experimental": true,"optional": ["asyncToGenerator",],"reactCompat": true,"sourceMap": "inline",}') - expectedDigest = shasum.digest('hex') - - observedDigest = to5.create6to5VersionAndOptionsDigest(version, defaultOptions) - expect(observedDigest).toEqual expectedDigest - - describe "when a .js file starts with 'use 6to5';", -> - it "transpiles it using 6to5", -> - transpiled = require('./fixtures/6to5/single-quotes.js') - expect(transpiled(3)).toBe 4 - - describe 'when a .js file starts with "use 6to5";', -> - it "transpiles it using 6to5", -> - transpiled = require('./fixtures/6to5/double-quotes.js') - expect(transpiled(3)).toBe 4 - - describe "when a .js file does not start with 'use 6to6';", -> - it "does not transpile it using 6to5", -> - expect(-> require('./fixtures/6to5/invalid.js')).toThrow() diff --git a/spec-nylas/action-bridge-spec.coffee b/spec/action-bridge-spec.coffee similarity index 100% rename from spec-nylas/action-bridge-spec.coffee rename to spec/action-bridge-spec.coffee diff --git a/spec-nylas/atom-spec.coffee b/spec/atom-spec.coffee similarity index 100% rename from spec-nylas/atom-spec.coffee rename to spec/atom-spec.coffee diff --git a/spec-nylas/auto-update-manager-spec.coffee b/spec/auto-update-manager-spec.coffee similarity index 100% rename from spec-nylas/auto-update-manager-spec.coffee rename to spec/auto-update-manager-spec.coffee diff --git a/spec-nylas/buffered-process-spec.coffee b/spec/buffered-process-spec.coffee similarity index 100% rename from spec-nylas/buffered-process-spec.coffee rename to spec/buffered-process-spec.coffee diff --git a/spec-nylas/clipboard-spec.coffee b/spec/clipboard-spec.coffee similarity index 100% rename from spec-nylas/clipboard-spec.coffee rename to spec/clipboard-spec.coffee diff --git a/spec/command-installer-spec.coffee b/spec/command-installer-spec.coffee deleted file mode 100644 index b87a08edc..000000000 --- a/spec/command-installer-spec.coffee +++ /dev/null @@ -1,34 +0,0 @@ -path = require 'path' -fs = require 'fs-plus' -temp = require 'temp' -installer = require '../src/command-installer' - -describe "install(commandPath, callback)", -> - commandFilePath = temp.openSync("atom-command").path - commandName = path.basename(commandFilePath) - installationPath = temp.mkdirSync("atom-bin") - installationFilePath = path.join(installationPath, commandName) - - beforeEach -> - fs.chmodSync(commandFilePath, '755') - spyOn(installer, 'getInstallDirectory').andReturn installationPath - - describe "on #darwin", -> - it "symlinks the command and makes it executable", -> - expect(fs.isFileSync(commandFilePath)).toBeTruthy() - expect(fs.isFileSync(installationFilePath)).toBeFalsy() - - installDone = false - installError = null - installer.createSymlink commandFilePath, false, (error) -> - installDone = true - installError = error - - waitsFor -> - installDone - - runs -> - expect(installError).toBeNull() - expect(fs.isFileSync(installationFilePath)).toBeTruthy() - expect(fs.realpathSync(installationFilePath)).toBe fs.realpathSync(commandFilePath) - expect(fs.isExecutableSync(installationFilePath)).toBeTruthy() diff --git a/spec/command-registry-spec.coffee b/spec/command-registry-spec.coffee deleted file mode 100644 index 31b807adc..000000000 --- a/spec/command-registry-spec.coffee +++ /dev/null @@ -1,218 +0,0 @@ -CommandRegistry = require '../src/command-registry' -_ = require 'underscore' - -describe "CommandRegistry", -> - [registry, parent, child, grandchild] = [] - - beforeEach -> - parent = document.createElement("div") - child = document.createElement("div") - grandchild = document.createElement("div") - parent.classList.add('parent') - child.classList.add('child') - grandchild.classList.add('grandchild') - child.appendChild(grandchild) - parent.appendChild(child) - document.querySelector('#jasmine-content').appendChild(parent) - - registry = new CommandRegistry - - afterEach -> - registry.destroy() - - describe "when a command event is dispatched on an element", -> - it "invokes callbacks with selectors matching the target", -> - called = false - registry.add '.grandchild', 'command', (event) -> - expect(this).toBe grandchild - expect(event.type).toBe 'command' - expect(event.eventPhase).toBe Event.BUBBLING_PHASE - expect(event.target).toBe grandchild - expect(event.currentTarget).toBe grandchild - called = true - - grandchild.dispatchEvent(new CustomEvent('command', bubbles: true)) - expect(called).toBe true - - it "invokes callbacks with selectors matching ancestors of the target", -> - calls = [] - - registry.add '.child', 'command', (event) -> - expect(this).toBe child - expect(event.target).toBe grandchild - expect(event.currentTarget).toBe child - calls.push('child') - - registry.add '.parent', 'command', (event) -> - expect(this).toBe parent - expect(event.target).toBe grandchild - expect(event.currentTarget).toBe parent - calls.push('parent') - - grandchild.dispatchEvent(new CustomEvent('command', bubbles: true)) - expect(calls).toEqual ['child', 'parent'] - - it "invokes inline listeners prior to listeners applied via selectors", -> - calls = [] - registry.add '.grandchild', 'command', -> calls.push('grandchild') - registry.add child, 'command', -> calls.push('child-inline') - registry.add '.child', 'command', -> calls.push('child') - registry.add '.parent', 'command', -> calls.push('parent') - - grandchild.dispatchEvent(new CustomEvent('command', bubbles: true)) - expect(calls).toEqual ['grandchild', 'child-inline', 'child', 'parent'] - - it "orders multiple matching listeners for an element by selector specificity", -> - child.classList.add('foo', 'bar') - calls = [] - - registry.add '.foo.bar', 'command', -> calls.push('.foo.bar') - registry.add '.foo', 'command', -> calls.push('.foo') - registry.add '.bar', 'command', -> calls.push('.bar') # specificity ties favor commands added later, like CSS - - grandchild.dispatchEvent(new CustomEvent('command', bubbles: true)) - expect(calls).toEqual ['.foo.bar', '.bar', '.foo'] - - it "stops bubbling through ancestors when .stopPropagation() is called on the event", -> - calls = [] - - registry.add '.parent', 'command', -> calls.push('parent') - registry.add '.child', 'command', -> calls.push('child-2') - registry.add '.child', 'command', (event) -> calls.push('child-1'); event.stopPropagation() - - dispatchedEvent = new CustomEvent('command', bubbles: true) - spyOn(dispatchedEvent, 'stopPropagation') - grandchild.dispatchEvent(dispatchedEvent) - expect(calls).toEqual ['child-1', 'child-2'] - expect(dispatchedEvent.stopPropagation).toHaveBeenCalled() - - it "stops invoking callbacks when .stopImmediatePropagation() is called on the event", -> - calls = [] - - registry.add '.parent', 'command', -> calls.push('parent') - registry.add '.child', 'command', -> calls.push('child-2') - registry.add '.child', 'command', (event) -> calls.push('child-1'); event.stopImmediatePropagation() - - dispatchedEvent = new CustomEvent('command', bubbles: true) - spyOn(dispatchedEvent, 'stopImmediatePropagation') - grandchild.dispatchEvent(dispatchedEvent) - expect(calls).toEqual ['child-1'] - expect(dispatchedEvent.stopImmediatePropagation).toHaveBeenCalled() - - it "forwards .preventDefault() calls from the synthetic event to the original", -> - registry.add '.child', 'command', (event) -> event.preventDefault() - - dispatchedEvent = new CustomEvent('command', bubbles: true) - spyOn(dispatchedEvent, 'preventDefault') - grandchild.dispatchEvent(dispatchedEvent) - expect(dispatchedEvent.preventDefault).toHaveBeenCalled() - - it "forwards .abortKeyBinding() calls from the synthetic event to the original", -> - registry.add '.child', 'command', (event) -> event.abortKeyBinding() - - dispatchedEvent = new CustomEvent('command', bubbles: true) - dispatchedEvent.abortKeyBinding = jasmine.createSpy('abortKeyBinding') - grandchild.dispatchEvent(dispatchedEvent) - expect(dispatchedEvent.abortKeyBinding).toHaveBeenCalled() - - it "allows listeners to be removed via a disposable returned by ::add", -> - calls = [] - - disposable1 = registry.add '.parent', 'command', -> calls.push('parent') - disposable2 = registry.add '.child', 'command', -> calls.push('child') - - disposable1.dispose() - grandchild.dispatchEvent(new CustomEvent('command', bubbles: true)) - expect(calls).toEqual ['child'] - - calls = [] - disposable2.dispose() - grandchild.dispatchEvent(new CustomEvent('command', bubbles: true)) - expect(calls).toEqual [] - - it "allows multiple commands to be registered under one selector when called with an object", -> - calls = [] - - disposable = registry.add '.child', - 'command-1': -> calls.push('command-1') - 'command-2': -> calls.push('command-2') - - grandchild.dispatchEvent(new CustomEvent('command-1', bubbles: true)) - grandchild.dispatchEvent(new CustomEvent('command-2', bubbles: true)) - - expect(calls).toEqual ['command-1', 'command-2'] - - calls = [] - disposable.dispose() - grandchild.dispatchEvent(new CustomEvent('command-1', bubbles: true)) - grandchild.dispatchEvent(new CustomEvent('command-2', bubbles: true)) - expect(calls).toEqual [] - - describe "::findCommands({target})", -> - it "returns commands that can be invoked on the target or its ancestors", -> - registry.add '.parent', 'namespace:command-1', -> - registry.add '.child', 'namespace:command-2', -> - registry.add '.grandchild', 'namespace:command-3', -> - registry.add '.grandchild.no-match', 'namespace:command-4', -> - - registry.add grandchild, 'namespace:inline-command-1', -> - registry.add child, 'namespace:inline-command-2', -> - - commands = registry.findCommands(target: grandchild) - nonJqueryCommands = _.reject commands, (cmd) -> cmd.jQuery - expect(nonJqueryCommands).toEqual [ - {name: 'namespace:inline-command-1', displayName: 'Namespace: Inline Command 1'} - {name: 'namespace:command-3', displayName: 'Namespace: Command 3'} - {name: 'namespace:inline-command-2', displayName: 'Namespace: Inline Command 2'} - {name: 'namespace:command-2', displayName: 'Namespace: Command 2'} - {name: 'namespace:command-1', displayName: 'Namespace: Command 1'} - ] - - describe "::dispatch(target, commandName)", -> - it "simulates invocation of the given command ", -> - called = false - registry.add '.grandchild', 'command', (event) -> - expect(this).toBe grandchild - expect(event.type).toBe 'command' - expect(event.eventPhase).toBe Event.BUBBLING_PHASE - expect(event.target).toBe grandchild - expect(event.currentTarget).toBe grandchild - called = true - - registry.dispatch(grandchild, 'command') - expect(called).toBe true - - it "returns a boolean indicating whether any listeners matched the command", -> - registry.add '.grandchild', 'command', -> - - expect(registry.dispatch(grandchild, 'command')).toBe true - expect(registry.dispatch(grandchild, 'bogus')).toBe false - expect(registry.dispatch(parent, 'command')).toBe false - - describe "::getSnapshot and ::restoreSnapshot", -> - it "removes all command handlers except for those in the snapshot", -> - registry.add '.parent', 'namespace:command-1', -> - registry.add '.child', 'namespace:command-2', -> - snapshot = registry.getSnapshot() - registry.add '.grandchild', 'namespace:command-3', -> - - expect(registry.findCommands(target: grandchild)[0..2]).toEqual [ - {name: 'namespace:command-3', displayName: 'Namespace: Command 3'} - {name: 'namespace:command-2', displayName: 'Namespace: Command 2'} - {name: 'namespace:command-1', displayName: 'Namespace: Command 1'} - ] - - registry.restoreSnapshot(snapshot) - - expect(registry.findCommands(target: grandchild)[0..1]).toEqual [ - {name: 'namespace:command-2', displayName: 'Namespace: Command 2'} - {name: 'namespace:command-1', displayName: 'Namespace: Command 1'} - ] - - registry.add '.grandchild', 'namespace:command-3', -> - registry.restoreSnapshot(snapshot) - - expect(registry.findCommands(target: grandchild)[0..1]).toEqual [ - {name: 'namespace:command-2', displayName: 'Namespace: Command 2'} - {name: 'namespace:command-1', displayName: 'Namespace: Command 1'} - ] diff --git a/spec-nylas/component-registry-spec.coffee b/spec/component-registry-spec.coffee similarity index 100% rename from spec-nylas/component-registry-spec.coffee rename to spec/component-registry-spec.coffee diff --git a/spec-nylas/components/evented-iframe-spec.cjsx b/spec/components/evented-iframe-spec.cjsx similarity index 100% rename from spec-nylas/components/evented-iframe-spec.cjsx rename to spec/components/evented-iframe-spec.cjsx diff --git a/spec-nylas/components/multiselect-list-interaction-handler-spec.coffee b/spec/components/multiselect-list-interaction-handler-spec.coffee similarity index 100% rename from spec-nylas/components/multiselect-list-interaction-handler-spec.coffee rename to spec/components/multiselect-list-interaction-handler-spec.coffee diff --git a/spec-nylas/components/multiselect-split-interaction-handler-spec.coffee b/spec/components/multiselect-split-interaction-handler-spec.coffee similarity index 100% rename from spec-nylas/components/multiselect-split-interaction-handler-spec.coffee rename to spec/components/multiselect-split-interaction-handler-spec.coffee diff --git a/spec-nylas/components/tokenizing-text-field-spec.cjsx b/spec/components/tokenizing-text-field-spec.cjsx similarity index 100% rename from spec-nylas/components/tokenizing-text-field-spec.cjsx rename to spec/components/tokenizing-text-field-spec.cjsx diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee deleted file mode 100644 index ea274e6d8..000000000 --- a/spec/config-spec.coffee +++ /dev/null @@ -1,1670 +0,0 @@ -path = require 'path' -temp = require 'temp' -CSON = require 'season' -fs = require 'fs-plus' -Grim = require 'grim' - -describe "Config", -> - dotNylasPath = null - - beforeEach -> - dotNylasPath = temp.path('dot-nylas-dir') - atom.config.configDirPath = dotNylasPath - atom.config.configFilePath = path.join(atom.config.configDirPath, "config.cson") - - describe ".get(keyPath, {scope, sources, excludeSources})", -> - it "allows a key path's value to be read", -> - expect(atom.config.set("foo.bar.baz", 42)).toBe true - expect(atom.config.get("foo.bar.baz")).toBe 42 - expect(atom.config.get("foo.quux")).toBeUndefined() - - it "returns a deep clone of the key path's value", -> - atom.config.set('value', array: [1, b: 2, 3]) - retrievedValue = atom.config.get('value') - retrievedValue.array[0] = 4 - retrievedValue.array[1].b = 2.1 - expect(atom.config.get('value')).toEqual(array: [1, b: 2, 3]) - - it "merges defaults into the returned value if both the assigned value and the default value are objects", -> - atom.config.setDefaults("foo.bar", baz: 1, ok: 2) - atom.config.set("foo.bar", baz: 3) - expect(atom.config.get("foo.bar")).toEqual {baz: 3, ok: 2} - - atom.config.setDefaults("other", baz: 1) - atom.config.set("other", 7) - expect(atom.config.get("other")).toBe 7 - - atom.config.set("bar.baz", a: 3) - atom.config.setDefaults("bar", baz: 7) - expect(atom.config.get("bar.baz")).toEqual {a: 3} - - describe "when a 'sources' option is specified", -> - it "only retrieves values from the specified sources", -> - atom.config.set("x.y", 1, scopeSelector: ".foo", source: "a") - atom.config.set("x.y", 2, scopeSelector: ".foo", source: "b") - atom.config.set("x.y", 3, scopeSelector: ".foo", source: "c") - atom.config.setSchema("x.y", type: "integer", default: 4) - - expect(atom.config.get("x.y", sources: ["a"], scope: [".foo"])).toBe 1 - expect(atom.config.get("x.y", sources: ["b"], scope: [".foo"])).toBe 2 - expect(atom.config.get("x.y", sources: ["c"], scope: [".foo"])).toBe 3 - # Schema defaults never match a specific source. We could potentially add a special "schema" source. - expect(atom.config.get("x.y", sources: ["x"], scope: [".foo"])).toBeUndefined() - - expect(atom.config.get(null, sources: ['a'], scope: [".foo"]).x.y).toBe 1 - - describe "when an 'excludeSources' option is specified", -> - it "only retrieves values from the specified sources", -> - atom.config.set("x.y", 0) - atom.config.set("x.y", 1, scopeSelector: ".foo", source: "a") - atom.config.set("x.y", 2, scopeSelector: ".foo", source: "b") - atom.config.set("x.y", 3, scopeSelector: ".foo", source: "c") - atom.config.setSchema("x.y", type: "integer", default: 4) - - expect(atom.config.get("x.y", excludeSources: ["a"], scope: [".foo"])).toBe 3 - expect(atom.config.get("x.y", excludeSources: ["c"], scope: [".foo"])).toBe 2 - expect(atom.config.get("x.y", excludeSources: ["b", "c"], scope: [".foo"])).toBe 1 - expect(atom.config.get("x.y", excludeSources: ["b", "c", "a"], scope: [".foo"])).toBe 0 - expect(atom.config.get("x.y", excludeSources: ["b", "c", "a", atom.config.getUserConfigPath()], scope: [".foo"])).toBe 4 - expect(atom.config.get("x.y", excludeSources: [atom.config.getUserConfigPath()])).toBe 4 - - describe "when a 'scope' option is given", -> - it "returns the property with the most specific scope selector", -> - atom.config.set("foo.bar.baz", 42, scopeSelector: ".source.coffee .string.quoted.double.coffee") - atom.config.set("foo.bar.baz", 22, scopeSelector: ".source .string.quoted.double") - atom.config.set("foo.bar.baz", 11, scopeSelector: ".source") - - expect(atom.config.get("foo.bar.baz", scope: [".source.coffee", ".string.quoted.double.coffee"])).toBe 42 - expect(atom.config.get("foo.bar.baz", scope: [".source.js", ".string.quoted.double.js"])).toBe 22 - expect(atom.config.get("foo.bar.baz", scope: [".source.js", ".variable.assignment.js"])).toBe 11 - expect(atom.config.get("foo.bar.baz", scope: [".text"])).toBeUndefined() - - it "favors the most recently added properties in the event of a specificity tie", -> - atom.config.set("foo.bar.baz", 42, scopeSelector: ".source.coffee .string.quoted.single") - atom.config.set("foo.bar.baz", 22, scopeSelector: ".source.coffee .string.quoted.double") - - expect(atom.config.get("foo.bar.baz", scope: [".source.coffee", ".string.quoted.single"])).toBe 42 - expect(atom.config.get("foo.bar.baz", scope: [".source.coffee", ".string.quoted.single.double"])).toBe 22 - - describe 'when there are global defaults', -> - it 'falls back to the global when there is no scoped property specified', -> - atom.config.setDefaults("foo", hasDefault: 'ok') - expect(atom.config.get("foo.hasDefault", scope: [".source.coffee", ".string.quoted.single"])).toBe 'ok' - - describe 'when package settings are added after user settings', -> - it "returns the user's setting because the user's setting has higher priority", -> - atom.config.set("foo.bar.baz", 100, scopeSelector: ".source.coffee") - atom.config.set("foo.bar.baz", 1, scopeSelector: ".source.coffee", source: "some-package") - expect(atom.config.get("foo.bar.baz", scope: [".source.coffee"])).toBe 100 - - describe ".getAll(keyPath, {scope, sources, excludeSources})", -> - it "reads all of the values for a given key-path", -> - expect(atom.config.set("foo", 41)).toBe true - expect(atom.config.set("foo", 43, scopeSelector: ".a .b")).toBe true - expect(atom.config.set("foo", 42, scopeSelector: ".a")).toBe true - expect(atom.config.set("foo", 44, scopeSelector: ".a .b.c")).toBe true - - expect(atom.config.set("foo", -44, scopeSelector: ".d")).toBe true - - expect(atom.config.getAll("foo", scope: [".a", ".b.c"])).toEqual [ - {scopeSelector: '.a .b.c', value: 44} - {scopeSelector: '.a .b', value: 43} - {scopeSelector: '.a', value: 42} - {scopeSelector: '*', value: 41} - ] - - it "includes the schema's default value", -> - atom.config.setSchema("foo", type: 'number', default: 40) - expect(atom.config.set("foo", 43, scopeSelector: ".a .b")).toBe true - expect(atom.config.getAll("foo", scope: [".a", ".b.c"])).toEqual [ - {scopeSelector: '.a .b', value: 43} - {scopeSelector: '*', value: 40} - ] - - describe ".set(keyPath, value, {source, scopeSelector})", -> - it "allows a key path's value to be written", -> - expect(atom.config.set("foo.bar.baz", 42)).toBe true - expect(atom.config.get("foo.bar.baz")).toBe 42 - - it "saves the user's config to disk after it stops changing", -> - atom.config.set("foo.bar.baz", 42) - advanceClock(50) - expect(atom.config.save).not.toHaveBeenCalled() - atom.config.set("foo.bar.baz", 43) - advanceClock(50) - expect(atom.config.save).not.toHaveBeenCalled() - atom.config.set("foo.bar.baz", 44) - advanceClock(150) - expect(atom.config.save).toHaveBeenCalled() - - it "does not save when a non-default 'source' is given", -> - atom.config.set("foo.bar.baz", 42, source: 'some-other-source', scopeSelector: '.a') - advanceClock(500) - expect(atom.config.save).not.toHaveBeenCalled() - - it "does not allow a 'source' option without a 'scopeSelector'", -> - expect(-> atom.config.set("foo", 1, source: [".source.ruby"])).toThrow() - - describe "when the key-path is null", -> - it "sets the root object", -> - expect(atom.config.set(null, editor: tabLength: 6)).toBe true - expect(atom.config.get("editor.tabLength")).toBe 6 - expect(atom.config.set(null, editor: tabLength: 8, scopeSelector: ['.source.js'])).toBe true - expect(atom.config.get("editor.tabLength", scope: ['.source.js'])).toBe 8 - - describe "when the value equals the default value", -> - it "does not store the value in the user's config", -> - atom.config.setDefaults "foo", - same: 1 - changes: 1 - sameArray: [1, 2, 3] - sameObject: {a: 1, b: 2} - null: null - undefined: undefined - expect(atom.config.settings.foo).toBeUndefined() - - atom.config.set('foo.same', 1) - atom.config.set('foo.changes', 2) - atom.config.set('foo.sameArray', [1, 2, 3]) - atom.config.set('foo.null', undefined) - atom.config.set('foo.undefined', null) - atom.config.set('foo.sameObject', {b: 2, a: 1}) - - expect(atom.config.get("foo.same", sources: [atom.config.getUserConfigPath()])).toBeUndefined() - - expect(atom.config.get("foo.changes", sources: [atom.config.getUserConfigPath()])).toBe 2 - atom.config.set('foo.changes', 1) - expect(atom.config.get("foo.changes", sources: [atom.config.getUserConfigPath()])).toBeUndefined() - - describe "when a 'scopeSelector' is given", -> - it "sets the value and overrides the others", -> - atom.config.set("foo.bar.baz", 42, scopeSelector: ".source.coffee .string.quoted.double.coffee") - atom.config.set("foo.bar.baz", 22, scopeSelector: ".source .string.quoted.double") - atom.config.set("foo.bar.baz", 11, scopeSelector: ".source") - - expect(atom.config.get("foo.bar.baz", scope: [".source.coffee", ".string.quoted.double.coffee"])).toBe 42 - - expect(atom.config.set("foo.bar.baz", 100, scopeSelector: ".source.coffee .string.quoted.double.coffee")).toBe true - expect(atom.config.get("foo.bar.baz", scope: [".source.coffee", ".string.quoted.double.coffee"])).toBe 100 - - describe ".unset(keyPath, {source, scopeSelector})", -> - beforeEach -> - atom.config.setSchema 'foo', - type: 'object' - properties: - bar: - type: 'object' - properties: - baz: - type: 'integer' - default: 0 - ok: - type: 'integer' - default: 0 - quux: - type: 'integer' - default: 0 - - it "sets the value of the key path to its default", -> - atom.config.setDefaults('a', b: 3) - atom.config.set('a.b', 4) - expect(atom.config.get('a.b')).toBe 4 - atom.config.unset('a.b') - expect(atom.config.get('a.b')).toBe 3 - - atom.config.set('a.c', 5) - expect(atom.config.get('a.c')).toBe 5 - atom.config.unset('a.c') - expect(atom.config.get('a.c')).toBeUndefined() - - it "calls ::save()", -> - atom.config.setDefaults('a', b: 3) - atom.config.set('a.b', 4) - atom.config.save.reset() - - atom.config.unset('a.c') - advanceClock(500) - expect(atom.config.save.callCount).toBe 1 - - describe "when no 'scopeSelector' is given", -> - describe "when a 'source' but no key-path is given", -> - it "removes all scoped settings with the given source", -> - atom.config.set("foo.bar.baz", 1, scopeSelector: ".a", source: "source-a") - atom.config.set("foo.bar.quux", 2, scopeSelector: ".b", source: "source-a") - expect(atom.config.get("foo.bar", scope: [".a.b"])).toEqual(baz: 1, quux: 2) - - atom.config.unset(null, source: "source-a") - expect(atom.config.get("foo.bar", scope: [".a"])).toEqual(baz: 0, ok: 0) - - describe "when a 'source' and a key-path is given", -> - it "removes all scoped settings with the given source and key-path", -> - atom.config.set("foo.bar.baz", 1) - atom.config.set("foo.bar.baz", 2, scopeSelector: ".a", source: "source-a") - atom.config.set("foo.bar.baz", 3, scopeSelector: ".a.b", source: "source-b") - expect(atom.config.get("foo.bar.baz", scope: [".a.b"])).toEqual(3) - - atom.config.unset("foo.bar.baz", source: "source-b") - expect(atom.config.get("foo.bar.baz", scope: [".a.b"])).toEqual(2) - expect(atom.config.get("foo.bar.baz")).toEqual(1) - - describe "when no 'source' is given", -> - it "removes all scoped and unscoped properties for that key-path", -> - atom.config.setDefaults("foo.bar", baz: 100) - - atom.config.set("foo.bar", { baz: 1, ok: 2 }, scopeSelector: ".a") - atom.config.set("foo.bar", { baz: 11, ok: 12 }, scopeSelector: ".b") - atom.config.set("foo.bar", { baz: 21, ok: 22 }) - - atom.config.unset("foo.bar.baz") - - expect(atom.config.get("foo.bar.baz", scope: [".a"])).toBe 100 - expect(atom.config.get("foo.bar.baz", scope: [".b"])).toBe 100 - expect(atom.config.get("foo.bar.baz")).toBe 100 - - expect(atom.config.get("foo.bar.ok", scope: [".a"])).toBe 2 - expect(atom.config.get("foo.bar.ok", scope: [".b"])).toBe 12 - expect(atom.config.get("foo.bar.ok")).toBe 22 - - describe "when a 'scopeSelector' is given", -> - it "restores the global default when no scoped default set", -> - atom.config.setDefaults("foo", bar: baz: 10) - atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee') - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 55 - - atom.config.unset('foo.bar.baz', scopeSelector: '.source.coffee') - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 10 - - it "restores the scoped default when a scoped default is set", -> - atom.config.setDefaults("foo", bar: baz: 10) - atom.config.set("foo.bar.baz", 42, scopeSelector: ".source.coffee", source: "some-source") - atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee') - atom.config.set('foo.bar.ok', 100, scopeSelector: '.source.coffee') - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 55 - - atom.config.unset('foo.bar.baz', scopeSelector: '.source.coffee') - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 42 - expect(atom.config.get('foo.bar.ok', scope: ['.source.coffee'])).toBe 100 - - it "calls ::save()", -> - atom.config.setDefaults("foo", bar: baz: 10) - atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee') - atom.config.save.reset() - - atom.config.unset('foo.bar.baz', scopeSelector: '.source.coffee') - advanceClock(150) - expect(atom.config.save.callCount).toBe 1 - - it "allows removing settings for a specific source and scope selector", -> - atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee', source: "source-a") - atom.config.set('foo.bar.baz', 65, scopeSelector: '.source.coffee', source: "source-b") - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 65 - - atom.config.unset('foo.bar.baz', source: "source-b", scopeSelector: ".source.coffee") - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee', '.string'])).toBe 55 - - it "allows removing all settings for a specific source", -> - atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee', source: "source-a") - atom.config.set('foo.bar.baz', 65, scopeSelector: '.source.coffee', source: "source-b") - atom.config.set('foo.bar.ok', 65, scopeSelector: '.source.coffee', source: "source-b") - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 65 - - atom.config.unset(null, source: "source-b", scopeSelector: ".source.coffee") - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee', '.string'])).toBe 55 - expect(atom.config.get('foo.bar.ok', scope: ['.source.coffee', '.string'])).toBe 0 - - it "does not call ::save or add a scoped property when no value has been set", -> - # see https://github.com/atom/atom/issues/4175 - atom.config.setDefaults("foo", bar: baz: 10) - atom.config.unset('foo.bar.baz', scopeSelector: '.source.coffee') - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 10 - - expect(atom.config.save).not.toHaveBeenCalled() - - scopedProperties = atom.config.scopedSettingsStore.propertiesForSource('user-config') - expect(scopedProperties['.coffee.source']).toBeUndefined() - - it "removes the scoped value when it was the only set value on the object", -> - spyOn(CSON, 'writeFileSync') - atom.config.save.andCallThrough() - - atom.config.setDefaults("foo", bar: baz: 10) - atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee') - atom.config.set('foo.bar.ok', 20, scopeSelector: '.source.coffee') - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 55 - - advanceClock(150) - CSON.writeFileSync.reset() - - atom.config.unset('foo.bar.baz', scopeSelector: '.source.coffee') - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 10 - expect(atom.config.get('foo.bar.ok', scope: ['.source.coffee'])).toBe 20 - - advanceClock(150) - expect(CSON.writeFileSync).toHaveBeenCalled() - properties = CSON.writeFileSync.mostRecentCall.args[1] - expect(properties['.coffee.source']).toEqual - foo: - bar: - ok: 20 - CSON.writeFileSync.reset() - - atom.config.unset('foo.bar.ok', scopeSelector: '.source.coffee') - - advanceClock(150) - expect(CSON.writeFileSync).toHaveBeenCalled() - properties = CSON.writeFileSync.mostRecentCall.args[1] - expect(properties['.coffee.source']).toBeUndefined() - - it "does not call ::save when the value is already at the default", -> - atom.config.setDefaults("foo", bar: baz: 10) - atom.config.set('foo.bar.baz', 55) - atom.config.save.reset() - - atom.config.unset('foo.bar.ok', scopeSelector: '.source.coffee') - expect(atom.config.save).not.toHaveBeenCalled() - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 55 - - it "deprecates passing a scope selector as the first argument", -> - atom.config.setDefaults("foo", bar: baz: 10) - atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee') - - spyOn(Grim, 'deprecate') - atom.config.unset('.source.coffee', 'foo.bar.baz') - expect(Grim.deprecate).toHaveBeenCalled() - - expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 10 - - describe ".onDidChange(keyPath, {scope})", -> - [observeHandler, observeSubscription] = [] - - describe 'when a keyPath is specified', -> - beforeEach -> - observeHandler = jasmine.createSpy("observeHandler") - atom.config.set("foo.bar.baz", "value 1") - observeSubscription = atom.config.onDidChange "foo.bar.baz", observeHandler - - it "does not fire the given callback with the current value at the keypath", -> - expect(observeHandler).not.toHaveBeenCalled() - - it "fires the callback every time the observed value changes", -> - atom.config.set('foo.bar.baz', "value 2") - expect(observeHandler).toHaveBeenCalledWith({newValue: 'value 2', oldValue: 'value 1'}) - observeHandler.reset() - - observeHandler.andCallFake -> throw new Error("oops") - expect(-> atom.config.set('foo.bar.baz', "value 1")).toThrow("oops") - expect(observeHandler).toHaveBeenCalledWith({newValue: 'value 1', oldValue: 'value 2'}) - observeHandler.reset() - - # Regression: exception in earlier handler shouldn't put observer - # into a bad state. - atom.config.set('something.else', "new value") - expect(observeHandler).not.toHaveBeenCalled() - - describe 'when a keyPath is not specified', -> - beforeEach -> - observeHandler = jasmine.createSpy("observeHandler") - atom.config.set("foo.bar.baz", "value 1") - observeSubscription = atom.config.onDidChange observeHandler - - it "does not fire the given callback initially", -> - expect(observeHandler).not.toHaveBeenCalled() - - it "fires the callback every time any value changes", -> - observeHandler.reset() # clear the initial call - atom.config.set('foo.bar.baz', "value 2") - expect(observeHandler).toHaveBeenCalled() - expect(observeHandler.mostRecentCall.args[0].newValue.foo.bar.baz).toBe("value 2") - expect(observeHandler.mostRecentCall.args[0].oldValue.foo.bar.baz).toBe("value 1") - - observeHandler.reset() - atom.config.set('foo.bar.baz', "value 1") - expect(observeHandler).toHaveBeenCalled() - expect(observeHandler.mostRecentCall.args[0].newValue.foo.bar.baz).toBe("value 1") - expect(observeHandler.mostRecentCall.args[0].oldValue.foo.bar.baz).toBe("value 2") - - observeHandler.reset() - atom.config.set('foo.bar.int', 1) - expect(observeHandler).toHaveBeenCalled() - expect(observeHandler.mostRecentCall.args[0].newValue.foo.bar.int).toBe(1) - expect(observeHandler.mostRecentCall.args[0].oldValue.foo.bar.int).toBe(undefined) - - describe "when a 'scope' is given", -> - it 'calls the supplied callback when the value at the descriptor/keypath changes', -> - changeSpy = jasmine.createSpy('onDidChange callback') - atom.config.onDidChange "foo.bar.baz", scope: [".source.coffee", ".string.quoted.double.coffee"], changeSpy - - atom.config.set("foo.bar.baz", 12) - expect(changeSpy).toHaveBeenCalledWith({oldValue: undefined, newValue: 12}) - changeSpy.reset() - - atom.config.set("foo.bar.baz", 22, scopeSelector: ".source .string.quoted.double", source: "a") - expect(changeSpy).toHaveBeenCalledWith({oldValue: 12, newValue: 22}) - changeSpy.reset() - - atom.config.set("foo.bar.baz", 42, scopeSelector: ".source.coffee .string.quoted.double.coffee", source: "b") - expect(changeSpy).toHaveBeenCalledWith({oldValue: 22, newValue: 42}) - changeSpy.reset() - - atom.config.unset(null, scopeSelector: ".source.coffee .string.quoted.double.coffee", source: "b") - expect(changeSpy).toHaveBeenCalledWith({oldValue: 42, newValue: 22}) - changeSpy.reset() - - atom.config.unset(null, scopeSelector: ".source .string.quoted.double", source: "a") - expect(changeSpy).toHaveBeenCalledWith({oldValue: 22, newValue: 12}) - changeSpy.reset() - - atom.config.set("foo.bar.baz", undefined) - expect(changeSpy).toHaveBeenCalledWith({oldValue: 12, newValue: undefined}) - changeSpy.reset() - - it 'deprecates using a scope descriptor as an optional first argument', -> - keyPath = "foo.bar.baz" - spyOn(Grim, 'deprecate') - atom.config.onDidChange [".source.coffee", ".string.quoted.double.coffee"], keyPath, changeSpy = jasmine.createSpy() - expect(Grim.deprecate).toHaveBeenCalled() - - atom.config.set("foo.bar.baz", 12) - expect(changeSpy).toHaveBeenCalledWith({oldValue: undefined, newValue: 12}) - - describe ".observe(keyPath, {scope})", -> - [observeHandler, observeSubscription] = [] - - beforeEach -> - observeHandler = jasmine.createSpy("observeHandler") - atom.config.set("foo.bar.baz", "value 1") - observeSubscription = atom.config.observe("foo.bar.baz", observeHandler) - - it "fires the given callback with the current value at the keypath", -> - expect(observeHandler).toHaveBeenCalledWith("value 1") - - it "fires the callback every time the observed value changes", -> - observeHandler.reset() # clear the initial call - atom.config.set('foo.bar.baz', "value 2") - expect(observeHandler).toHaveBeenCalledWith("value 2") - observeHandler.reset() - - atom.config.set('foo.bar.baz', "value 1") - expect(observeHandler).toHaveBeenCalledWith("value 1") - advanceClock(100) # complete pending save that was requested in ::set - - observeHandler.reset() - atom.config.loadUserConfig() - expect(observeHandler).toHaveBeenCalledWith(undefined) - - it "fires the callback when the observed value is deleted", -> - observeHandler.reset() # clear the initial call - atom.config.set('foo.bar.baz', undefined) - expect(observeHandler).toHaveBeenCalledWith(undefined) - - it "fires the callback when the full key path goes into and out of existence", -> - observeHandler.reset() # clear the initial call - atom.config.set("foo.bar", undefined) - expect(observeHandler).toHaveBeenCalledWith(undefined) - - observeHandler.reset() - atom.config.set("foo.bar.baz", "i'm back") - expect(observeHandler).toHaveBeenCalledWith("i'm back") - - it "does not fire the callback once the subscription is disposed", -> - observeHandler.reset() # clear the initial call - observeSubscription.dispose() - atom.config.set('foo.bar.baz', "value 2") - expect(observeHandler).not.toHaveBeenCalled() - - it 'does not fire the callback for a similarly named keyPath', -> - bazCatHandler = jasmine.createSpy("bazCatHandler") - observeSubscription = atom.config.observe "foo.bar.bazCat", bazCatHandler - - bazCatHandler.reset() - atom.config.set('foo.bar.baz', "value 10") - expect(bazCatHandler).not.toHaveBeenCalled() - - describe "when a 'scope' is given", -> - otherHandler = null - - beforeEach -> - observeSubscription.dispose() - otherHandler = jasmine.createSpy('otherHandler') - - it "allows settings to be observed in a specific scope", -> - atom.config.observe("foo.bar.baz", scope: [".some.scope"], observeHandler) - atom.config.observe("foo.bar.baz", scope: [".another.scope"], otherHandler) - - atom.config.set('foo.bar.baz', "value 2", scopeSelector: ".some") - expect(observeHandler).toHaveBeenCalledWith("value 2") - expect(otherHandler).not.toHaveBeenCalledWith("value 2") - - it "deprecates using a scope descriptor as the first argument", -> - spyOn(Grim, 'deprecate') - atom.config.observe([".some.scope"], "foo.bar.baz", observeHandler) - atom.config.observe([".another.scope"], "foo.bar.baz", otherHandler) - expect(Grim.deprecate).toHaveBeenCalled() - - atom.config.set('foo.bar.baz', "value 2", scopeSelector: ".some") - expect(observeHandler).toHaveBeenCalledWith("value 2") - expect(otherHandler).not.toHaveBeenCalledWith("value 2") - - it 'calls the callback when properties with more specific selectors are removed', -> - changeSpy = jasmine.createSpy() - atom.config.observe("foo.bar.baz", scope: [".source.coffee", ".string.quoted.double.coffee"], changeSpy) - expect(changeSpy).toHaveBeenCalledWith("value 1") - changeSpy.reset() - - atom.config.set("foo.bar.baz", 12) - expect(changeSpy).toHaveBeenCalledWith(12) - changeSpy.reset() - - atom.config.set("foo.bar.baz", 22, scopeSelector: ".source .string.quoted.double", source: "a") - expect(changeSpy).toHaveBeenCalledWith(22) - changeSpy.reset() - - atom.config.set("foo.bar.baz", 42, scopeSelector: ".source.coffee .string.quoted.double.coffee", source: "b") - expect(changeSpy).toHaveBeenCalledWith(42) - changeSpy.reset() - - atom.config.unset(null, scopeSelector: ".source.coffee .string.quoted.double.coffee", source: "b") - expect(changeSpy).toHaveBeenCalledWith(22) - changeSpy.reset() - - atom.config.unset(null, scopeSelector: ".source .string.quoted.double", source: "a") - expect(changeSpy).toHaveBeenCalledWith(12) - changeSpy.reset() - - atom.config.set("foo.bar.baz", undefined) - expect(changeSpy).toHaveBeenCalledWith(undefined) - changeSpy.reset() - - describe ".transact(callback)", -> - changeSpy = null - - beforeEach -> - changeSpy = jasmine.createSpy('onDidChange callback') - atom.config.onDidChange("foo.bar.baz", changeSpy) - - it "allows only one change event for the duration of the given callback", -> - atom.config.transact -> - atom.config.set("foo.bar.baz", 1) - atom.config.set("foo.bar.baz", 2) - atom.config.set("foo.bar.baz", 3) - - expect(changeSpy.callCount).toBe(1) - expect(changeSpy.argsForCall[0][0]).toEqual(newValue: 3, oldValue: undefined) - - it "does not emit an event if no changes occur while paused", -> - atom.config.transact -> - expect(changeSpy).not.toHaveBeenCalled() - - describe ".getSources()", -> - it "returns an array of all of the config's source names", -> - expect(atom.config.getSources()).toEqual([]) - - atom.config.set("a.b", 1, scopeSelector: ".x1", source: "source-1") - atom.config.set("a.c", 1, scopeSelector: ".x1", source: "source-1") - atom.config.set("a.b", 2, scopeSelector: ".x2", source: "source-2") - atom.config.set("a.b", 1, scopeSelector: ".x3", source: "source-3") - - expect(atom.config.getSources()).toEqual([ - "source-1" - "source-2" - "source-3" - ]) - - describe "Internal Methods", -> - describe ".save()", -> - CSON = require 'season' - - beforeEach -> - spyOn(CSON, 'writeFileSync') - jasmine.unspy atom.config, 'save' - - describe "when ~/.atom/config.json exists", -> - it "writes any non-default properties to ~/.atom/config.json", -> - atom.config.set("a.b.c", 1) - atom.config.set("a.b.d", 2) - atom.config.set("x.y.z", 3) - atom.config.setDefaults("a.b", e: 4, f: 5) - - CSON.writeFileSync.reset() - atom.config.save() - - expect(CSON.writeFileSync.argsForCall[0][0]).toBe atom.config.configFilePath - writtenConfig = CSON.writeFileSync.argsForCall[0][1] - expect(writtenConfig).toEqual '*': atom.config.settings - - describe "when ~/.atom/config.json doesn't exist", -> - it "writes any non-default properties to ~/.atom/config.cson", -> - atom.config.set("a.b.c", 1) - atom.config.set("a.b.d", 2) - atom.config.set("x.y.z", 3) - atom.config.setDefaults("a.b", e: 4, f: 5) - - CSON.writeFileSync.reset() - atom.config.save() - - expect(CSON.writeFileSync.argsForCall[0][0]).toBe path.join(atom.config.configDirPath, "atom.config.cson") - writtenConfig = CSON.writeFileSync.argsForCall[0][1] - expect(writtenConfig).toEqual '*': atom.config.settings - - describe "when scoped settings are defined", -> - it 'writes out explicitly set config settings', -> - atom.config.set('foo.bar', 'ruby', scopeSelector: '.source.ruby') - atom.config.set('foo.omg', 'wow', scopeSelector: '.source.ruby') - atom.config.set('foo.bar', 'coffee', scopeSelector: '.source.coffee') - - CSON.writeFileSync.reset() - atom.config.save() - - writtenConfig = CSON.writeFileSync.argsForCall[0][1] - expect(writtenConfig).toEqualJson - '*': - atom.config.settings - '.ruby.source': - foo: - bar: 'ruby' - omg: 'wow' - '.coffee.source': - foo: - bar: 'coffee' - - describe ".loadUserConfig()", -> - beforeEach -> - expect(fs.existsSync(atom.config.configDirPath)).toBeFalsy() - atom.config.setSchema 'foo', - type: 'object' - properties: - bar: - type: 'string' - default: 'def' - int: - type: 'integer' - default: 12 - - afterEach -> - fs.removeSync(dotNylasPath) - - describe "when the config file contains scoped settings", -> - beforeEach -> - fs.writeFileSync atom.config.configFilePath, """ - '*': - foo: - bar: 'baz' - - '.source.ruby': - foo: - bar: 'more-specific' - """ - atom.config.loadUserConfig() - - it "updates the config data based on the file contents", -> - expect(atom.config.get("foo.bar")).toBe 'baz' - expect(atom.config.get("foo.bar", scope: ['.source.ruby'])).toBe 'more-specific' - - describe "when the config file does not conform to the schema", -> - beforeEach -> - fs.writeFileSync atom.config.configFilePath, """ - '*': - foo: - bar: 'omg' - int: 'baz' - '.source.ruby': - foo: - bar: 'scoped' - int: 'nope' - """ - - it "validates and does not load the incorrect values", -> - atom.config.loadUserConfig() - expect(atom.config.get("foo.int")).toBe 12 - expect(atom.config.get("foo.bar")).toBe 'omg' - expect(atom.config.get("foo.int", scope: ['.source.ruby'])).toBe 12 - expect(atom.config.get("foo.bar", scope: ['.source.ruby'])).toBe 'scoped' - - describe "when the config file contains valid cson", -> - beforeEach -> - fs.writeFileSync(atom.config.configFilePath, "foo: bar: 'baz'") - - it "updates the config data based on the file contents", -> - atom.config.loadUserConfig() - expect(atom.config.get("foo.bar")).toBe 'baz' - - it "notifies observers for updated keypaths on load", -> - observeHandler = jasmine.createSpy("observeHandler") - observeSubscription = atom.config.observe "foo.bar", observeHandler - - atom.config.loadUserConfig() - - expect(observeHandler).toHaveBeenCalledWith 'baz' - - describe "when the config file contains invalid cson", -> - addErrorHandler = null - beforeEach -> - atom.notifications.onDidAddNotification addErrorHandler = jasmine.createSpy() - fs.writeFileSync(atom.config.configFilePath, "{{{{{") - - it "logs an error to the console and does not overwrite the config file on a subsequent save", -> - atom.config.loadUserConfig() - expect(addErrorHandler.callCount).toBe 1 - atom.config.set("hair", "blonde") # trigger a save - expect(atom.config.save).not.toHaveBeenCalled() - - describe "when the config file does not exist", -> - it "creates it with an empty object", -> - fs.makeTreeSync(atom.config.configDirPath) - atom.config.loadUserConfig() - expect(fs.existsSync(atom.config.configFilePath)).toBe true - expect(CSON.readFileSync(atom.config.configFilePath)).toEqual {} - - describe "when the config file contains values that do not adhere to the schema", -> - warnSpy = null - beforeEach -> - warnSpy = spyOn console, 'warn' - fs.writeFileSync atom.config.configFilePath, """ - foo: - bar: 'baz' - int: 'bad value' - """ - atom.config.loadUserConfig() - - it "updates the only the settings that have values matching the schema", -> - expect(atom.config.get("foo.bar")).toBe 'baz' - expect(atom.config.get("foo.int")).toBe 12 - - expect(warnSpy).toHaveBeenCalled() - expect(warnSpy.mostRecentCall.args[0]).toContain "foo.int" - - describe "when there is a pending save", -> - it "does not change the config settings", -> - fs.writeFileSync atom.config.configFilePath, "'*': foo: bar: 'baz'" - - atom.config.set("foo.bar", "quux") - atom.config.loadUserConfig() - expect(atom.config.get("foo.bar")).toBe "quux" - - advanceClock(100) - expect(atom.config.save.callCount).toBe 1 - - expect(atom.config.get("foo.bar")).toBe "quux" - atom.config.loadUserConfig() - expect(atom.config.get("foo.bar")).toBe "baz" - - - describe ".observeUserConfig()", -> - updatedHandler = null - - writeConfigFile = (data) -> - previousSetTimeoutCallCount = setTimeout.callCount - runs -> - fs.writeFileSync(atom.config.configFilePath, data) - waitsFor "debounced config file load", -> - setTimeout.callCount > previousSetTimeoutCallCount - runs -> - advanceClock(1000) - - beforeEach -> - atom.config.setSchema 'foo', - type: 'object' - properties: - bar: - type: 'string' - default: 'def' - baz: - type: 'string' - scoped: - type: 'boolean' - int: - type: 'integer' - default: 12 - - expect(fs.existsSync(atom.config.configDirPath)).toBeFalsy() - fs.writeFileSync atom.config.configFilePath, """ - '*': - foo: - bar: 'baz' - scoped: false - '.source.ruby': - foo: - scoped: true - """ - atom.config.loadUserConfig() - atom.config.observeUserConfig() - updatedHandler = jasmine.createSpy("updatedHandler") - atom.config.onDidChange updatedHandler - - afterEach -> - atom.config.unobserveUserConfig() - fs.removeSync(dotNylasPath) - - describe "when the config file changes to contain valid cson", -> - it "updates the config data", -> - writeConfigFile("foo: { bar: 'quux', baz: 'bar'}") - waitsFor 'update event', -> updatedHandler.callCount > 0 - runs -> - expect(atom.config.get('foo.bar')).toBe 'quux' - expect(atom.config.get('foo.baz')).toBe 'bar' - - it "does not fire a change event for paths that did not change", -> - atom.config.onDidChange 'foo.bar', noChangeSpy = jasmine.createSpy() - - writeConfigFile("foo: { bar: 'baz', baz: 'ok'}") - waitsFor 'update event', -> updatedHandler.callCount > 0 - - runs -> - expect(noChangeSpy).not.toHaveBeenCalled() - expect(atom.config.get('foo.bar')).toBe 'baz' - expect(atom.config.get('foo.baz')).toBe 'ok' - - describe 'when the default value is a complex value', -> - beforeEach -> - atom.config.setSchema 'foo.bar', - type: 'array' - items: - type: 'string' - - writeConfigFile("foo: { bar: ['baz', 'ok']}") - waitsFor 'update event', -> updatedHandler.callCount > 0 - runs -> updatedHandler.reset() - - it "does not fire a change event for paths that did not change", -> - noChangeSpy = jasmine.createSpy() - atom.config.onDidChange('foo.bar', noChangeSpy) - - writeConfigFile("foo: { bar: ['baz', 'ok'], baz: 'another'}") - waitsFor 'update event', -> updatedHandler.callCount > 0 - - runs -> - expect(noChangeSpy).not.toHaveBeenCalled() - expect(atom.config.get('foo.bar')).toEqual ['baz', 'ok'] - expect(atom.config.get('foo.baz')).toBe 'another' - - describe 'when scoped settings are used', -> - it "fires a change event for scoped settings that are removed", -> - scopedSpy = jasmine.createSpy() - atom.config.onDidChange('foo.scoped', scope: ['.source.ruby'], scopedSpy) - - writeConfigFile """ - '*': - foo: - scoped: false - """ - waitsFor 'update event', -> updatedHandler.callCount > 0 - - runs -> - expect(scopedSpy).toHaveBeenCalled() - expect(atom.config.get('foo.scoped', scope: ['.source.ruby'])).toBe false - - it "does not fire a change event for paths that did not change", -> - noChangeSpy = jasmine.createSpy() - atom.config.onDidChange('foo.scoped', scope: ['.source.ruby'], noChangeSpy) - - writeConfigFile """ - '*': - foo: - bar: 'baz' - '.source.ruby': - foo: - scoped: true - """ - waitsFor 'update event', -> updatedHandler.callCount > 0 - - runs -> - expect(noChangeSpy).not.toHaveBeenCalled() - expect(atom.config.get('foo.bar', scope: ['.source.ruby'])).toBe 'baz' - expect(atom.config.get('foo.scoped', scope: ['.source.ruby'])).toBe true - - describe "when the config file changes to omit a setting with a default", -> - it "resets the setting back to the default", -> - writeConfigFile("foo: { baz: 'new'}") - waitsFor 'update event', -> updatedHandler.callCount > 0 - runs -> - expect(atom.config.get('foo.bar')).toBe 'def' - expect(atom.config.get('foo.baz')).toBe 'new' - - describe "when the config file changes to be empty", -> - beforeEach -> - writeConfigFile("") - waitsFor 'update event', -> updatedHandler.callCount > 0 - - it "resets all settings back to the defaults", -> - expect(updatedHandler.callCount).toBe 1 - expect(atom.config.get('foo.bar')).toBe 'def' - atom.config.set("hair", "blonde") # trigger a save - advanceClock(500) - expect(atom.config.save).toHaveBeenCalled() - - describe "when the config file subsequently changes again to contain configuration", -> - beforeEach -> - updatedHandler.reset() - writeConfigFile("foo: bar: 'newVal'") - waitsFor 'update event', -> updatedHandler.callCount > 0 - - it "sets the setting to the value specified in the config file", -> - expect(atom.config.get('foo.bar')).toBe 'newVal' - - describe "when the config file changes to contain invalid cson", -> - addErrorHandler = null - beforeEach -> - atom.notifications.onDidAddNotification addErrorHandler = jasmine.createSpy() - writeConfigFile("}}}") - waitsFor "error to be logged", -> addErrorHandler.callCount > 0 - - it "logs a warning and does not update config data", -> - expect(updatedHandler.callCount).toBe 0 - expect(atom.config.get('foo.bar')).toBe 'baz' - atom.config.set("hair", "blonde") # trigger a save - expect(atom.config.save).not.toHaveBeenCalled() - - describe "when the config file subsequently changes again to contain valid cson", -> - beforeEach -> - writeConfigFile("foo: bar: 'newVal'") - waitsFor 'update event', -> updatedHandler.callCount > 0 - - it "updates the config data and resumes saving", -> - atom.config.set("hair", "blonde") - advanceClock(500) - expect(atom.config.save).toHaveBeenCalled() - - describe ".initializeConfigDirectory()", -> - beforeEach -> - if fs.existsSync(dotNylasPath) - fs.removeSync(dotNylasPath) - - atom.config.configDirPath = dotNylasPath - - afterEach -> - fs.removeSync(dotNylasPath) - - describe "when the configDirPath doesn't exist", -> - it "copies the contents of dot-nylas to ~/.nylas", -> - initializationDone = false - jasmine.unspy(window, "setTimeout") - atom.config.initializeConfigDirectory -> - initializationDone = true - - waitsFor -> initializationDone - - runs -> - expect(fs.existsSync(atom.config.configDirPath)).toBeTruthy() - expect(fs.existsSync(path.join(atom.config.configDirPath, 'packages'))).toBeTruthy() - expect(fs.isFileSync(path.join(atom.config.configDirPath, 'snippets.cson'))).toBeTruthy() - expect(fs.isFileSync(path.join(atom.config.configDirPath, 'config.cson'))).toBeTruthy() - expect(fs.isFileSync(path.join(atom.config.configDirPath, 'init.coffee'))).toBeTruthy() - expect(fs.isFileSync(path.join(atom.config.configDirPath, 'styles.less'))).toBeTruthy() - - describe ".pushAtKeyPath(keyPath, value)", -> - it "pushes the given value to the array at the key path and updates observers", -> - atom.config.set("foo.bar.baz", ["a"]) - observeHandler = jasmine.createSpy "observeHandler" - atom.config.observe "foo.bar.baz", observeHandler - observeHandler.reset() - - expect(atom.config.pushAtKeyPath("foo.bar.baz", "b")).toBe 2 - expect(atom.config.get("foo.bar.baz")).toEqual ["a", "b"] - expect(observeHandler).toHaveBeenCalledWith atom.config.get("foo.bar.baz") - - describe ".unshiftAtKeyPath(keyPath, value)", -> - it "unshifts the given value to the array at the key path and updates observers", -> - atom.config.set("foo.bar.baz", ["b"]) - observeHandler = jasmine.createSpy "observeHandler" - atom.config.observe "foo.bar.baz", observeHandler - observeHandler.reset() - - expect(atom.config.unshiftAtKeyPath("foo.bar.baz", "a")).toBe 2 - expect(atom.config.get("foo.bar.baz")).toEqual ["a", "b"] - expect(observeHandler).toHaveBeenCalledWith atom.config.get("foo.bar.baz") - - describe ".removeAtKeyPath(keyPath, value)", -> - it "removes the given value from the array at the key path and updates observers", -> - atom.config.set("foo.bar.baz", ["a", "b", "c"]) - observeHandler = jasmine.createSpy "observeHandler" - atom.config.observe "foo.bar.baz", observeHandler - observeHandler.reset() - - expect(atom.config.removeAtKeyPath("foo.bar.baz", "b")).toEqual ["a", "c"] - expect(atom.config.get("foo.bar.baz")).toEqual ["a", "c"] - expect(observeHandler).toHaveBeenCalledWith atom.config.get("foo.bar.baz") - - describe ".setDefaults(keyPath, defaults)", -> - it "assigns any previously-unassigned keys to the object at the key path", -> - atom.config.set("foo.bar.baz", a: 1) - atom.config.setDefaults("foo.bar.baz", a: 2, b: 3, c: 4) - expect(atom.config.get("foo.bar.baz.a")).toBe 1 - expect(atom.config.get("foo.bar.baz.b")).toBe 3 - expect(atom.config.get("foo.bar.baz.c")).toBe 4 - - atom.config.setDefaults("foo.quux", x: 0, y: 1) - expect(atom.config.get("foo.quux.x")).toBe 0 - expect(atom.config.get("foo.quux.y")).toBe 1 - - it "emits an updated event", -> - updatedCallback = jasmine.createSpy('updated') - atom.config.onDidChange('foo.bar.baz.a', updatedCallback) - expect(updatedCallback.callCount).toBe 0 - atom.config.setDefaults("foo.bar.baz", a: 2) - expect(updatedCallback.callCount).toBe 1 - - it "sets a default when the setting's key contains an escaped dot", -> - atom.config.setDefaults("foo", 'a\\.b': 1, b: 2) - expect(atom.config.get("foo")).toEqual 'a\\.b': 1, b: 2 - - describe ".setSchema(keyPath, schema)", -> - it 'creates a properly nested schema', -> - schema = - type: 'object' - properties: - anInt: - type: 'integer' - default: 12 - - atom.config.setSchema('foo.bar', schema) - - expect(atom.config.getSchema('foo')).toEqual - type: 'object' - properties: - bar: - type: 'object' - properties: - anInt: - type: 'integer' - default: 12 - - it 'sets defaults specified by the schema', -> - schema = - type: 'object' - properties: - anInt: - type: 'integer' - default: 12 - anObject: - type: 'object' - properties: - nestedInt: - type: 'integer' - default: 24 - nestedObject: - type: 'object' - properties: - superNestedInt: - type: 'integer' - default: 36 - - atom.config.setSchema('foo.bar', schema) - expect(atom.config.get("foo.bar.anInt")).toBe 12 - expect(atom.config.get("foo.bar.anObject")).toEqual - nestedInt: 24 - nestedObject: - superNestedInt: 36 - - it 'can set a non-object schema', -> - schema = - type: 'integer' - default: 12 - - atom.config.setSchema('foo.bar.anInt', schema) - expect(atom.config.get("foo.bar.anInt")).toBe 12 - expect(atom.config.getSchema('foo.bar.anInt')).toEqual - type: 'integer' - default: 12 - - it "allows the schema to be retrieved via ::getSchema", -> - schema = - type: 'object' - properties: - anInt: - type: 'integer' - default: 12 - - atom.config.setSchema('foo.bar', schema) - - expect(atom.config.getSchema('foo.bar')).toEqual - type: 'object' - properties: - anInt: - type: 'integer' - default: 12 - - expect(atom.config.getSchema('foo.bar.anInt')).toEqual - type: 'integer' - default: 12 - - expect(atom.config.getSchema('foo.baz')).toBeUndefined() - expect(atom.config.getSchema('foo.bar.anInt.baz')).toBeUndefined() - - it "respects the schema for scoped settings", -> - schema = - type: 'string' - default: 'ok' - scopes: - '.source.js': - default: 'omg' - atom.config.setSchema('foo.bar.str', schema) - - expect(atom.config.get('foo.bar.str')).toBe 'ok' - expect(atom.config.get('foo.bar.str', scope: ['.source.js'])).toBe 'omg' - expect(atom.config.get('foo.bar.str', scope: ['.source.coffee'])).toBe 'ok' - - describe 'when a schema is added after config values have been set', -> - schema = null - beforeEach -> - schema = - type: 'object' - properties: - int: - type: 'integer' - default: 2 - str: - type: 'string' - default: 'def' - - it "respects the new schema when values are set", -> - expect(atom.config.set('foo.bar.str', 'global')).toBe true - expect(atom.config.set('foo.bar.str', 'scoped', scopeSelector: '.source.js')).toBe true - expect(atom.config.get('foo.bar.str')).toBe 'global' - expect(atom.config.get('foo.bar.str', scope: ['.source.js'])).toBe 'scoped' - - expect(atom.config.set('foo.bar.noschema', 'nsGlobal')).toBe true - expect(atom.config.set('foo.bar.noschema', 'nsScoped', scopeSelector: '.source.js')).toBe true - expect(atom.config.get('foo.bar.noschema')).toBe 'nsGlobal' - expect(atom.config.get('foo.bar.noschema', scope: ['.source.js'])).toBe 'nsScoped' - - expect(atom.config.set('foo.bar.int', 'nope')).toBe true - expect(atom.config.set('foo.bar.int', 'notanint', scopeSelector: '.source.js')).toBe true - expect(atom.config.set('foo.bar.int', 23, scopeSelector: '.source.coffee')).toBe true - expect(atom.config.get('foo.bar.int')).toBe 'nope' - expect(atom.config.get('foo.bar.int', scope: ['.source.js'])).toBe 'notanint' - expect(atom.config.get('foo.bar.int', scope: ['.source.coffee'])).toBe 23 - - atom.config.setSchema('foo.bar', schema) - - expect(atom.config.get('foo.bar.str')).toBe 'global' - expect(atom.config.get('foo.bar.str', scope: ['.source.js'])).toBe 'scoped' - expect(atom.config.get('foo.bar.noschema')).toBe 'nsGlobal' - expect(atom.config.get('foo.bar.noschema', scope: ['.source.js'])).toBe 'nsScoped' - - expect(atom.config.get('foo.bar.int')).toBe 2 - expect(atom.config.get('foo.bar.int', scope: ['.source.js'])).toBe 2 - expect(atom.config.get('foo.bar.int', scope: ['.source.coffee'])).toBe 23 - - it "sets all values that adhere to the schema", -> - expect(atom.config.set('foo.bar.int', 10)).toBe true - expect(atom.config.set('foo.bar.int', 15, scopeSelector: '.source.js')).toBe true - expect(atom.config.set('foo.bar.int', 23, scopeSelector: '.source.coffee')).toBe true - expect(atom.config.get('foo.bar.int')).toBe 10 - expect(atom.config.get('foo.bar.int', scope: ['.source.js'])).toBe 15 - expect(atom.config.get('foo.bar.int', scope: ['.source.coffee'])).toBe 23 - - atom.config.setSchema('foo.bar', schema) - - expect(atom.config.get('foo.bar.int')).toBe 10 - expect(atom.config.get('foo.bar.int', scope: ['.source.js'])).toBe 15 - expect(atom.config.get('foo.bar.int', scope: ['.source.coffee'])).toBe 23 - - describe 'when the value has an "integer" type', -> - beforeEach -> - schema = - type: 'integer' - default: 12 - atom.config.setSchema('foo.bar.anInt', schema) - - it 'coerces a string to an int', -> - atom.config.set('foo.bar.anInt', '123') - expect(atom.config.get('foo.bar.anInt')).toBe 123 - - it 'does not allow infinity', -> - atom.config.set('foo.bar.anInt', Infinity) - expect(atom.config.get('foo.bar.anInt')).toBe 12 - - it 'coerces a float to an int', -> - atom.config.set('foo.bar.anInt', 12.3) - expect(atom.config.get('foo.bar.anInt')).toBe 12 - - it 'will not set non-integers', -> - atom.config.set('foo.bar.anInt', null) - expect(atom.config.get('foo.bar.anInt')).toBe 12 - - atom.config.set('foo.bar.anInt', 'nope') - expect(atom.config.get('foo.bar.anInt')).toBe 12 - - describe 'when the minimum and maximum keys are used', -> - beforeEach -> - schema = - type: 'integer' - minimum: 10 - maximum: 20 - default: 12 - atom.config.setSchema('foo.bar.anInt', schema) - - it 'keeps the specified value within the specified range', -> - atom.config.set('foo.bar.anInt', '123') - expect(atom.config.get('foo.bar.anInt')).toBe 20 - - atom.config.set('foo.bar.anInt', '1') - expect(atom.config.get('foo.bar.anInt')).toBe 10 - - describe 'when the value has an "integer" and "string" type', -> - beforeEach -> - schema = - type: ['integer', 'string'] - default: 12 - atom.config.setSchema('foo.bar.anInt', schema) - - it 'can coerce an int, and fallback to a string', -> - atom.config.set('foo.bar.anInt', '123') - expect(atom.config.get('foo.bar.anInt')).toBe 123 - - atom.config.set('foo.bar.anInt', 'cats') - expect(atom.config.get('foo.bar.anInt')).toBe 'cats' - - describe 'when the value has an "string" and "boolean" type', -> - beforeEach -> - schema = - type: ['string', 'boolean'] - default: 'def' - atom.config.setSchema('foo.bar', schema) - - it 'can set a string, a boolean, and revert back to the default', -> - atom.config.set('foo.bar', 'ok') - expect(atom.config.get('foo.bar')).toBe 'ok' - - atom.config.set('foo.bar', false) - expect(atom.config.get('foo.bar')).toBe false - - atom.config.set('foo.bar', undefined) - expect(atom.config.get('foo.bar')).toBe 'def' - - describe 'when the value has a "number" type', -> - beforeEach -> - schema = - type: 'number' - default: 12.1 - atom.config.setSchema('foo.bar.aFloat', schema) - - it 'coerces a string to a float', -> - atom.config.set('foo.bar.aFloat', '12.23') - expect(atom.config.get('foo.bar.aFloat')).toBe 12.23 - - it 'will not set non-numbers', -> - atom.config.set('foo.bar.aFloat', null) - expect(atom.config.get('foo.bar.aFloat')).toBe 12.1 - - atom.config.set('foo.bar.aFloat', 'nope') - expect(atom.config.get('foo.bar.aFloat')).toBe 12.1 - - describe 'when the minimum and maximum keys are used', -> - beforeEach -> - schema = - type: 'number' - minimum: 11.2 - maximum: 25.4 - default: 12.1 - atom.config.setSchema('foo.bar.aFloat', schema) - - it 'keeps the specified value within the specified range', -> - atom.config.set('foo.bar.aFloat', '123.2') - expect(atom.config.get('foo.bar.aFloat')).toBe 25.4 - - atom.config.set('foo.bar.aFloat', '1.0') - expect(atom.config.get('foo.bar.aFloat')).toBe 11.2 - - describe 'when the value has a "boolean" type', -> - beforeEach -> - schema = - type: 'boolean' - default: true - atom.config.setSchema('foo.bar.aBool', schema) - - it 'coerces various types to a boolean', -> - atom.config.set('foo.bar.aBool', 'true') - expect(atom.config.get('foo.bar.aBool')).toBe true - atom.config.set('foo.bar.aBool', 'false') - expect(atom.config.get('foo.bar.aBool')).toBe false - atom.config.set('foo.bar.aBool', 'TRUE') - expect(atom.config.get('foo.bar.aBool')).toBe true - atom.config.set('foo.bar.aBool', 'FALSE') - expect(atom.config.get('foo.bar.aBool')).toBe false - atom.config.set('foo.bar.aBool', 1) - expect(atom.config.get('foo.bar.aBool')).toBe false - atom.config.set('foo.bar.aBool', 0) - expect(atom.config.get('foo.bar.aBool')).toBe false - atom.config.set('foo.bar.aBool', {}) - expect(atom.config.get('foo.bar.aBool')).toBe false - atom.config.set('foo.bar.aBool', null) - expect(atom.config.get('foo.bar.aBool')).toBe false - - it 'reverts back to the default value when undefined is passed to set', -> - atom.config.set('foo.bar.aBool', 'false') - expect(atom.config.get('foo.bar.aBool')).toBe false - - atom.config.set('foo.bar.aBool', undefined) - expect(atom.config.get('foo.bar.aBool')).toBe true - - describe 'when the value has an "string" type', -> - beforeEach -> - schema = - type: 'string' - default: 'ok' - atom.config.setSchema('foo.bar.aString', schema) - - it 'allows strings', -> - atom.config.set('foo.bar.aString', 'yep') - expect(atom.config.get('foo.bar.aString')).toBe 'yep' - - it 'will only set strings', -> - expect(atom.config.set('foo.bar.aString', 123)).toBe false - expect(atom.config.get('foo.bar.aString')).toBe 'ok' - - expect(atom.config.set('foo.bar.aString', true)).toBe false - expect(atom.config.get('foo.bar.aString')).toBe 'ok' - - expect(atom.config.set('foo.bar.aString', null)).toBe false - expect(atom.config.get('foo.bar.aString')).toBe 'ok' - - expect(atom.config.set('foo.bar.aString', [])).toBe false - expect(atom.config.get('foo.bar.aString')).toBe 'ok' - - expect(atom.config.set('foo.bar.aString', nope: 'nope')).toBe false - expect(atom.config.get('foo.bar.aString')).toBe 'ok' - - describe 'when the value has an "object" type', -> - beforeEach -> - schema = - type: 'object' - properties: - anInt: - type: 'integer' - default: 12 - nestedObject: - type: 'object' - properties: - nestedBool: - type: 'boolean' - default: false - atom.config.setSchema('foo.bar', schema) - - it 'converts and validates all the children', -> - atom.config.set 'foo.bar', - anInt: '23' - nestedObject: - nestedBool: 'true' - expect(atom.config.get('foo.bar')).toEqual - anInt: 23 - nestedObject: - nestedBool: true - - it 'will set only the values that adhere to the schema', -> - expect(atom.config.set 'foo.bar', - anInt: 'nope' - nestedObject: - nestedBool: true - ).toBe true - expect(atom.config.get('foo.bar.anInt')).toEqual 12 - expect(atom.config.get('foo.bar.nestedObject.nestedBool')).toEqual true - - describe 'when the value has an "array" type', -> - beforeEach -> - schema = - type: 'array' - default: [1, 2, 3] - items: - type: 'integer' - atom.config.setSchema('foo.bar', schema) - - it 'converts an array of strings to an array of ints', -> - atom.config.set 'foo.bar', ['2', '3', '4'] - expect(atom.config.get('foo.bar')).toEqual [2, 3, 4] - - describe 'when the value has a "color" type', -> - beforeEach -> - schema = - type: 'color' - default: 'white' - atom.config.setSchema('foo.bar.aColor', schema) - - it 'returns a Color object', -> - color = atom.config.get('foo.bar.aColor') - expect(color.toHexString()).toBe '#ffffff' - expect(color.toRGBAString()).toBe 'rgba(255, 255, 255, 1)' - - color.red = 0 - color.green = 0 - color.blue = 0 - color.alpha = 0 - atom.config.set('foo.bar.aColor', color) - - color = atom.config.get('foo.bar.aColor') - expect(color.toHexString()).toBe '#000000' - expect(color.toRGBAString()).toBe 'rgba(0, 0, 0, 0)' - - color.red = 300 - color.green = -200 - color.blue = -1 - color.alpha = 'not see through' - atom.config.set('foo.bar.aColor', color) - - color = atom.config.get('foo.bar.aColor') - expect(color.toHexString()).toBe '#ff0000' - expect(color.toRGBAString()).toBe 'rgba(255, 0, 0, 1)' - - it 'coerces various types to a color object', -> - atom.config.set('foo.bar.aColor', 'red') - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 255, green: 0, blue: 0, alpha: 1} - atom.config.set('foo.bar.aColor', '#020') - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 0, green: 34, blue: 0, alpha: 1} - atom.config.set('foo.bar.aColor', '#abcdef') - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 171, green: 205, blue: 239, alpha: 1} - atom.config.set('foo.bar.aColor', 'rgb(1,2,3)') - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 1, green: 2, blue: 3, alpha: 1} - atom.config.set('foo.bar.aColor', 'rgba(4,5,6,.7)') - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 4, green: 5, blue: 6, alpha: .7} - atom.config.set('foo.bar.aColor', 'hsl(120,100%,50%)') - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 0, green: 255, blue: 0, alpha: 1} - atom.config.set('foo.bar.aColor', 'hsla(120,100%,50%,0.3)') - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 0, green: 255, blue: 0, alpha: .3} - atom.config.set('foo.bar.aColor', {red: 100, green: 255, blue: 2, alpha: .5}) - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 100, green: 255, blue: 2, alpha: .5} - atom.config.set('foo.bar.aColor', {red: 255}) - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 255, green: 0, blue: 0, alpha: 1} - atom.config.set('foo.bar.aColor', {red: 1000}) - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 255, green: 0, blue: 0, alpha: 1} - atom.config.set('foo.bar.aColor', {red: 'dark'}) - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 0, green: 0, blue: 0, alpha: 1} - - it 'reverts back to the default value when undefined is passed to set', -> - atom.config.set('foo.bar.aColor', undefined) - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 255, green: 255, blue: 255, alpha: 1} - - it 'will not set non-colors', -> - atom.config.set('foo.bar.aColor', null) - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 255, green: 255, blue: 255, alpha: 1} - - atom.config.set('foo.bar.aColor', 'nope') - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 255, green: 255, blue: 255, alpha: 1} - - atom.config.set('foo.bar.aColor', 30) - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 255, green: 255, blue: 255, alpha: 1} - - atom.config.set('foo.bar.aColor', false) - expect(atom.config.get('foo.bar.aColor')).toEqual {red: 255, green: 255, blue: 255, alpha: 1} - - it "returns a clone of the Color when returned in a parent object", -> - color1 = atom.config.get('foo.bar').aColor - color2 = atom.config.get('foo.bar').aColor - expect(color1.toRGBAString()).toBe 'rgba(255, 255, 255, 1)' - expect(color2.toRGBAString()).toBe 'rgba(255, 255, 255, 1)' - expect(color1).not.toBe color2 - expect(color1).toEqual color2 - - describe 'when the `enum` key is used', -> - beforeEach -> - schema = - type: 'object' - properties: - str: - type: 'string' - default: 'ok' - enum: ['ok', 'one', 'two'] - int: - type: 'integer' - default: 2 - enum: [2, 3, 5] - arr: - type: 'array' - default: ['one', 'two'] - items: - type: 'string' - enum: ['one', 'two', 'three'] - - atom.config.setSchema('foo.bar', schema) - - it 'will only set a string when the string is in the enum values', -> - expect(atom.config.set('foo.bar.str', 'nope')).toBe false - expect(atom.config.get('foo.bar.str')).toBe 'ok' - - expect(atom.config.set('foo.bar.str', 'one')).toBe true - expect(atom.config.get('foo.bar.str')).toBe 'one' - - it 'will only set an integer when the integer is in the enum values', -> - expect(atom.config.set('foo.bar.int', '400')).toBe false - expect(atom.config.get('foo.bar.int')).toBe 2 - - expect(atom.config.set('foo.bar.int', '3')).toBe true - expect(atom.config.get('foo.bar.int')).toBe 3 - - it 'will only set an array when the array values are in the enum values', -> - expect(atom.config.set('foo.bar.arr', ['one', 'five'])).toBe true - expect(atom.config.get('foo.bar.arr')).toEqual ['one'] - - expect(atom.config.set('foo.bar.arr', ['two', 'three'])).toBe true - expect(atom.config.get('foo.bar.arr')).toEqual ['two', 'three'] - - describe "Deprecated Methods", -> - describe ".getDefault(keyPath)", -> - it "returns a clone of the default value", -> - atom.config.setDefaults("foo", same: 1, changes: 1) - - spyOn(Grim, 'deprecate') - expect(atom.config.getDefault('foo.same')).toBe 1 - expect(atom.config.getDefault('foo.changes')).toBe 1 - expect(Grim.deprecate.callCount).toBe 2 - - atom.config.set('foo.same', 2) - atom.config.set('foo.changes', 3) - - expect(atom.config.getDefault('foo.same')).toBe 1 - expect(atom.config.getDefault('foo.changes')).toBe 1 - expect(Grim.deprecate.callCount).toBe 4 - - initialDefaultValue = [1, 2, 3] - atom.config.setDefaults("foo", bar: initialDefaultValue) - expect(atom.config.getDefault('foo.bar')).toEqual initialDefaultValue - expect(atom.config.getDefault('foo.bar')).not.toBe initialDefaultValue - expect(Grim.deprecate.callCount).toBe 6 - - describe "when scoped settings are used", -> - it "returns the global default when no scoped default set", -> - atom.config.setDefaults("foo", bar: baz: 10) - - spyOn(Grim, 'deprecate') - expect(atom.config.getDefault('.source.coffee', 'foo.bar.baz')).toBe 10 - expect(Grim.deprecate).toHaveBeenCalled() - - it "returns the scoped settings not including the user's config file", -> - atom.config.setDefaults("foo", bar: baz: 10) - atom.config.set("foo.bar.baz", 42, scopeSelector: ".source.coffee", source: "some-source") - - spyOn(Grim, 'deprecate') - expect(atom.config.getDefault('.source.coffee', 'foo.bar.baz')).toBe 42 - expect(Grim.deprecate.callCount).toBe 1 - - atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee') - expect(atom.config.getDefault('.source.coffee', 'foo.bar.baz')).toBe 42 - expect(Grim.deprecate.callCount).toBe 2 - - describe ".isDefault(keyPath)", -> - it "returns true when the value of the key path is its default value", -> - atom.config.setDefaults("foo", same: 1, changes: 1) - - spyOn(Grim, 'deprecate') - expect(atom.config.isDefault('foo.same')).toBe true - expect(atom.config.isDefault('foo.changes')).toBe true - expect(Grim.deprecate.callCount).toBe 2 - - atom.config.set('foo.same', 2) - atom.config.set('foo.changes', 3) - - expect(atom.config.isDefault('foo.same')).toBe false - expect(atom.config.isDefault('foo.changes')).toBe false - expect(Grim.deprecate.callCount).toBe 4 - - describe "when scoped settings are used", -> - it "returns false when a scoped setting was set by the user", -> - spyOn(Grim, 'deprecate') - expect(atom.config.isDefault('.source.coffee', 'foo.bar.baz')).toBe true - expect(Grim.deprecate.callCount).toBe 1 - - atom.config.set("foo.bar.baz", 42, scopeSelector: ".source.coffee", source: "something-else") - expect(atom.config.isDefault('.source.coffee', 'foo.bar.baz')).toBe true - expect(Grim.deprecate.callCount).toBe 2 - - atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee') - expect(atom.config.isDefault('.source.coffee', 'foo.bar.baz')).toBe false - expect(Grim.deprecate.callCount).toBe 3 - - describe ".toggle(keyPath)", -> - beforeEach -> - jasmine.snapshotDeprecations() - - afterEach -> - jasmine.restoreDeprecationsSnapshot() - - it "negates the boolean value of the current key path value", -> - atom.config.set('foo.a', 1) - atom.config.toggle('foo.a') - expect(atom.config.get('foo.a')).toBe false - - atom.config.set('foo.a', '') - atom.config.toggle('foo.a') - expect(atom.config.get('foo.a')).toBe true - - atom.config.set('foo.a', null) - atom.config.toggle('foo.a') - expect(atom.config.get('foo.a')).toBe true - - atom.config.set('foo.a', true) - atom.config.toggle('foo.a') - expect(atom.config.get('foo.a')).toBe false - - describe ".getSettings()", -> - it "returns all settings including defaults", -> - atom.config.setDefaults("foo", bar: baz: 10) - atom.config.set("foo.ok", 12) - - jasmine.snapshotDeprecations() - expect(atom.config.getSettings().foo).toEqual - ok: 12 - bar: - baz: 10 - jasmine.restoreDeprecationsSnapshot() - - describe ".getPositiveInt(keyPath, defaultValue)", -> - beforeEach -> - jasmine.snapshotDeprecations() - - afterEach -> - jasmine.restoreDeprecationsSnapshot() - - it "returns the proper coerced value", -> - atom.config.set('editor.preferredLineLength', 0) - expect(atom.config.getPositiveInt('editor.preferredLineLength', 80)).toBe 1 - - it "returns the proper coerced value", -> - atom.config.set('editor.preferredLineLength', -1234) - expect(atom.config.getPositiveInt('editor.preferredLineLength', 80)).toBe 1 - - it "returns the default value when a string is passed in", -> - atom.config.set('editor.preferredLineLength', 'abcd') - expect(atom.config.getPositiveInt('editor.preferredLineLength', 80)).toBe 80 - - it "returns the default value when null is passed in", -> - atom.config.set('editor.preferredLineLength', null) - expect(atom.config.getPositiveInt('editor.preferredLineLength', 80)).toBe 80 diff --git a/spec/context-menu-manager-spec.coffee b/spec/context-menu-manager-spec.coffee deleted file mode 100644 index 1c3c1f21a..000000000 --- a/spec/context-menu-manager-spec.coffee +++ /dev/null @@ -1,181 +0,0 @@ -{$$} = require '../src/space-pen-extensions' - -ContextMenuManager = require '../src/context-menu-manager' - -describe "ContextMenuManager", -> - [contextMenu, parent, child, grandchild] = [] - - beforeEach -> - {resourcePath} = atom.getLoadSettings() - contextMenu = new ContextMenuManager({resourcePath}) - - parent = document.createElement("div") - child = document.createElement("div") - grandchild = document.createElement("div") - parent.classList.add('parent') - child.classList.add('child') - grandchild.classList.add('grandchild') - child.appendChild(grandchild) - parent.appendChild(child) - - describe "::add(itemsBySelector)", -> - it "can add top-level menu items that can be removed with the returned disposable", -> - disposable = contextMenu.add - '.parent': [{label: 'A', command: 'a'}] - '.child': [{label: 'B', command: 'b'}] - '.grandchild': [{label: 'C', command: 'c'}] - - expect(contextMenu.templateForElement(grandchild)).toEqual [ - {label: 'C', command: 'c'} - {label: 'B', command: 'b'} - {label: 'A', command: 'a'} - ] - - disposable.dispose() - expect(contextMenu.templateForElement(grandchild)).toEqual [] - - it "can add submenu items to existing menus that can be removed with the returned disposable", -> - disposable1 = contextMenu.add - '.grandchild': [{label: 'A', submenu: [{label: 'B', command: 'b'}]}] - disposable2 = contextMenu.add - '.grandchild': [{label: 'A', submenu: [{label: 'C', command: 'c'}]}] - - expect(contextMenu.templateForElement(grandchild)).toEqual [{ - label: 'A', - submenu: [ - {label: 'B', command: 'b'} - {label: 'C', command: 'c'} - ] - }] - - disposable2.dispose() - expect(contextMenu.templateForElement(grandchild)).toEqual [{ - label: 'A', - submenu: [ - {label: 'B', command: 'b'} - ] - }] - - disposable1.dispose() - expect(contextMenu.templateForElement(grandchild)).toEqual [] - - it "favors the most specific / recently added item in the case of a duplicate label", -> - grandchild.classList.add('foo') - - disposable1 = contextMenu.add - '.grandchild': [{label: 'A', command: 'a'}] - disposable2 = contextMenu.add - '.grandchild.foo': [{label: 'A', command: 'b'}] - disposable3 = contextMenu.add - '.grandchild': [{label: 'A', command: 'c'}] - disposable4 = contextMenu.add - '.child': [{label: 'A', command: 'd'}] - - expect(contextMenu.templateForElement(grandchild)).toEqual [{label: 'A', command: 'b'}] - - disposable2.dispose() - expect(contextMenu.templateForElement(grandchild)).toEqual [{label: 'A', command: 'c'}] - - disposable3.dispose() - expect(contextMenu.templateForElement(grandchild)).toEqual [{label: 'A', command: 'a'}] - - disposable1.dispose() - expect(contextMenu.templateForElement(grandchild)).toEqual [{label: 'A', command: 'd'}] - - it "allows multiple separators, but not adjacent to each other", -> - contextMenu.add - '.grandchild': [ - {label: 'A', command: 'a'}, - {type: 'separator'}, - {type: 'separator'}, - {label: 'B', command: 'b'}, - {type: 'separator'}, - {type: 'separator'}, - {label: 'C', command: 'c'} - ] - - expect(contextMenu.templateForElement(grandchild)).toEqual [ - {label: 'A', command: 'a'}, - {type: 'separator'}, - {label: 'B', command: 'b'}, - {type: 'separator'}, - {label: 'C', command: 'c'} - ] - - it "excludes items marked for display in devMode unless in dev mode", -> - disposable1 = contextMenu.add - '.grandchild': [{label: 'A', command: 'a', devMode: true}, {label: 'B', command: 'b', devMode: false}] - - expect(contextMenu.templateForElement(grandchild)).toEqual [{label: 'B', command: 'b'}] - - contextMenu.devMode = true - expect(contextMenu.templateForElement(grandchild)).toEqual [{label: 'A', command: 'a'}, {label: 'B', command: 'b'}] - - it "allows items to be associated with `created` hooks which are invoked on template construction with the item and event", -> - createdEvent = null - - item = { - label: 'A', - command: 'a', - created: (event) -> - @command = 'b' - createdEvent = event - } - - contextMenu.add('.grandchild': [item]) - - dispatchedEvent = {target: grandchild} - expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual [{label: 'A', command: 'b'}] - expect(item.command).toBe 'a' # doesn't modify original item template - expect(createdEvent).toBe dispatchedEvent - - it "allows items to be associated with `shouldDisplay` hooks which are invoked on construction to determine whether the item should be included", -> - shouldDisplayEvent = null - shouldDisplay = true - - item = { - label: 'A', - command: 'a', - shouldDisplay: (event) -> - @foo = 'bar' - shouldDisplayEvent = event - shouldDisplay - } - contextMenu.add('.grandchild': [item]) - - dispatchedEvent = {target: grandchild} - expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual [{label: 'A', command: 'a'}] - expect(item.foo).toBeUndefined() # doesn't modify original item template - expect(shouldDisplayEvent).toBe dispatchedEvent - - shouldDisplay = false - expect(contextMenu.templateForEvent(dispatchedEvent)).toEqual [] - - describe "when the menus are specified in a legacy format", -> - beforeEach -> - jasmine.snapshotDeprecations() - - afterEach -> - jasmine.restoreDeprecationsSnapshot() - - it "allows items to be specified in the legacy format for now", -> - contextMenu.add '.parent': - 'A': 'a' - 'Separator 1': '-' - 'B': - 'C': 'c' - 'Separator 2': '-' - 'D': 'd' - - expect(contextMenu.templateForElement(parent)).toEqual [ - {label: 'A', command: 'a'} - {type: 'separator'} - { - label: 'B' - submenu: [ - {label: 'C', command: 'c'} - {type: 'separator'} - {label: 'D', command: 'd'} - ] - } - ] diff --git a/spec-nylas/database-object-registry-spec.coffee b/spec/database-object-registry-spec.coffee similarity index 100% rename from spec-nylas/database-object-registry-spec.coffee rename to spec/database-object-registry-spec.coffee diff --git a/spec-nylas/database-view-spec.coffee b/spec/database-view-spec.coffee similarity index 100% rename from spec-nylas/database-view-spec.coffee rename to spec/database-view-spec.coffee diff --git a/spec-nylas/dom-utils-spec.coffee b/spec/dom-utils-spec.coffee similarity index 100% rename from spec-nylas/dom-utils-spec.coffee rename to spec/dom-utils-spec.coffee diff --git a/spec/fixtures/6to5/double-quotes.js b/spec/fixtures/6to5/double-quotes.js deleted file mode 100644 index 254912bc0..000000000 --- a/spec/fixtures/6to5/double-quotes.js +++ /dev/null @@ -1,3 +0,0 @@ -"use 6to5"; - -module.exports = v => v + 1 diff --git a/spec/fixtures/6to5/invalid.js b/spec/fixtures/6to5/invalid.js deleted file mode 100644 index 4af6a59e2..000000000 --- a/spec/fixtures/6to5/invalid.js +++ /dev/null @@ -1,3 +0,0 @@ -'use 6to6'; - -module.exports = v => v + 1 diff --git a/spec/fixtures/6to5/single-quotes.js b/spec/fixtures/6to5/single-quotes.js deleted file mode 100644 index 16e382ec2..000000000 --- a/spec/fixtures/6to5/single-quotes.js +++ /dev/null @@ -1,3 +0,0 @@ -'use 6to5'; - -module.exports = v => v + 1 diff --git a/spec/fixtures/coffee.coffee b/spec/fixtures/coffee.coffee deleted file mode 100644 index 81c78703f..000000000 --- a/spec/fixtures/coffee.coffee +++ /dev/null @@ -1,23 +0,0 @@ -class Quicksort - sort: (items) -> - return items if items.length <= 1 - - pivot = items.shift() - left = [] - right = [] - - # Comment in the middle - - while items.length > 0 - current = items.shift() - if current < pivot - left.push(current) - else - right.push(current); - - sort(left).concat(pivot).concat(sort(right)) - - noop: -> - # just a noop - -exports.modules = Quicksort diff --git a/spec-nylas/fixtures/db-test-model.coffee b/spec/fixtures/db-test-model.coffee similarity index 100% rename from spec-nylas/fixtures/db-test-model.coffee rename to spec/fixtures/db-test-model.coffee diff --git a/spec/fixtures/dir/a b/spec/fixtures/dir/a deleted file mode 100644 index 95c5424ba..000000000 --- a/spec/fixtures/dir/a +++ /dev/null @@ -1,3 +0,0 @@ -aaa bbb -cc aa cc -dollar$bill \ No newline at end of file diff --git a/spec/fixtures/dir/a-dir/oh-git b/spec/fixtures/dir/a-dir/oh-git deleted file mode 100644 index 64998f776..000000000 --- a/spec/fixtures/dir/a-dir/oh-git +++ /dev/null @@ -1 +0,0 @@ -bbb aaaa \ No newline at end of file diff --git a/spec/fixtures/dir/b b/spec/fixtures/dir/b deleted file mode 100644 index f2c4fd35c..000000000 --- a/spec/fixtures/dir/b +++ /dev/null @@ -1 +0,0 @@ -aaa ccc diff --git a/spec/fixtures/dir/file1 b/spec/fixtures/dir/file1 deleted file mode 100644 index e69de29bb..000000000 diff --git a/spec-nylas/fixtures/emails/correct_sig.txt b/spec/fixtures/emails/correct_sig.txt similarity index 100% rename from spec-nylas/fixtures/emails/correct_sig.txt rename to spec/fixtures/emails/correct_sig.txt diff --git a/spec-nylas/fixtures/emails/email_1.html b/spec/fixtures/emails/email_1.html similarity index 100% rename from spec-nylas/fixtures/emails/email_1.html rename to spec/fixtures/emails/email_1.html diff --git a/spec-nylas/fixtures/emails/email_10.html b/spec/fixtures/emails/email_10.html similarity index 100% rename from spec-nylas/fixtures/emails/email_10.html rename to spec/fixtures/emails/email_10.html diff --git a/spec-nylas/fixtures/emails/email_10_stripped.html b/spec/fixtures/emails/email_10_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_10_stripped.html rename to spec/fixtures/emails/email_10_stripped.html diff --git a/spec-nylas/fixtures/emails/email_11.html b/spec/fixtures/emails/email_11.html similarity index 100% rename from spec-nylas/fixtures/emails/email_11.html rename to spec/fixtures/emails/email_11.html diff --git a/spec-nylas/fixtures/emails/email_11_stripped.html b/spec/fixtures/emails/email_11_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_11_stripped.html rename to spec/fixtures/emails/email_11_stripped.html diff --git a/spec-nylas/fixtures/emails/email_12.html b/spec/fixtures/emails/email_12.html similarity index 100% rename from spec-nylas/fixtures/emails/email_12.html rename to spec/fixtures/emails/email_12.html diff --git a/spec-nylas/fixtures/emails/email_12_stripped.html b/spec/fixtures/emails/email_12_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_12_stripped.html rename to spec/fixtures/emails/email_12_stripped.html diff --git a/spec-nylas/fixtures/emails/email_13.html b/spec/fixtures/emails/email_13.html similarity index 100% rename from spec-nylas/fixtures/emails/email_13.html rename to spec/fixtures/emails/email_13.html diff --git a/spec-nylas/fixtures/emails/email_13_stripped.html b/spec/fixtures/emails/email_13_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_13_stripped.html rename to spec/fixtures/emails/email_13_stripped.html diff --git a/spec-nylas/fixtures/emails/email_14.html b/spec/fixtures/emails/email_14.html similarity index 100% rename from spec-nylas/fixtures/emails/email_14.html rename to spec/fixtures/emails/email_14.html diff --git a/spec-nylas/fixtures/emails/email_14_stripped.html b/spec/fixtures/emails/email_14_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_14_stripped.html rename to spec/fixtures/emails/email_14_stripped.html diff --git a/spec-nylas/fixtures/emails/email_15.html b/spec/fixtures/emails/email_15.html similarity index 100% rename from spec-nylas/fixtures/emails/email_15.html rename to spec/fixtures/emails/email_15.html diff --git a/spec-nylas/fixtures/emails/email_15_stripped.html b/spec/fixtures/emails/email_15_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_15_stripped.html rename to spec/fixtures/emails/email_15_stripped.html diff --git a/spec-nylas/fixtures/emails/email_16.html b/spec/fixtures/emails/email_16.html similarity index 100% rename from spec-nylas/fixtures/emails/email_16.html rename to spec/fixtures/emails/email_16.html diff --git a/spec-nylas/fixtures/emails/email_16_stripped.html b/spec/fixtures/emails/email_16_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_16_stripped.html rename to spec/fixtures/emails/email_16_stripped.html diff --git a/spec-nylas/fixtures/emails/email_1_1.txt b/spec/fixtures/emails/email_1_1.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_1_1.txt rename to spec/fixtures/emails/email_1_1.txt diff --git a/spec-nylas/fixtures/emails/email_1_2.txt b/spec/fixtures/emails/email_1_2.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_1_2.txt rename to spec/fixtures/emails/email_1_2.txt diff --git a/spec-nylas/fixtures/emails/email_1_3.txt b/spec/fixtures/emails/email_1_3.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_1_3.txt rename to spec/fixtures/emails/email_1_3.txt diff --git a/spec-nylas/fixtures/emails/email_1_4.txt b/spec/fixtures/emails/email_1_4.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_1_4.txt rename to spec/fixtures/emails/email_1_4.txt diff --git a/spec-nylas/fixtures/emails/email_1_5.txt b/spec/fixtures/emails/email_1_5.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_1_5.txt rename to spec/fixtures/emails/email_1_5.txt diff --git a/spec-nylas/fixtures/emails/email_1_6.txt b/spec/fixtures/emails/email_1_6.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_1_6.txt rename to spec/fixtures/emails/email_1_6.txt diff --git a/spec-nylas/fixtures/emails/email_1_7.txt b/spec/fixtures/emails/email_1_7.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_1_7.txt rename to spec/fixtures/emails/email_1_7.txt diff --git a/spec-nylas/fixtures/emails/email_1_8.txt b/spec/fixtures/emails/email_1_8.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_1_8.txt rename to spec/fixtures/emails/email_1_8.txt diff --git a/spec-nylas/fixtures/emails/email_1_stripped.html b/spec/fixtures/emails/email_1_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_1_stripped.html rename to spec/fixtures/emails/email_1_stripped.html diff --git a/spec-nylas/fixtures/emails/email_2.html b/spec/fixtures/emails/email_2.html similarity index 100% rename from spec-nylas/fixtures/emails/email_2.html rename to spec/fixtures/emails/email_2.html diff --git a/spec-nylas/fixtures/emails/email_2_1.txt b/spec/fixtures/emails/email_2_1.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_2_1.txt rename to spec/fixtures/emails/email_2_1.txt diff --git a/spec-nylas/fixtures/emails/email_2_stripped.html b/spec/fixtures/emails/email_2_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_2_stripped.html rename to spec/fixtures/emails/email_2_stripped.html diff --git a/spec-nylas/fixtures/emails/email_3.html b/spec/fixtures/emails/email_3.html similarity index 100% rename from spec-nylas/fixtures/emails/email_3.html rename to spec/fixtures/emails/email_3.html diff --git a/spec-nylas/fixtures/emails/email_3_stripped.html b/spec/fixtures/emails/email_3_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_3_stripped.html rename to spec/fixtures/emails/email_3_stripped.html diff --git a/spec-nylas/fixtures/emails/email_4.html b/spec/fixtures/emails/email_4.html similarity index 100% rename from spec-nylas/fixtures/emails/email_4.html rename to spec/fixtures/emails/email_4.html diff --git a/spec-nylas/fixtures/emails/email_4_stripped.html b/spec/fixtures/emails/email_4_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_4_stripped.html rename to spec/fixtures/emails/email_4_stripped.html diff --git a/spec-nylas/fixtures/emails/email_5.html b/spec/fixtures/emails/email_5.html similarity index 100% rename from spec-nylas/fixtures/emails/email_5.html rename to spec/fixtures/emails/email_5.html diff --git a/spec-nylas/fixtures/emails/email_5_stripped.html b/spec/fixtures/emails/email_5_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_5_stripped.html rename to spec/fixtures/emails/email_5_stripped.html diff --git a/spec-nylas/fixtures/emails/email_6.html b/spec/fixtures/emails/email_6.html similarity index 100% rename from spec-nylas/fixtures/emails/email_6.html rename to spec/fixtures/emails/email_6.html diff --git a/spec-nylas/fixtures/emails/email_6_stripped.html b/spec/fixtures/emails/email_6_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_6_stripped.html rename to spec/fixtures/emails/email_6_stripped.html diff --git a/spec-nylas/fixtures/emails/email_7.html b/spec/fixtures/emails/email_7.html similarity index 100% rename from spec-nylas/fixtures/emails/email_7.html rename to spec/fixtures/emails/email_7.html diff --git a/spec-nylas/fixtures/emails/email_7_stripped.html b/spec/fixtures/emails/email_7_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_7_stripped.html rename to spec/fixtures/emails/email_7_stripped.html diff --git a/spec-nylas/fixtures/emails/email_8.html b/spec/fixtures/emails/email_8.html similarity index 100% rename from spec-nylas/fixtures/emails/email_8.html rename to spec/fixtures/emails/email_8.html diff --git a/spec-nylas/fixtures/emails/email_8_stripped.html b/spec/fixtures/emails/email_8_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_8_stripped.html rename to spec/fixtures/emails/email_8_stripped.html diff --git a/spec-nylas/fixtures/emails/email_9.html b/spec/fixtures/emails/email_9.html similarity index 100% rename from spec-nylas/fixtures/emails/email_9.html rename to spec/fixtures/emails/email_9.html diff --git a/spec-nylas/fixtures/emails/email_9_stripped.html b/spec/fixtures/emails/email_9_stripped.html similarity index 100% rename from spec-nylas/fixtures/emails/email_9_stripped.html rename to spec/fixtures/emails/email_9_stripped.html diff --git a/spec-nylas/fixtures/emails/email_BlackBerry.txt b/spec/fixtures/emails/email_BlackBerry.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_BlackBerry.txt rename to spec/fixtures/emails/email_BlackBerry.txt diff --git a/spec-nylas/fixtures/emails/email_bullets.txt b/spec/fixtures/emails/email_bullets.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_bullets.txt rename to spec/fixtures/emails/email_bullets.txt diff --git a/spec-nylas/fixtures/emails/email_iPhone.txt b/spec/fixtures/emails/email_iPhone.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_iPhone.txt rename to spec/fixtures/emails/email_iPhone.txt diff --git a/spec-nylas/fixtures/emails/email_multi_word_sent_from_my_mobile_device.txt b/spec/fixtures/emails/email_multi_word_sent_from_my_mobile_device.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_multi_word_sent_from_my_mobile_device.txt rename to spec/fixtures/emails/email_multi_word_sent_from_my_mobile_device.txt diff --git a/spec-nylas/fixtures/emails/email_sent_from_my_not_signature.txt b/spec/fixtures/emails/email_sent_from_my_not_signature.txt similarity index 100% rename from spec-nylas/fixtures/emails/email_sent_from_my_not_signature.txt rename to spec/fixtures/emails/email_sent_from_my_not_signature.txt diff --git a/spec/fixtures/git/ignore.git/HEAD b/spec/fixtures/git/ignore.git/HEAD deleted file mode 100644 index cb089cd89..000000000 --- a/spec/fixtures/git/ignore.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/spec/fixtures/git/ignore.git/config b/spec/fixtures/git/ignore.git/config deleted file mode 100644 index af107929f..000000000 --- a/spec/fixtures/git/ignore.git/config +++ /dev/null @@ -1,6 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true diff --git a/spec/fixtures/git/ignore.git/index b/spec/fixtures/git/ignore.git/index deleted file mode 100644 index bf35b18cd334b5611b86f4a8dc91bf08542daf34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 137 zcmZ?q402{*U|<4b#(>UEnLwHWMl&)nurS0#rZX@!E&)n^1xks46HxQkR4~MWxT#H|svHx?@GG&8yum a%eN^dzV?cL@sl}bFS|j92$yAM$22rPLQ6n?I4({XK>N diff --git a/spec/fixtures/git/ignore.git/refs/heads/master b/spec/fixtures/git/ignore.git/refs/heads/master deleted file mode 100644 index 6134b5707..000000000 --- a/spec/fixtures/git/ignore.git/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -ef046e9eecaa5255ea5e9817132d4001724d6ae1 diff --git a/spec/fixtures/git/master.git/HEAD b/spec/fixtures/git/master.git/HEAD deleted file mode 100644 index cb089cd89..000000000 --- a/spec/fixtures/git/master.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/spec/fixtures/git/master.git/config b/spec/fixtures/git/master.git/config deleted file mode 100644 index af107929f..000000000 --- a/spec/fixtures/git/master.git/config +++ /dev/null @@ -1,6 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true diff --git a/spec/fixtures/git/master.git/index b/spec/fixtures/git/master.git/index deleted file mode 100644 index bf35b18cd334b5611b86f4a8dc91bf08542daf34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 137 zcmZ?q402{*U|<4b#(>UEnLwHWMl&)nurS0#rZX@!E&)n^1xks46HxQkR4~MWxT#H|svHx?@GG&8yum a%eN^dzV?cL@sl}bFS|j92$yAM$22rPLQ6n?I4({XK>N diff --git a/spec/fixtures/git/master.git/refs/heads/master b/spec/fixtures/git/master.git/refs/heads/master deleted file mode 100644 index 6134b5707..000000000 --- a/spec/fixtures/git/master.git/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -ef046e9eecaa5255ea5e9817132d4001724d6ae1 diff --git a/spec/fixtures/git/working-dir/.gitignore b/spec/fixtures/git/working-dir/.gitignore deleted file mode 100644 index 23238eafc..000000000 --- a/spec/fixtures/git/working-dir/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -poop -ignored.txt diff --git a/spec/fixtures/git/working-dir/a.txt b/spec/fixtures/git/working-dir/a.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/spec/fixtures/git/working-dir/git.git/HEAD b/spec/fixtures/git/working-dir/git.git/HEAD deleted file mode 100644 index cb089cd89..000000000 --- a/spec/fixtures/git/working-dir/git.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/spec/fixtures/git/working-dir/git.git/config b/spec/fixtures/git/working-dir/git.git/config deleted file mode 100644 index af107929f..000000000 --- a/spec/fixtures/git/working-dir/git.git/config +++ /dev/null @@ -1,6 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true diff --git a/spec/fixtures/git/working-dir/git.git/index b/spec/fixtures/git/working-dir/git.git/index deleted file mode 100644 index e49f052cdef53c909897e7b1237f67226b99a7d2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 334 zcmZ?q402{*U|<4bmf(*6F+iFDMl%A%*i6}V85kOuFfcHF1xks4ClsTL!nML|ZV6$+TqmO0|XWE?!fwxj+ zL~r&oR&}H{C7;^V&&0rymYI_ZaT3fwFdFI}b2M{!{-03nzNEs%vr|8xDWuo6!bQVm xHUnpVNk(cB*r1RgS686F*cfyT6%4p8T(3{4Te)%G?c*uGx5!xBU`7Fk>(@FfcPQQApG)sVHH1Huur&O&6~@dv|NDE04Ny=t)oT zM5uza%$!uPnzTC;0&k_th~DgFtm;T@Nt<8 diff --git a/spec/fixtures/git/working-dir/git.git/objects/16/735fb793d7b038818219c4b8c6295346e20eef b/spec/fixtures/git/working-dir/git.git/objects/16/735fb793d7b038818219c4b8c6295346e20eef deleted file mode 100644 index e5d8eb93c4c43d673464725fc8b80cf50c4dc69b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 164 zcmV;V09*ff0iBLX4#F@D06FIs{s72!9nwk&!I>j3a1s|HC`BbK&j-X0IL;hKlg42v z6}SnrI+=lwEE**>Q8o9z5f+Z5DKTSedqq#Ni;V87lU*uUkFvDREU9|--qc&yQlN&j zAW~q-OEq$Oug7tMojuA0_WCU8RA6=b;_XM9!=UB7NaL^u5+rFu7YODU5Z%XqKCAs- SaNC@rFK1iSS9Ndbqf9dYl}cd% diff --git a/spec/fixtures/git/working-dir/git.git/objects/52/f56457b6fca045ce41bb9d32e6ca79d23192af b/spec/fixtures/git/working-dir/git.git/objects/52/f56457b6fca045ce41bb9d32e6ca79d23192af deleted file mode 100644 index 03280f17f92921347ea184b70380df75453ad75b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 166 zcmV;X09pTd0iBLZ4#FT509|v6cLAHn9};79?a~tfeOOXyO~udgt?>pfXBLx5bFHO; zkZ#i!B0$4+_CaZHT$Gw?!XQv+iIjadJj5VOG>P59LQ?~7tkgMLFMAtNI>(*hKB?%E z5nfAWNFY&W;n9Y9ffGH;1n2N7X)LfCzj*)A;Zj4nc4@AA;0n2N);kGXw1{lA>u00? U3+&kUFt>r0uDu)k00NXtOU?sL6aWAK diff --git a/spec/fixtures/git/working-dir/git.git/objects/5b/24ab4c3baadf534242b1acc220c8fa051b9b20 b/spec/fixtures/git/working-dir/git.git/objects/5b/24ab4c3baadf534242b1acc220c8fa051b9b20 deleted file mode 100644 index 27cfeb8f2846ab6a1d28fdd3e1b8e2a234116992..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 79 zcmV-V0I>gf0V^p=O;s?nWH2-^Ff%bxNYpE-C}DUu_tET47q2;ccWbUIkGgT_Nl)-Z lsDiZ2oK&!yv^x_5Z>7qJ-t1+p>PT%$KDDWz2>^*!A66C=BJThI diff --git a/spec/fixtures/git/working-dir/git.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 b/spec/fixtures/git/working-dir/git.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 deleted file mode 100644 index ba1f06fc0e5703e15be021b473eb64a7063688ae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 50 zcmb2rPLQ6n?I4({XK>N diff --git a/spec/fixtures/git/working-dir/git.git/objects/fe/bde178cdf35e9df6279d87aa27590c6d92e354 b/spec/fixtures/git/working-dir/git.git/objects/fe/bde178cdf35e9df6279d87aa27590c6d92e354 deleted file mode 100644 index fde11bec75ae110653087629728e5bf93d6dd5d8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 139 zcmV;60CfL&0V^p=O;s>7He)a}FfcPQQApG)sVHH1Huur&O&6~@dv|NDE04Ny=t)oT zL=yubP)NxvVt5m0k;(dB*X+?mjw~VePZ3e8Iu)SW(=u~X!6u~LnGkp@RYvq?FJo0l tYE$y5P5n$zHTfkOsYPH#|4%4(UsB=X*{Pq;6w>Qj;i6$O8vwe9Hp`8$JzxL; diff --git a/spec/fixtures/git/working-dir/git.git/objects/ff/c8218bd2240a0cb92f6f02548d45784428349b b/spec/fixtures/git/working-dir/git.git/objects/ff/c8218bd2240a0cb92f6f02548d45784428349b deleted file mode 100644 index 919f08db877f221f674ad2aacbdf956e3f40a6af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28 kcmb 0) { - current = items.shift(); - current < pivot ? left.push(current) : right.push(current); - } - return sort(left).concat(pivot).concat(sort(right)); - }; - // this is a single-line comment - return sort(Array.apply(this, arguments)); -}; \ No newline at end of file diff --git a/spec/fixtures/sample-with-tabs-and-initial-comment.js b/spec/fixtures/sample-with-tabs-and-initial-comment.js deleted file mode 100644 index 996d4dff0..000000000 --- a/spec/fixtures/sample-with-tabs-and-initial-comment.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Look, this is a comment. Don't go making assumtions that I want soft tabs - * because this block comment has leading spaces, Geez. - */ - -if (beNice) { - console.log('Thank you for being nice.'); -} diff --git a/spec/fixtures/sample.js b/spec/fixtures/sample.js deleted file mode 100644 index fb33b0b43..000000000 --- a/spec/fixtures/sample.js +++ /dev/null @@ -1,13 +0,0 @@ -var quicksort = function () { - var sort = function(items) { - if (items.length <= 1) return items; - var pivot = items.shift(), current, left = [], right = []; - while(items.length > 0) { - current = items.shift(); - current < pivot ? left.push(current) : right.push(current); - } - return sort(left).concat(pivot).concat(sort(right)); - }; - - return sort(Array.apply(this, arguments)); -}; \ No newline at end of file diff --git a/spec/fixtures/sample.txt b/spec/fixtures/sample.txt deleted file mode 100644 index 3e715502b..000000000 --- a/spec/fixtures/sample.txt +++ /dev/null @@ -1 +0,0 @@ -Some text. diff --git a/spec/fixtures/shebang b/spec/fixtures/shebang deleted file mode 100644 index f15429b13..000000000 --- a/spec/fixtures/shebang +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/ruby - -puts "America – fuck yeah!" \ No newline at end of file diff --git a/spec-nylas/fixtures/task-spec-handler.coffee b/spec/fixtures/task-spec-handler.coffee similarity index 100% rename from spec-nylas/fixtures/task-spec-handler.coffee rename to spec/fixtures/task-spec-handler.coffee diff --git a/spec/fixtures/two-hundred.txt b/spec/fixtures/two-hundred.txt deleted file mode 100644 index 9001290d1..000000000 --- a/spec/fixtures/two-hundred.txt +++ /dev/null @@ -1,200 +0,0 @@ -0 -1 -2 -3 -4---------------------------------------------------------------------------------------------------- -5 -6 -7 -8 -9---------------------------------------------------------------------------------------------------- -10 -11 -12 -13 -14---------------------------------------------------------------------------------------------------- -15 -16 -17 -18 -19---------------------------------------------------------------------------------------------------- -20 -21 -22 -23 -24---------------------------------------------------------------------------------------------------- -25 -26 -27 -28 -29---------------------------------------------------------------------------------------------------- -30 -31 -32 -33 -34---------------------------------------------------------------------------------------------------- -35 -36 -37 -38 -39---------------------------------------------------------------------------------------------------- -40 -41 -42 -43 -44---------------------------------------------------------------------------------------------------- -45 -46 -47 -48 -49---------------------------------------------------------------------------------------------------- -50 -51 -52 -53 -54---------------------------------------------------------------------------------------------------- -55 -56 -57 -58 -59---------------------------------------------------------------------------------------------------- -60 -61 -62 -63 -64---------------------------------------------------------------------------------------------------- -65 -66 -67 -68 -69---------------------------------------------------------------------------------------------------- -70 -71 -72 -73 -74---------------------------------------------------------------------------------------------------- -75 -76 -77 -78 -79---------------------------------------------------------------------------------------------------- -80 -81 -82 -83 -84---------------------------------------------------------------------------------------------------- -85 -86 -87 -88 -89---------------------------------------------------------------------------------------------------- -90 -91 -92 -93 -94---------------------------------------------------------------------------------------------------- -95 -96 -97 -98 -99---------------------------------------------------------------------------------------------------- -100 -101 -102 -103 -104---------------------------------------------------------------------------------------------------- -105 -106 -107 -108 -109---------------------------------------------------------------------------------------------------- -110 -111 -112 -113 -114---------------------------------------------------------------------------------------------------- -115 -116 -117 -118 -119---------------------------------------------------------------------------------------------------- -120 -121 -122 -123 -124---------------------------------------------------------------------------------------------------- -125 -126 -127 -128 -129---------------------------------------------------------------------------------------------------- -130 -131 -132 -133 -134---------------------------------------------------------------------------------------------------- -135 -136 -137 -138 -139---------------------------------------------------------------------------------------------------- -140 -141 -142 -143 -144---------------------------------------------------------------------------------------------------- -145 -146 -147 -148 -149---------------------------------------------------------------------------------------------------- -150 -151 -152 -153 -154---------------------------------------------------------------------------------------------------- -155 -156 -157 -158 -159---------------------------------------------------------------------------------------------------- -160 -161 -162 -163 -164---------------------------------------------------------------------------------------------------- -165 -166 -167 -168 -169---------------------------------------------------------------------------------------------------- -170 -171 -172 -173 -174---------------------------------------------------------------------------------------------------- -175 -176 -177 -178 -179---------------------------------------------------------------------------------------------------- -180 -181 -182 -183 -184---------------------------------------------------------------------------------------------------- -185 -186 -187 -188 -189---------------------------------------------------------------------------------------------------- -190 -191 -192 -193 -194---------------------------------------------------------------------------------------------------- -195 -196 -197 -198 -199---------------------------------------------------------------------------------------------------- diff --git a/spec/language-mode-spec.coffee b/spec/language-mode-spec.coffee deleted file mode 100644 index 68e6daaef..000000000 --- a/spec/language-mode-spec.coffee +++ /dev/null @@ -1,491 +0,0 @@ -describe "LanguageMode", -> - [editor, buffer, languageMode] = [] - - afterEach -> - editor.destroy() - - describe "javascript", -> - beforeEach -> - waitsForPromise -> - atom.workspace.open('sample.js', autoIndent: false).then (o) -> - editor = o - {buffer, languageMode} = editor - - waitsForPromise -> - atom.packages.activatePackage('language-javascript') - - afterEach -> - atom.packages.deactivatePackages() - atom.packages.unloadPackages() - - describe ".minIndentLevelForRowRange(startRow, endRow)", -> - it "returns the minimum indent level for the given row range", -> - expect(languageMode.minIndentLevelForRowRange(4, 7)).toBe 2 - expect(languageMode.minIndentLevelForRowRange(5, 7)).toBe 2 - expect(languageMode.minIndentLevelForRowRange(5, 6)).toBe 3 - expect(languageMode.minIndentLevelForRowRange(9, 11)).toBe 1 - expect(languageMode.minIndentLevelForRowRange(10, 10)).toBe 0 - - describe ".toggleLineCommentsForBufferRows(start, end)", -> - it "comments/uncomments lines in the given range", -> - languageMode.toggleLineCommentsForBufferRows(4, 7) - expect(buffer.lineForRow(4)).toBe " // while(items.length > 0) {" - expect(buffer.lineForRow(5)).toBe " // current = items.shift();" - expect(buffer.lineForRow(6)).toBe " // current < pivot ? left.push(current) : right.push(current);" - expect(buffer.lineForRow(7)).toBe " // }" - - languageMode.toggleLineCommentsForBufferRows(4, 5) - expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {" - expect(buffer.lineForRow(5)).toBe " current = items.shift();" - expect(buffer.lineForRow(6)).toBe " // current < pivot ? left.push(current) : right.push(current);" - expect(buffer.lineForRow(7)).toBe " // }" - - buffer.setText('\tvar i;') - languageMode.toggleLineCommentsForBufferRows(0, 0) - expect(buffer.lineForRow(0)).toBe "\t// var i;" - - buffer.setText('var i;') - languageMode.toggleLineCommentsForBufferRows(0, 0) - expect(buffer.lineForRow(0)).toBe "// var i;" - - buffer.setText(' var i;') - languageMode.toggleLineCommentsForBufferRows(0, 0) - expect(buffer.lineForRow(0)).toBe " // var i;" - - buffer.setText(' ') - languageMode.toggleLineCommentsForBufferRows(0, 0) - expect(buffer.lineForRow(0)).toBe " // " - - buffer.setText(' a\n \n b') - languageMode.toggleLineCommentsForBufferRows(0, 2) - expect(buffer.lineForRow(0)).toBe " // a" - expect(buffer.lineForRow(1)).toBe " // " - expect(buffer.lineForRow(2)).toBe " // b" - - buffer.setText(' \n // var i;') - languageMode.toggleLineCommentsForBufferRows(0, 1) - expect(buffer.lineForRow(0)).toBe ' ' - expect(buffer.lineForRow(1)).toBe ' var i;' - - describe ".rowRangeForCodeFoldAtBufferRow(bufferRow)", -> - it "returns the start/end rows of the foldable region starting at the given row", -> - expect(languageMode.rowRangeForCodeFoldAtBufferRow(0)).toEqual [0, 12] - expect(languageMode.rowRangeForCodeFoldAtBufferRow(1)).toEqual [1, 9] - expect(languageMode.rowRangeForCodeFoldAtBufferRow(2)).toBeNull() - expect(languageMode.rowRangeForCodeFoldAtBufferRow(4)).toEqual [4, 7] - - describe ".rowRangeForCommentAtBufferRow(bufferRow)", -> - it "returns the start/end rows of the foldable comment starting at the given row", -> - buffer.setText("//this is a multi line comment\n//another line") - expect(languageMode.rowRangeForCommentAtBufferRow(0)).toEqual [0, 1] - expect(languageMode.rowRangeForCommentAtBufferRow(1)).toEqual [0, 1] - - buffer.setText("//this is a multi line comment\n//another line\n//and one more") - expect(languageMode.rowRangeForCommentAtBufferRow(0)).toEqual [0, 2] - expect(languageMode.rowRangeForCommentAtBufferRow(1)).toEqual [0, 2] - - buffer.setText("//this is a multi line comment\n\n//with an empty line") - expect(languageMode.rowRangeForCommentAtBufferRow(0)).toBeUndefined() - expect(languageMode.rowRangeForCommentAtBufferRow(1)).toBeUndefined() - expect(languageMode.rowRangeForCommentAtBufferRow(2)).toBeUndefined() - - buffer.setText("//this is a single line comment\n") - expect(languageMode.rowRangeForCommentAtBufferRow(0)).toBeUndefined() - expect(languageMode.rowRangeForCommentAtBufferRow(1)).toBeUndefined() - - buffer.setText("//this is a single line comment") - expect(languageMode.rowRangeForCommentAtBufferRow(0)).toBeUndefined() - - describe ".suggestedIndentForBufferRow", -> - it "bases indentation off of the previous non-blank line", -> - expect(languageMode.suggestedIndentForBufferRow(0)).toBe 0 - expect(languageMode.suggestedIndentForBufferRow(1)).toBe 1 - expect(languageMode.suggestedIndentForBufferRow(2)).toBe 2 - expect(languageMode.suggestedIndentForBufferRow(9)).toBe 1 - expect(languageMode.suggestedIndentForBufferRow(11)).toBe 1 - - describe "rowRangeForParagraphAtBufferRow", -> - describe "with code and comments", -> - beforeEach -> - buffer.setText ''' - var quicksort = function () { - /* Single line comment block */ - var sort = function(items) {}; - - /* - A multiline - comment is here - */ - var sort = function(items) {}; - - // A comment - // - // Multiple comment - // lines - var sort = function(items) {}; - // comment line after fn - }; - ''' - - it "will limit paragraph range to comments", -> - range = languageMode.rowRangeForParagraphAtBufferRow(0) - expect(range).toEqual [[0,0], [0,29]] - - range = languageMode.rowRangeForParagraphAtBufferRow(10) - expect(range).toEqual [[10,0], [10,14]] - range = languageMode.rowRangeForParagraphAtBufferRow(11) - expect(range).toBeFalsy() - range = languageMode.rowRangeForParagraphAtBufferRow(12) - expect(range).toEqual [[12,0], [13,10]] - - range = languageMode.rowRangeForParagraphAtBufferRow(14) - expect(range).toEqual [[14,0], [14,32]] - - range = languageMode.rowRangeForParagraphAtBufferRow(15) - expect(range).toEqual [[15,0], [15,26]] - - describe "coffeescript", -> - beforeEach -> - waitsForPromise -> - atom.workspace.open('coffee.coffee', autoIndent: false).then (o) -> - editor = o - {buffer, languageMode} = editor - - waitsForPromise -> - atom.packages.activatePackage('language-coffee-script') - - afterEach -> - atom.packages.deactivatePackages() - atom.packages.unloadPackages() - - describe ".toggleLineCommentsForBufferRows(start, end)", -> - it "comments/uncomments lines in the given range", -> - languageMode.toggleLineCommentsForBufferRows(4, 6) - expect(buffer.lineForRow(4)).toBe " # pivot = items.shift()" - expect(buffer.lineForRow(5)).toBe " # left = []" - expect(buffer.lineForRow(6)).toBe " # right = []" - - languageMode.toggleLineCommentsForBufferRows(4, 5) - expect(buffer.lineForRow(4)).toBe " pivot = items.shift()" - expect(buffer.lineForRow(5)).toBe " left = []" - expect(buffer.lineForRow(6)).toBe " # right = []" - - it "comments/uncomments lines when empty line", -> - languageMode.toggleLineCommentsForBufferRows(4, 7) - expect(buffer.lineForRow(4)).toBe " # pivot = items.shift()" - expect(buffer.lineForRow(5)).toBe " # left = []" - expect(buffer.lineForRow(6)).toBe " # right = []" - expect(buffer.lineForRow(7)).toBe " # " - - languageMode.toggleLineCommentsForBufferRows(4, 5) - expect(buffer.lineForRow(4)).toBe " pivot = items.shift()" - expect(buffer.lineForRow(5)).toBe " left = []" - expect(buffer.lineForRow(6)).toBe " # right = []" - expect(buffer.lineForRow(7)).toBe " # " - - describe "fold suggestion", -> - describe ".isFoldableAtBufferRow(bufferRow)", -> - it "returns true only when the buffer row starts a foldable region", -> - expect(languageMode.isFoldableAtBufferRow(0)).toBeTruthy() - expect(languageMode.isFoldableAtBufferRow(1)).toBeTruthy() - expect(languageMode.isFoldableAtBufferRow(2)).toBeFalsy() - expect(languageMode.isFoldableAtBufferRow(3)).toBeFalsy() - expect(languageMode.isFoldableAtBufferRow(19)).toBeTruthy() - - describe ".rowRangeForCodeFoldAtBufferRow(bufferRow)", -> - it "returns the start/end rows of the foldable region starting at the given row", -> - expect(languageMode.rowRangeForCodeFoldAtBufferRow(0)).toEqual [0, 20] - expect(languageMode.rowRangeForCodeFoldAtBufferRow(1)).toEqual [1, 17] - expect(languageMode.rowRangeForCodeFoldAtBufferRow(2)).toBeNull() - expect(languageMode.rowRangeForCodeFoldAtBufferRow(19)).toEqual [19, 20] - - describe "css", -> - beforeEach -> - waitsForPromise -> - atom.workspace.open('css.css', autoIndent: false).then (o) -> - editor = o - {buffer, languageMode} = editor - - waitsForPromise -> - atom.packages.activatePackage('language-css') - - afterEach -> - atom.packages.deactivatePackages() - atom.packages.unloadPackages() - - describe ".toggleLineCommentsForBufferRows(start, end)", -> - it "comments/uncomments lines in the given range", -> - languageMode.toggleLineCommentsForBufferRows(0, 1) - expect(buffer.lineForRow(0)).toBe "/*body {" - expect(buffer.lineForRow(1)).toBe " font-size: 1234px;*/" - expect(buffer.lineForRow(2)).toBe " width: 110%;" - expect(buffer.lineForRow(3)).toBe " font-weight: bold !important;" - - languageMode.toggleLineCommentsForBufferRows(2, 2) - expect(buffer.lineForRow(0)).toBe "/*body {" - expect(buffer.lineForRow(1)).toBe " font-size: 1234px;*/" - expect(buffer.lineForRow(2)).toBe " /*width: 110%;*/" - expect(buffer.lineForRow(3)).toBe " font-weight: bold !important;" - - languageMode.toggleLineCommentsForBufferRows(0, 1) - expect(buffer.lineForRow(0)).toBe "body {" - expect(buffer.lineForRow(1)).toBe " font-size: 1234px;" - expect(buffer.lineForRow(2)).toBe " /*width: 110%;*/" - expect(buffer.lineForRow(3)).toBe " font-weight: bold !important;" - - it "uncomments lines with leading whitespace", -> - buffer.setTextInRange([[2, 0], [2, Infinity]], " /*width: 110%;*/") - languageMode.toggleLineCommentsForBufferRows(2, 2) - expect(buffer.lineForRow(2)).toBe " width: 110%;" - - it "uncomments lines with trailing whitespace", -> - buffer.setTextInRange([[2, 0], [2, Infinity]], "/*width: 110%;*/ ") - languageMode.toggleLineCommentsForBufferRows(2, 2) - expect(buffer.lineForRow(2)).toBe "width: 110%; " - - it "uncomments lines with leading and trailing whitespace", -> - buffer.setTextInRange([[2, 0], [2, Infinity]], " /*width: 110%;*/ ") - languageMode.toggleLineCommentsForBufferRows(2, 2) - expect(buffer.lineForRow(2)).toBe " width: 110%; " - - describe "less", -> - beforeEach -> - waitsForPromise -> - atom.workspace.open('sample.less', autoIndent: false).then (o) -> - editor = o - {buffer, languageMode} = editor - - waitsForPromise -> - atom.packages.activatePackage('language-less') - - waitsForPromise -> - atom.packages.activatePackage('language-css') - - afterEach -> - atom.packages.deactivatePackages() - atom.packages.unloadPackages() - - describe "when commenting lines", -> - it "only uses the `commentEnd` pattern if it comes from the same grammar as the `commentStart`", -> - languageMode.toggleLineCommentsForBufferRows(0, 0) - expect(buffer.lineForRow(0)).toBe "// @color: #4D926F;" - - describe "xml", -> - beforeEach -> - waitsForPromise -> - atom.workspace.open('sample.xml', autoIndent: false).then (o) -> - editor = o - editor.setText("") - {buffer, languageMode} = editor - - waitsForPromise -> - atom.packages.activatePackage('language-xml') - - afterEach -> - atom.packages.deactivatePackages() - atom.packages.unloadPackages() - - describe "when uncommenting lines", -> - it "removes the leading whitespace from the comment end pattern match", -> - languageMode.toggleLineCommentsForBufferRows(0, 0) - expect(buffer.lineForRow(0)).toBe "test" - - describe "folding", -> - beforeEach -> - waitsForPromise -> - atom.workspace.open('sample.js', autoIndent: false).then (o) -> - editor = o - {buffer, languageMode} = editor - - waitsForPromise -> - atom.packages.activatePackage('language-javascript') - - afterEach -> - atom.packages.deactivatePackages() - atom.packages.unloadPackages() - - it "maintains cursor buffer position when a folding/unfolding", -> - editor.setCursorBufferPosition([5,5]) - languageMode.foldAll() - expect(editor.getCursorBufferPosition()).toEqual([5,5]) - - describe ".unfoldAll()", -> - it "unfolds every folded line", -> - initialScreenLineCount = editor.getScreenLineCount() - languageMode.foldBufferRow(0) - languageMode.foldBufferRow(1) - expect(editor.getScreenLineCount()).toBeLessThan initialScreenLineCount - languageMode.unfoldAll() - expect(editor.getScreenLineCount()).toBe initialScreenLineCount - - describe ".foldAll()", -> - it "folds every foldable line", -> - languageMode.foldAll() - - fold1 = editor.tokenizedLineForScreenRow(0).fold - expect([fold1.getStartRow(), fold1.getEndRow()]).toEqual [0, 12] - fold1.destroy() - - fold2 = editor.tokenizedLineForScreenRow(1).fold - expect([fold2.getStartRow(), fold2.getEndRow()]).toEqual [1, 9] - fold2.destroy() - - fold3 = editor.tokenizedLineForScreenRow(4).fold - expect([fold3.getStartRow(), fold3.getEndRow()]).toEqual [4, 7] - - describe ".foldBufferRow(bufferRow)", -> - describe "when bufferRow can be folded", -> - it "creates a fold based on the syntactic region starting at the given row", -> - languageMode.foldBufferRow(1) - fold = editor.tokenizedLineForScreenRow(1).fold - expect(fold.getStartRow()).toBe 1 - expect(fold.getEndRow()).toBe 9 - - describe "when bufferRow can't be folded", -> - it "searches upward for the first row that begins a syntatic region containing the given buffer row (and folds it)", -> - languageMode.foldBufferRow(8) - fold = editor.tokenizedLineForScreenRow(1).fold - expect(fold.getStartRow()).toBe 1 - expect(fold.getEndRow()).toBe 9 - - describe "when the bufferRow is already folded", -> - it "searches upward for the first row that begins a syntatic region containing the folded row (and folds it)", -> - languageMode.foldBufferRow(2) - expect(editor.tokenizedLineForScreenRow(1).fold).toBeDefined() - expect(editor.tokenizedLineForScreenRow(0).fold).not.toBeDefined() - - languageMode.foldBufferRow(1) - expect(editor.tokenizedLineForScreenRow(0).fold).toBeDefined() - - describe "when the bufferRow is in a multi-line comment", -> - it "searches upward and downward for surrounding comment lines and folds them as a single fold", -> - buffer.insert([1,0], " //this is a comment\n // and\n //more docs\n\n//second comment") - languageMode.foldBufferRow(1) - fold = editor.tokenizedLineForScreenRow(1).fold - expect(fold.getStartRow()).toBe 1 - expect(fold.getEndRow()).toBe 3 - - describe "when the bufferRow is a single-line comment", -> - it "searches upward for the first row that begins a syntatic region containing the folded row (and folds it)", -> - buffer.insert([1,0], " //this is a single line comment\n") - languageMode.foldBufferRow(1) - fold = editor.tokenizedLineForScreenRow(0).fold - expect(fold.getStartRow()).toBe 0 - expect(fold.getEndRow()).toBe 13 - - describe ".isFoldableAtBufferRow(bufferRow)", -> - it "returns true if the line starts a foldable row range", -> - expect(languageMode.isFoldableAtBufferRow(0)).toBe true - expect(languageMode.isFoldableAtBufferRow(1)).toBe true - expect(languageMode.isFoldableAtBufferRow(2)).toBe false - expect(languageMode.isFoldableAtBufferRow(3)).toBe false - expect(languageMode.isFoldableAtBufferRow(4)).toBe true - - describe ".foldAllAtIndentLevel(indentLevel)", -> - it "folds blocks of text at the given indentation level", -> - languageMode.foldAllAtIndentLevel(0) - expect(editor.lineTextForScreenRow(0)).toBe "var quicksort = function () {" - expect(editor.getLastScreenRow()).toBe 0 - - languageMode.foldAllAtIndentLevel(1) - expect(editor.lineTextForScreenRow(0)).toBe "var quicksort = function () {" - expect(editor.lineTextForScreenRow(1)).toBe " var sort = function(items) {" - expect(editor.getLastScreenRow()).toBe 4 - - languageMode.foldAllAtIndentLevel(2) - expect(editor.lineTextForScreenRow(0)).toBe "var quicksort = function () {" - expect(editor.lineTextForScreenRow(1)).toBe " var sort = function(items) {" - expect(editor.lineTextForScreenRow(2)).toBe " if (items.length <= 1) return items;" - expect(editor.getLastScreenRow()).toBe 9 - - describe "folding with comments", -> - beforeEach -> - waitsForPromise -> - atom.workspace.open('sample-with-comments.js', autoIndent: false).then (o) -> - editor = o - {buffer, languageMode} = editor - - waitsForPromise -> - atom.packages.activatePackage('language-javascript') - - afterEach -> - atom.packages.deactivatePackages() - atom.packages.unloadPackages() - - describe ".unfoldAll()", -> - it "unfolds every folded line", -> - initialScreenLineCount = editor.getScreenLineCount() - languageMode.foldBufferRow(0) - languageMode.foldBufferRow(5) - expect(editor.getScreenLineCount()).toBeLessThan initialScreenLineCount - languageMode.unfoldAll() - expect(editor.getScreenLineCount()).toBe initialScreenLineCount - - describe ".foldAll()", -> - it "folds every foldable line", -> - languageMode.foldAll() - - fold1 = editor.tokenizedLineForScreenRow(0).fold - expect([fold1.getStartRow(), fold1.getEndRow()]).toEqual [0, 19] - fold1.destroy() - - fold2 = editor.tokenizedLineForScreenRow(1).fold - expect([fold2.getStartRow(), fold2.getEndRow()]).toEqual [1, 4] - - fold3 = editor.tokenizedLineForScreenRow(2).fold.destroy() - - fold4 = editor.tokenizedLineForScreenRow(3).fold - expect([fold4.getStartRow(), fold4.getEndRow()]).toEqual [6, 8] - - describe ".foldAllAtIndentLevel()", -> - it "folds every foldable range at a given indentLevel", -> - languageMode.foldAllAtIndentLevel(2) - - fold1 = editor.tokenizedLineForScreenRow(6).fold - expect([fold1.getStartRow(), fold1.getEndRow()]).toEqual [6, 8] - fold1.destroy() - - fold2 = editor.tokenizedLineForScreenRow(11).fold - expect([fold2.getStartRow(), fold2.getEndRow()]).toEqual [11, 14] - fold2.destroy() - - it "does not fold anything but the indentLevel", -> - languageMode.foldAllAtIndentLevel(0) - - fold1 = editor.tokenizedLineForScreenRow(0).fold - expect([fold1.getStartRow(), fold1.getEndRow()]).toEqual [0, 19] - fold1.destroy() - - fold2 = editor.tokenizedLineForScreenRow(5).fold - expect(fold2).toBeFalsy() - - describe ".isFoldableAtBufferRow(bufferRow)", -> - it "returns true if the line starts a multi-line comment", -> - expect(languageMode.isFoldableAtBufferRow(1)).toBe true - expect(languageMode.isFoldableAtBufferRow(6)).toBe true - expect(languageMode.isFoldableAtBufferRow(17)).toBe false - - it "does not return true for a line in the middle of a comment that's followed by an indented line", -> - expect(languageMode.isFoldableAtBufferRow(7)).toBe false - editor.buffer.insert([8, 0], ' ') - expect(languageMode.isFoldableAtBufferRow(7)).toBe false - - describe "css", -> - beforeEach -> - waitsForPromise -> - atom.workspace.open('css.css', autoIndent: true).then (o) -> - editor = o - {buffer, languageMode} = editor - - waitsForPromise -> - atom.packages.activatePackage('language-source') - atom.packages.activatePackage('language-css') - - afterEach -> - atom.packages.deactivatePackages() - atom.packages.unloadPackages() - - describe "suggestedIndentForBufferRow", -> - it "does not return negative values (regression)", -> - editor.setText('.test {\npadding: 0;\n}') - expect(editor.suggestedIndentForBufferRow(2)).toBe 0 diff --git a/spec-nylas/launch-services-spec.coffee b/spec/launch-services-spec.coffee similarity index 100% rename from spec-nylas/launch-services-spec.coffee rename to spec/launch-services-spec.coffee diff --git a/spec-nylas/menu-manager-spec.coffee b/spec/menu-manager-spec.coffee similarity index 100% rename from spec-nylas/menu-manager-spec.coffee rename to spec/menu-manager-spec.coffee diff --git a/spec-nylas/model-view-selection-spec.coffee b/spec/model-view-selection-spec.coffee similarity index 100% rename from spec-nylas/model-view-selection-spec.coffee rename to spec/model-view-selection-spec.coffee diff --git a/spec-nylas/model-view-spec.coffee b/spec/model-view-spec.coffee similarity index 100% rename from spec-nylas/model-view-spec.coffee rename to spec/model-view-spec.coffee diff --git a/spec-nylas/models/contact-spec.coffee b/spec/models/contact-spec.coffee similarity index 100% rename from spec-nylas/models/contact-spec.coffee rename to spec/models/contact-spec.coffee diff --git a/spec-nylas/models/event-spec.coffee b/spec/models/event-spec.coffee similarity index 100% rename from spec-nylas/models/event-spec.coffee rename to spec/models/event-spec.coffee diff --git a/spec-nylas/models/file-spec.coffee b/spec/models/file-spec.coffee similarity index 100% rename from spec-nylas/models/file-spec.coffee rename to spec/models/file-spec.coffee diff --git a/spec-nylas/models/message-spec.coffee b/spec/models/message-spec.coffee similarity index 100% rename from spec-nylas/models/message-spec.coffee rename to spec/models/message-spec.coffee diff --git a/spec-nylas/models/model-spec.coffee b/spec/models/model-spec.coffee similarity index 100% rename from spec-nylas/models/model-spec.coffee rename to spec/models/model-spec.coffee diff --git a/spec-nylas/models/query-spec.coffee b/spec/models/query-spec.coffee similarity index 100% rename from spec-nylas/models/query-spec.coffee rename to spec/models/query-spec.coffee diff --git a/spec-nylas/models/thread-spec.coffee b/spec/models/thread-spec.coffee similarity index 100% rename from spec-nylas/models/thread-spec.coffee rename to spec/models/thread-spec.coffee diff --git a/spec-nylas/module-cache-spec.coffee b/spec/module-cache-spec.coffee similarity index 97% rename from spec-nylas/module-cache-spec.coffee rename to spec/module-cache-spec.coffee index 7b29849f9..7f9fdebfe 100644 --- a/spec-nylas/module-cache-spec.coffee +++ b/spec/module-cache-spec.coffee @@ -23,7 +23,7 @@ describe 'ModuleCache', -> _atomModuleCache: extensions: '.json': [ - path.join('spec-nylas', 'fixtures', 'module-cache', 'file.json') + path.join('spec', 'fixtures', 'module-cache', 'file.json') ] } expect(require('./fixtures/module-cache/file.json').foo).toBe 'bar' diff --git a/spec/notification-manager-spec.coffee b/spec/notification-manager-spec.coffee deleted file mode 100644 index dfc16322c..000000000 --- a/spec/notification-manager-spec.coffee +++ /dev/null @@ -1,57 +0,0 @@ -NotificationManager = require '../src/notification-manager' - -describe "NotificationManager", -> - [manager] = [] - - beforeEach -> - manager = new NotificationManager - - describe "the atom global", -> - it "has a notifications instance", -> - expect(atom.notifications instanceof NotificationManager).toBe true - - describe "adding events", -> - addSpy = null - - beforeEach -> - addSpy = jasmine.createSpy() - manager.onDidAddNotification(addSpy) - - it "emits an event when a notification has been added", -> - manager.add('error', 'Some error!', icon: 'someIcon') - expect(addSpy).toHaveBeenCalled() - - notification = addSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'error' - expect(notification.getMessage()).toBe 'Some error!' - expect(notification.getIcon()).toBe 'someIcon' - - it "emits a fatal error ::addFatalError has been called", -> - manager.addFatalError('Some error!', icon: 'someIcon') - expect(addSpy).toHaveBeenCalled() - notification = addSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'fatal' - - it "emits an error ::addError has been called", -> - manager.addError('Some error!', icon: 'someIcon') - expect(addSpy).toHaveBeenCalled() - notification = addSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'error' - - it "emits a warning notification ::addWarning has been called", -> - manager.addWarning('Something!', icon: 'someIcon') - expect(addSpy).toHaveBeenCalled() - notification = addSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'warning' - - it "emits an info notification ::addInfo has been called", -> - manager.addInfo('Something!', icon: 'someIcon') - expect(addSpy).toHaveBeenCalled() - notification = addSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'info' - - it "emits a success notification ::addSuccess has been called", -> - manager.addSuccess('Something!', icon: 'someIcon') - expect(addSpy).toHaveBeenCalled() - notification = addSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'success' diff --git a/spec/notification-spec.coffee b/spec/notification-spec.coffee deleted file mode 100644 index 0ff4599a7..000000000 --- a/spec/notification-spec.coffee +++ /dev/null @@ -1,47 +0,0 @@ -Notification = require '../src/notification' - -describe "Notification", -> - [notification] = [] - - describe "::getTimestamp()", -> - it "returns a Date object", -> - notification = new Notification('error', 'message!') - expect(notification.getTimestamp() instanceof Date).toBe true - - describe "::getIcon()", -> - it "returns a default when no icon specified", -> - notification = new Notification('error', 'message!') - expect(notification.getIcon()).toBe 'flame' - - it "returns the icon specified", -> - notification = new Notification('error', 'message!', icon: 'my-icon') - expect(notification.getIcon()).toBe 'my-icon' - - describe "dismissing notifications", -> - describe "when the notfication is dismissable", -> - it "calls a callback when the notification is dismissed", -> - dismissedSpy = jasmine.createSpy() - notification = new Notification('error', 'message', dismissable: true) - notification.onDidDismiss dismissedSpy - - expect(notification.isDismissable()).toBe true - expect(notification.isDismissed()).toBe false - - notification.dismiss() - - expect(dismissedSpy).toHaveBeenCalled() - expect(notification.isDismissed()).toBe true - - describe "when the notfication is not dismissable", -> - it "does nothing when ::dismiss() is called", -> - dismissedSpy = jasmine.createSpy() - notification = new Notification('error', 'message') - notification.onDidDismiss dismissedSpy - - expect(notification.isDismissable()).toBe false - expect(notification.isDismissed()).toBe true - - notification.dismiss() - - expect(dismissedSpy).not.toHaveBeenCalled() - expect(notification.isDismissed()).toBe true diff --git a/spec-nylas/nylas-api-spec.coffee b/spec/nylas-api-spec.coffee similarity index 100% rename from spec-nylas/nylas-api-spec.coffee rename to spec/nylas-api-spec.coffee diff --git a/spec-nylas/nylas-protocol-handler-spec.coffee b/spec/nylas-protocol-handler-spec.coffee similarity index 100% rename from spec-nylas/nylas-protocol-handler-spec.coffee rename to spec/nylas-protocol-handler-spec.coffee diff --git a/spec-nylas/package-manager-spec.coffee b/spec/package-manager-spec.coffee similarity index 100% rename from spec-nylas/package-manager-spec.coffee rename to spec/package-manager-spec.coffee diff --git a/spec-nylas/package-spec.coffee b/spec/package-spec.coffee similarity index 100% rename from spec-nylas/package-spec.coffee rename to spec/package-spec.coffee diff --git a/spec-nylas/quoted-html-parser-spec.coffee b/spec/quoted-html-parser-spec.coffee similarity index 100% rename from spec-nylas/quoted-html-parser-spec.coffee rename to spec/quoted-html-parser-spec.coffee diff --git a/spec-nylas/quoted-plain-text-parser-spec.coffee b/spec/quoted-plain-text-parser-spec.coffee similarity index 100% rename from spec-nylas/quoted-plain-text-parser-spec.coffee rename to spec/quoted-plain-text-parser-spec.coffee diff --git a/spec/space-pen-extensions-spec.coffee b/spec/space-pen-extensions-spec.coffee deleted file mode 100644 index e11b32de9..000000000 --- a/spec/space-pen-extensions-spec.coffee +++ /dev/null @@ -1,41 +0,0 @@ -{View, $, $$} = require '../src/space-pen-extensions' - -describe "SpacePen extensions", -> - class TestView extends View - @content: -> @div() - - [view, parent] = [] - - beforeEach -> - view = new TestView - parent = $$ -> @div() - parent.append(view) - - describe "View.subscribe(eventEmitter, eventName, callback)", -> - [emitter, eventHandler] = [] - - beforeEach -> - eventHandler = jasmine.createSpy 'eventHandler' - emitter = $$ -> @div() - view.subscribe emitter, 'foo', eventHandler - - it "subscribes to the given event emitter and unsubscribes when unsubscribe is called", -> - emitter.trigger "foo" - expect(eventHandler).toHaveBeenCalled() - - describe "tooltips", -> - describe "when the window is resized", -> - it "hides the tooltips", -> - class TooltipView extends View - @content: -> - @div() - - view = new TooltipView() - view.attachToDom() - view.setTooltip('this is a tip') - - view.tooltip('show') - expect($(document.body).find('.tooltip')).toBeVisible() - - $(window).trigger('resize') - expect($(document.body).find('.tooltip')).not.toExist() diff --git a/spec/spec-suite.coffee b/spec/spec-suite.coffee index d79f62cb0..7d5886278 100644 --- a/spec/spec-suite.coffee +++ b/spec/spec-suite.coffee @@ -33,10 +33,7 @@ setSpecDirectory = (specDirectory) -> runAllSpecs = -> {resourcePath} = atom.getLoadSettings() - # requireSpecs(path.join(resourcePath, 'spec')) - # - # EDGEHILL_CORE: Load edgehill core specs instead of Atom text editor core specs. - requireSpecs(path.join(resourcePath, 'spec-nylas')) + requireSpecs(path.join(resourcePath, 'spec')) setSpecType('core') diff --git a/spec/squirrel-update-spec.coffee b/spec/squirrel-update-spec.coffee deleted file mode 100644 index b71a9b0c4..000000000 --- a/spec/squirrel-update-spec.coffee +++ /dev/null @@ -1,104 +0,0 @@ -ChildProcess = require 'child_process' -{EventEmitter} = require 'events' -fs = require 'fs-plus' -path = require 'path' -temp = require 'temp' -SquirrelUpdate = require '../src/browser/squirrel-update' - -describe "Windows squirrel updates", -> - tempHomeDirectory = null - - beforeEach -> - # Prevent the actually home directory from being manipulated - tempHomeDirectory = temp.mkdirSync('atom-temp-home-') - spyOn(fs, 'getHomeDirectory').andReturn(tempHomeDirectory) - - # Prevent any commands from actually running and affecting the host - originalSpawn = ChildProcess.spawn - spyOn(ChildProcess, 'spawn').andCallFake (command, args) -> - if path.basename(command) is 'Update.exe' and args?[0] is '--createShortcut' - fs.writeFileSync(path.join(tempHomeDirectory, 'Desktop', 'Atom.lnk'), '') - - # Just spawn something that won't actually modify the host - if process.platform is 'win32' - originalSpawn('dir') - else - originalSpawn('ls') - - it "ignores errors spawning Squirrel", -> - jasmine.unspy(ChildProcess, 'spawn') - spyOn(ChildProcess, 'spawn').andCallFake -> throw new Error("EBUSY") - - app = quit: jasmine.createSpy('quit') - expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-install')).toBe true - - waitsFor -> - app.quit.callCount is 1 - - it "quits the app on all squirrel events", -> - app = quit: jasmine.createSpy('quit') - - expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-install')).toBe true - - waitsFor -> - app.quit.callCount is 1 - - runs -> - app.quit.reset() - expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-updated')).toBe true - - waitsFor -> - app.quit.callCount is 1 - - runs -> - app.quit.reset() - expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-uninstall')).toBe true - - waitsFor -> - app.quit.callCount is 1 - - runs -> - app.quit.reset() - expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-obsolete')).toBe true - - waitsFor -> - app.quit.callCount is 1 - - runs -> - expect(SquirrelUpdate.handleStartupEvent(app, '--not-squirrel')).toBe false - - it "keeps the desktop shortcut deleted on updates if it was previously deleted after install", -> - desktopShortcutPath = path.join(tempHomeDirectory, 'Desktop', 'Atom.lnk') - expect(fs.existsSync(desktopShortcutPath)).toBe false - - app = quit: jasmine.createSpy('quit') - expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-install')).toBe true - - waitsFor -> - app.quit.callCount is 1 - - runs -> - app.quit.reset() - expect(fs.existsSync(desktopShortcutPath)).toBe true - fs.removeSync(desktopShortcutPath) - expect(fs.existsSync(desktopShortcutPath)).toBe false - expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-updated')).toBe true - - waitsFor -> - app.quit.callCount is 1 - - runs -> - expect(fs.existsSync(desktopShortcutPath)).toBe false - - describe ".restartAtom", -> - it "quits the app and spawns a new one", -> - app = new EventEmitter() - app.quit = jasmine.createSpy('quit') - - SquirrelUpdate.restartAtom(app) - expect(app.quit.callCount).toBe 1 - - expect(ChildProcess.spawn.callCount).toBe 0 - app.emit('will-quit') - expect(ChildProcess.spawn.callCount).toBe 1 - expect(path.basename(ChildProcess.spawn.argsForCall[0][0])).toBe 'atom.cmd' diff --git a/spec-nylas/stores/account-store-spec.coffee b/spec/stores/account-store-spec.coffee similarity index 100% rename from spec-nylas/stores/account-store-spec.coffee rename to spec/stores/account-store-spec.coffee diff --git a/spec-nylas/stores/contact-store-spec.coffee b/spec/stores/contact-store-spec.coffee similarity index 100% rename from spec-nylas/stores/contact-store-spec.coffee rename to spec/stores/contact-store-spec.coffee diff --git a/spec-nylas/stores/database-setup-query-builder-spec.coffee b/spec/stores/database-setup-query-builder-spec.coffee similarity index 100% rename from spec-nylas/stores/database-setup-query-builder-spec.coffee rename to spec/stores/database-setup-query-builder-spec.coffee diff --git a/spec-nylas/stores/database-store-spec.coffee b/spec/stores/database-store-spec.coffee similarity index 100% rename from spec-nylas/stores/database-store-spec.coffee rename to spec/stores/database-store-spec.coffee diff --git a/spec-nylas/stores/draft-store-proxy-spec.coffee b/spec/stores/draft-store-proxy-spec.coffee similarity index 100% rename from spec-nylas/stores/draft-store-proxy-spec.coffee rename to spec/stores/draft-store-proxy-spec.coffee diff --git a/spec-nylas/stores/draft-store-spec.coffee b/spec/stores/draft-store-spec.coffee similarity index 100% rename from spec-nylas/stores/draft-store-spec.coffee rename to spec/stores/draft-store-spec.coffee diff --git a/spec-nylas/stores/event-store-spec.coffee b/spec/stores/event-store-spec.coffee similarity index 100% rename from spec-nylas/stores/event-store-spec.coffee rename to spec/stores/event-store-spec.coffee diff --git a/spec-nylas/stores/file-download-store-spec.coffee b/spec/stores/file-download-store-spec.coffee similarity index 100% rename from spec-nylas/stores/file-download-store-spec.coffee rename to spec/stores/file-download-store-spec.coffee diff --git a/spec-nylas/stores/file-upload-store-spec.coffee b/spec/stores/file-upload-store-spec.coffee similarity index 100% rename from spec-nylas/stores/file-upload-store-spec.coffee rename to spec/stores/file-upload-store-spec.coffee diff --git a/spec-nylas/stores/focused-contacts-store-spec.coffee b/spec/stores/focused-contacts-store-spec.coffee similarity index 100% rename from spec-nylas/stores/focused-contacts-store-spec.coffee rename to spec/stores/focused-contacts-store-spec.coffee diff --git a/spec-nylas/stores/focused-content-store-spec.coffee b/spec/stores/focused-content-store-spec.coffee similarity index 100% rename from spec-nylas/stores/focused-content-store-spec.coffee rename to spec/stores/focused-content-store-spec.coffee diff --git a/spec-nylas/stores/focused-mail-view-store-spec.coffee b/spec/stores/focused-mail-view-store-spec.coffee similarity index 100% rename from spec-nylas/stores/focused-mail-view-store-spec.coffee rename to spec/stores/focused-mail-view-store-spec.coffee diff --git a/spec-nylas/stores/message-store-spec.coffee b/spec/stores/message-store-spec.coffee similarity index 100% rename from spec-nylas/stores/message-store-spec.coffee rename to spec/stores/message-store-spec.coffee diff --git a/spec-nylas/stores/metadata-store-spec.coffee b/spec/stores/metadata-store-spec.coffee similarity index 100% rename from spec-nylas/stores/metadata-store-spec.coffee rename to spec/stores/metadata-store-spec.coffee diff --git a/spec-nylas/stores/task-queue-spec.coffee b/spec/stores/task-queue-spec.coffee similarity index 100% rename from spec-nylas/stores/task-queue-spec.coffee rename to spec/stores/task-queue-spec.coffee diff --git a/spec-nylas/stores/unread-count-store-spec.coffee b/spec/stores/unread-count-store-spec.coffee similarity index 100% rename from spec-nylas/stores/unread-count-store-spec.coffee rename to spec/stores/unread-count-store-spec.coffee diff --git a/spec-nylas/style-manager-spec.coffee b/spec/style-manager-spec.coffee similarity index 100% rename from spec-nylas/style-manager-spec.coffee rename to spec/style-manager-spec.coffee diff --git a/spec-nylas/styles-element-spec.coffee b/spec/styles-element-spec.coffee similarity index 100% rename from spec-nylas/styles-element-spec.coffee rename to spec/styles-element-spec.coffee diff --git a/spec-nylas/tasks/change-folder-task-spec.coffee b/spec/tasks/change-folder-task-spec.coffee similarity index 100% rename from spec-nylas/tasks/change-folder-task-spec.coffee rename to spec/tasks/change-folder-task-spec.coffee diff --git a/spec-nylas/tasks/change-labels-task-spec.coffee b/spec/tasks/change-labels-task-spec.coffee similarity index 100% rename from spec-nylas/tasks/change-labels-task-spec.coffee rename to spec/tasks/change-labels-task-spec.coffee diff --git a/spec-nylas/tasks/change-mail-task-spec.coffee b/spec/tasks/change-mail-task-spec.coffee similarity index 100% rename from spec-nylas/tasks/change-mail-task-spec.coffee rename to spec/tasks/change-mail-task-spec.coffee diff --git a/spec-nylas/tasks/change-starred-task-spec.coffee b/spec/tasks/change-starred-task-spec.coffee similarity index 100% rename from spec-nylas/tasks/change-starred-task-spec.coffee rename to spec/tasks/change-starred-task-spec.coffee diff --git a/spec-nylas/tasks/change-unread-task-spec.coffee b/spec/tasks/change-unread-task-spec.coffee similarity index 100% rename from spec-nylas/tasks/change-unread-task-spec.coffee rename to spec/tasks/change-unread-task-spec.coffee diff --git a/spec-nylas/tasks/event-rsvp-spec.coffee b/spec/tasks/event-rsvp-spec.coffee similarity index 100% rename from spec-nylas/tasks/event-rsvp-spec.coffee rename to spec/tasks/event-rsvp-spec.coffee diff --git a/spec-nylas/tasks/file-upload-task-spec.coffee b/spec/tasks/file-upload-task-spec.coffee similarity index 100% rename from spec-nylas/tasks/file-upload-task-spec.coffee rename to spec/tasks/file-upload-task-spec.coffee diff --git a/spec-nylas/tasks/mark-message-read-spec.coffee b/spec/tasks/mark-message-read-spec.coffee similarity index 100% rename from spec-nylas/tasks/mark-message-read-spec.coffee rename to spec/tasks/mark-message-read-spec.coffee diff --git a/spec-nylas/tasks/remove-thread-helper-spec.coffee b/spec/tasks/remove-thread-helper-spec.coffee similarity index 100% rename from spec-nylas/tasks/remove-thread-helper-spec.coffee rename to spec/tasks/remove-thread-helper-spec.coffee diff --git a/spec-nylas/tasks/send-draft-spec.coffee b/spec/tasks/send-draft-spec.coffee similarity index 100% rename from spec-nylas/tasks/send-draft-spec.coffee rename to spec/tasks/send-draft-spec.coffee diff --git a/spec-nylas/tasks/syncback-category-task-spec.coffee b/spec/tasks/syncback-category-task-spec.coffee similarity index 100% rename from spec-nylas/tasks/syncback-category-task-spec.coffee rename to spec/tasks/syncback-category-task-spec.coffee diff --git a/spec-nylas/tasks/syncback-draft-spec.coffee b/spec/tasks/syncback-draft-spec.coffee similarity index 100% rename from spec-nylas/tasks/syncback-draft-spec.coffee rename to spec/tasks/syncback-draft-spec.coffee diff --git a/spec-nylas/tasks/task-spec.coffee b/spec/tasks/task-spec.coffee similarity index 100% rename from spec-nylas/tasks/task-spec.coffee rename to spec/tasks/task-spec.coffee diff --git a/spec-nylas/test_utils.coffee b/spec/test_utils.coffee similarity index 100% rename from spec-nylas/test_utils.coffee rename to spec/test_utils.coffee diff --git a/spec-nylas/theme-manager-spec.coffee b/spec/theme-manager-spec.coffee similarity index 100% rename from spec-nylas/theme-manager-spec.coffee rename to spec/theme-manager-spec.coffee diff --git a/spec-nylas/undo-manager-spec.coffee b/spec/undo-manager-spec.coffee similarity index 100% rename from spec-nylas/undo-manager-spec.coffee rename to spec/undo-manager-spec.coffee diff --git a/spec-nylas/utils-spec.coffee b/spec/utils-spec.coffee similarity index 100% rename from spec-nylas/utils-spec.coffee rename to spec/utils-spec.coffee diff --git a/spec/window-spec.coffee b/spec/window-spec.coffee deleted file mode 100644 index fdeefc0a7..000000000 --- a/spec/window-spec.coffee +++ /dev/null @@ -1,287 +0,0 @@ -{$, $$} = require '../src/space-pen-extensions' -path = require 'path' -TextEditor = require '../src/text-editor' -WindowEventHandler = require '../src/window-event-handler' - -describe "Window", -> - [projectPath, windowEventHandler] = [] - - beforeEach -> - spyOn(atom, 'hide') - initialPath = atom.project.getPaths()[0] - spyOn(atom, 'getLoadSettings').andCallFake -> - loadSettings = atom.getLoadSettings.originalValue.call(atom) - loadSettings.initialPath = initialPath - loadSettings - atom.project.destroy() - windowEventHandler = new WindowEventHandler() - atom.deserializeEditorWindow() - projectPath = atom.project.getPaths()[0] - - afterEach -> - windowEventHandler.unsubscribe() - $(window).off 'beforeunload' - - describe "when the window is loaded", -> - it "doesn't have .is-blurred on the body tag", -> - expect($("body")).not.toHaveClass("is-blurred") - - describe "when the window is blurred", -> - beforeEach -> - $(window).triggerHandler 'blur' - - afterEach -> - $('body').removeClass('is-blurred') - - it "adds the .is-blurred class on the body", -> - expect($("body")).toHaveClass("is-blurred") - - describe "when the window is focused again", -> - it "removes the .is-blurred class from the body", -> - $(window).triggerHandler 'focus' - expect($("body")).not.toHaveClass("is-blurred") - - describe "window:close event", -> - it "closes the window", -> - spyOn(atom, 'close') - $(window).trigger 'window:close' - expect(atom.close).toHaveBeenCalled() - - describe "beforeunload event", -> - [beforeUnloadEvent] = [] - - beforeEach -> - jasmine.unspy(TextEditor.prototype, "shouldPromptToSave") - beforeUnloadEvent = $.Event(new Event('beforeunload')) - - describe "when pane items are are modified", -> - it "prompts user to save and calls atom.workspace.confirmClose", -> - editor = null - spyOn(atom.workspace, 'confirmClose').andCallThrough() - spyOn(atom, "confirm").andReturn(2) - - waitsForPromise -> - atom.workspace.open("sample.js").then (o) -> editor = o - - runs -> - editor.insertText("I look different, I feel different.") - $(window).trigger(beforeUnloadEvent) - expect(atom.workspace.confirmClose).toHaveBeenCalled() - expect(atom.confirm).toHaveBeenCalled() - - it "prompts user to save and handler returns true if don't save", -> - editor = null - spyOn(atom, "confirm").andReturn(2) - - waitsForPromise -> - atom.workspace.open("sample.js").then (o) -> editor = o - - runs -> - editor.insertText("I look different, I feel different.") - $(window).trigger(beforeUnloadEvent) - expect(atom.confirm).toHaveBeenCalled() - - it "prompts user to save and handler returns false if dialog is canceled", -> - editor = null - spyOn(atom, "confirm").andReturn(1) - waitsForPromise -> - atom.workspace.open("sample.js").then (o) -> editor = o - - runs -> - editor.insertText("I look different, I feel different.") - $(window).trigger(beforeUnloadEvent) - expect(atom.confirm).toHaveBeenCalled() - - describe ".saveStateAndUnloadWindow()", -> - it "saves the serialized state of the window so it can be deserialized after reload", -> - workspaceState = atom.workspace.serialize() - syntaxState = atom.grammars.serialize() - projectState = atom.project.serialize() - - atom.saveStateAndUnloadWindow() - - expect(atom.state.workspace).toEqual workspaceState - expect(atom.state.grammars).toEqual syntaxState - expect(atom.state.project).toEqual projectState - expect(atom.saveSync).toHaveBeenCalled() - - describe ".removeEditorWindow()", -> - it "unsubscribes from all buffers", -> - waitsForPromise -> - atom.workspace.open("sample.js") - - runs -> - buffer = atom.workspace.getActivePaneItem().buffer - pane = atom.workspace.getActivePane() - pane.splitRight(copyActiveItem: true) - expect(atom.workspace.getTextEditors().length).toBe 2 - - atom.removeEditorWindow() - - expect(buffer.getSubscriptionCount()).toBe 0 - - describe "drag and drop", -> - buildDragEvent = (type, files) -> - dataTransfer = - files: files - data: {} - setData: (key, value) -> @data[key] = value - getData: (key) -> @data[key] - - event = new CustomEvent("drop") - event.dataTransfer = dataTransfer - event - - describe "when a file is dragged to window", -> - it "opens it", -> - spyOn(atom, "open") - event = buildDragEvent("drop", [ {path: "/fake1"}, {path: "/fake2"} ]) - document.dispatchEvent(event) - expect(atom.open.callCount).toBe 1 - expect(atom.open.argsForCall[0][0]).toEqual pathsToOpen: ['/fake1', '/fake2'] - - describe "when a non-file is dragged to window", -> - it "does nothing", -> - spyOn(atom, "open") - event = buildDragEvent("drop", []) - document.dispatchEvent(event) - expect(atom.open).not.toHaveBeenCalled() - - describe "when a link is clicked", -> - it "opens the http/https links in an external application", -> - shell = require 'shell' - spyOn(shell, 'openExternal') - - $("the website").appendTo(document.body).click().remove() - expect(shell.openExternal).toHaveBeenCalled() - expect(shell.openExternal.argsForCall[0][0]).toBe "http://github.com" - - shell.openExternal.reset() - $("the website").appendTo(document.body).click().remove() - expect(shell.openExternal).toHaveBeenCalled() - expect(shell.openExternal.argsForCall[0][0]).toBe "https://github.com" - - shell.openExternal.reset() - $("the website").appendTo(document.body).click().remove() - expect(shell.openExternal).not.toHaveBeenCalled() - - shell.openExternal.reset() - $("link").appendTo(document.body).click().remove() - expect(shell.openExternal).not.toHaveBeenCalled() - - describe "when a form is submitted", -> - it "prevents the default so that the window's URL isn't changed", -> - submitSpy = jasmine.createSpy('submit') - $(document).on('submit', 'form', submitSpy) - $("
foo
").appendTo(document.body).submit().remove() - expect(submitSpy.callCount).toBe 1 - expect(submitSpy.argsForCall[0][0].isDefaultPrevented()).toBe true - - describe "core:focus-next and core:focus-previous", -> - describe "when there is no currently focused element", -> - it "focuses the element with the lowest/highest tabindex", -> - elements = $$ -> - @div => - @button tabindex: 2 - @input tabindex: 1 - - elements.attachToDom() - - elements.trigger "core:focus-next" - expect(elements.find("[tabindex=1]:focus")).toExist() - - $(":focus").blur() - - elements.trigger "core:focus-previous" - expect(elements.find("[tabindex=2]:focus")).toExist() - - describe "when a tabindex is set on the currently focused element", -> - it "focuses the element with the next highest tabindex", -> - elements = $$ -> - @div => - @input tabindex: 1 - @button tabindex: 2 - @button tabindex: 5 - @input tabindex: -1 - @input tabindex: 3 - @button tabindex: 7 - - elements.attachToDom() - elements.find("[tabindex=1]").focus() - - elements.trigger "core:focus-next" - expect(elements.find("[tabindex=2]:focus")).toExist() - - elements.trigger "core:focus-next" - expect(elements.find("[tabindex=3]:focus")).toExist() - - elements.focus().trigger "core:focus-next" - expect(elements.find("[tabindex=5]:focus")).toExist() - - elements.focus().trigger "core:focus-next" - expect(elements.find("[tabindex=7]:focus")).toExist() - - elements.focus().trigger "core:focus-next" - expect(elements.find("[tabindex=1]:focus")).toExist() - - elements.trigger "core:focus-previous" - expect(elements.find("[tabindex=7]:focus")).toExist() - - elements.trigger "core:focus-previous" - expect(elements.find("[tabindex=5]:focus")).toExist() - - elements.focus().trigger "core:focus-previous" - expect(elements.find("[tabindex=3]:focus")).toExist() - - elements.focus().trigger "core:focus-previous" - expect(elements.find("[tabindex=2]:focus")).toExist() - - elements.focus().trigger "core:focus-previous" - expect(elements.find("[tabindex=1]:focus")).toExist() - - it "skips disabled elements", -> - elements = $$ -> - @div => - @input tabindex: 1 - @button tabindex: 2, disabled: 'disabled' - @input tabindex: 3 - - elements.attachToDom() - elements.find("[tabindex=1]").focus() - - elements.trigger "core:focus-next" - expect(elements.find("[tabindex=3]:focus")).toExist() - - elements.trigger "core:focus-previous" - expect(elements.find("[tabindex=1]:focus")).toExist() - - describe "the window:open-path event", -> - beforeEach -> - spyOn(atom.workspace, 'open') - - describe "when the project does not have a path", -> - beforeEach -> - atom.project.setPaths([]) - - describe "when the opened path exists", -> - it "sets the project path to the opened path", -> - atom.getCurrentWindow().send 'open-path', pathToOpen: __filename - expect(atom.project.getPaths()[0]).toBe __dirname - - describe "when the opened path does not exist but its parent directory does", -> - it "sets the project path to the opened path's parent directory", -> - pathToOpen = path.join(__dirname, 'this-path-does-not-exist.txt') - atom.getCurrentWindow().send 'open-path', {pathToOpen} - expect(atom.project.getPaths()[0]).toBe __dirname - - describe "when the opened path is a file", -> - it "opens it in the workspace", -> - atom.getCurrentWindow().send 'open-path', pathToOpen: __filename - - expect(atom.workspace.open.mostRecentCall.args[0]).toBe __filename - - describe "when the opened path is a directory", -> - it "does not open it in the workspace", -> - atom.getCurrentWindow().send 'open-path', pathToOpen: __dirname - - expect(atom.workspace.open.callCount).toBe 0 diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee deleted file mode 100644 index a175b1acc..000000000 --- a/spec/workspace-spec.coffee +++ /dev/null @@ -1,1031 +0,0 @@ -path = require 'path' -temp = require 'temp' -Workspace = require '../src/workspace' -Pane = require '../src/pane' -{View} = require '../src/space-pen-extensions' -platform = require './spec-helper-platform' -_ = require 'underscore' -fstream = require 'fstream' -fs = require 'fs-plus' -Grim = require 'grim' - -describe "Workspace", -> - workspace = null - - beforeEach -> - atom.project.setPaths([atom.project.getDirectories()[0]?.resolve('dir')]) - atom.workspace = workspace = new Workspace - - describe "::open(uri, options)", -> - openEvents = null - - beforeEach -> - openEvents = [] - workspace.onDidOpen (event) -> openEvents.push(event) - spyOn(workspace.getActivePane(), 'activate').andCallThrough() - - describe "when the 'searchAllPanes' option is false (default)", -> - describe "when called without a uri", -> - it "adds and activates an empty editor on the active pane", -> - [editor1, editor2] = [] - - waitsForPromise -> - workspace.open().then (editor) -> editor1 = editor - - runs -> - expect(editor1.getPath()).toBeUndefined() - expect(workspace.getActivePane().items).toEqual [editor1] - expect(workspace.getActivePaneItem()).toBe editor1 - expect(workspace.getActivePane().activate).toHaveBeenCalled() - expect(openEvents).toEqual [{uri: undefined, pane: workspace.getActivePane(), item: editor1, index: 0}] - openEvents = [] - - waitsForPromise -> - workspace.open().then (editor) -> editor2 = editor - - runs -> - expect(editor2.getPath()).toBeUndefined() - expect(workspace.getActivePane().items).toEqual [editor1, editor2] - expect(workspace.getActivePaneItem()).toBe editor2 - expect(workspace.getActivePane().activate).toHaveBeenCalled() - expect(openEvents).toEqual [{uri: undefined, pane: workspace.getActivePane(), item: editor2, index: 1}] - - describe "when called with a uri", -> - describe "when the active pane already has an editor for the given uri", -> - it "activates the existing editor on the active pane", -> - editor = null - editor1 = null - editor2 = null - - waitsForPromise -> - workspace.open('a').then (o) -> - editor1 = o - workspace.open('b').then (o) -> - editor2 = o - workspace.open('a').then (o) -> - editor = o - - runs -> - expect(editor).toBe editor1 - expect(workspace.getActivePaneItem()).toBe editor - expect(workspace.getActivePane().activate).toHaveBeenCalled() - - expect(openEvents).toEqual [ - { - uri: atom.project.getDirectories()[0]?.resolve('a') - item: editor1 - pane: atom.workspace.getActivePane() - index: 0 - } - { - uri: atom.project.getDirectories()[0]?.resolve('b') - item: editor2 - pane: atom.workspace.getActivePane() - index: 1 - } - { - uri: atom.project.getDirectories()[0]?.resolve('a') - item: editor1 - pane: atom.workspace.getActivePane() - index: 0 - } - ] - - describe "when the active pane does not have an editor for the given uri", -> - it "adds and activates a new editor for the given path on the active pane", -> - editor = null - waitsForPromise -> - workspace.open('a').then (o) -> editor = o - - runs -> - expect(editor.getURI()).toBe atom.project.getDirectories()[0]?.resolve('a') - expect(workspace.getActivePaneItem()).toBe editor - expect(workspace.getActivePane().items).toEqual [editor] - expect(workspace.getActivePane().activate).toHaveBeenCalled() - - describe "when the 'searchAllPanes' option is true", -> - describe "when an editor for the given uri is already open on an inactive pane", -> - it "activates the existing editor on the inactive pane, then activates that pane", -> - editor1 = null - editor2 = null - pane1 = workspace.getActivePane() - pane2 = workspace.getActivePane().splitRight() - - waitsForPromise -> - pane1.activate() - workspace.open('a').then (o) -> editor1 = o - - waitsForPromise -> - pane2.activate() - workspace.open('b').then (o) -> editor2 = o - - runs -> - expect(workspace.getActivePaneItem()).toBe editor2 - - waitsForPromise -> - workspace.open('a', searchAllPanes: true) - - runs -> - expect(workspace.getActivePane()).toBe pane1 - expect(workspace.getActivePaneItem()).toBe editor1 - - describe "when no editor for the given uri is open in any pane", -> - it "opens an editor for the given uri in the active pane", -> - editor = null - waitsForPromise -> - workspace.open('a', searchAllPanes: true).then (o) -> editor = o - - runs -> - expect(workspace.getActivePaneItem()).toBe editor - - describe "when the 'split' option is set", -> - describe "when the 'split' option is 'left'", -> - it "opens the editor in the leftmost pane of the current pane axis", -> - pane1 = workspace.getActivePane() - pane2 = pane1.splitRight() - expect(workspace.getActivePane()).toBe pane2 - - editor = null - waitsForPromise -> - workspace.open('a', split: 'left').then (o) -> editor = o - - runs -> - expect(workspace.getActivePane()).toBe pane1 - expect(pane1.items).toEqual [editor] - expect(pane2.items).toEqual [] - - # Focus right pane and reopen the file on the left - waitsForPromise -> - pane2.focus() - workspace.open('a', split: 'left').then (o) -> editor = o - - runs -> - expect(workspace.getActivePane()).toBe pane1 - expect(pane1.items).toEqual [editor] - expect(pane2.items).toEqual [] - - describe "when a pane axis is the leftmost sibling of the current pane", -> - it "opens the new item in the current pane", -> - editor = null - pane1 = workspace.getActivePane() - pane2 = pane1.splitLeft() - pane3 = pane2.splitDown() - pane1.activate() - expect(workspace.getActivePane()).toBe pane1 - - waitsForPromise -> - workspace.open('a', split: 'left').then (o) -> editor = o - - runs -> - expect(workspace.getActivePane()).toBe pane1 - expect(pane1.items).toEqual [editor] - - describe "when the 'split' option is 'right'", -> - it "opens the editor in the rightmost pane of the current pane axis", -> - editor = null - pane1 = workspace.getActivePane() - pane2 = null - waitsForPromise -> - workspace.open('a', split: 'right').then (o) -> editor = o - - runs -> - pane2 = workspace.getPanes().filter((p) -> p != pane1)[0] - expect(workspace.getActivePane()).toBe pane2 - expect(pane1.items).toEqual [] - expect(pane2.items).toEqual [editor] - - # Focus right pane and reopen the file on the right - waitsForPromise -> - pane1.focus() - workspace.open('a', split: 'right').then (o) -> editor = o - - runs -> - expect(workspace.getActivePane()).toBe pane2 - expect(pane1.items).toEqual [] - expect(pane2.items).toEqual [editor] - - describe "when a pane axis is the rightmost sibling of the current pane", -> - it "opens the new item in a new pane split to the right of the current pane", -> - editor = null - pane1 = workspace.getActivePane() - pane2 = pane1.splitRight() - pane3 = pane2.splitDown() - pane1.activate() - expect(workspace.getActivePane()).toBe pane1 - pane4 = null - - waitsForPromise -> - workspace.open('a', split: 'right').then (o) -> editor = o - - runs -> - pane4 = workspace.getPanes().filter((p) -> p != pane1)[0] - expect(workspace.getActivePane()).toBe pane4 - expect(pane4.items).toEqual [editor] - expect(workspace.paneContainer.root.children[0]).toBe pane1 - expect(workspace.paneContainer.root.children[1]).toBe pane4 - - describe "when passed a path that matches a custom opener", -> - it "returns the resource returned by the custom opener", -> - fooOpener = (pathToOpen, options) -> { foo: pathToOpen, options } if pathToOpen?.match(/\.foo/) - barOpener = (pathToOpen) -> { bar: pathToOpen } if pathToOpen?.match(/^bar:\/\//) - workspace.addOpener(fooOpener) - workspace.addOpener(barOpener) - - waitsForPromise -> - pathToOpen = atom.project.getDirectories()[0]?.resolve('a.foo') - workspace.open(pathToOpen, hey: "there").then (item) -> - expect(item).toEqual { foo: pathToOpen, options: {hey: "there"} } - - waitsForPromise -> - workspace.open("bar://baz").then (item) -> - expect(item).toEqual { bar: "bar://baz" } - - it "notifies ::onDidAddTextEditor observers", -> - absolutePath = require.resolve('./fixtures/dir/a') - newEditorHandler = jasmine.createSpy('newEditorHandler') - workspace.onDidAddTextEditor newEditorHandler - - editor = null - waitsForPromise -> - workspace.open(absolutePath).then (e) -> editor = e - - runs -> - expect(newEditorHandler.argsForCall[0][0].textEditor).toBe editor - - it "records a deprecation warning on the appropriate package if the item has a ::getUri method instead of ::getURI", -> - jasmine.snapshotDeprecations() - - waitsForPromise -> atom.packages.activatePackage('package-with-deprecated-pane-item-method') - - waitsForPromise -> - atom.workspace.open("test") - - runs -> - deprecations = Grim.getDeprecations() - expect(deprecations.length).toBe 1 - expect(deprecations[0].message).toBe "Pane item with class `TestItem` should implement `::getURI` instead of `::getUri`." - expect(deprecations[0].getStacks()[0].metadata.packageName).toBe "package-with-deprecated-pane-item-method" - jasmine.restoreDeprecationsSnapshot() - - describe "when there is an error opening the file", -> - notificationSpy = null - beforeEach -> - atom.notifications.onDidAddNotification notificationSpy = jasmine.createSpy() - - describe "when a large file is opened", -> - beforeEach -> - spyOn(fs, 'getSizeSync').andReturn 2 * 1048577 # 2MB - - it "creates a notification", -> - waitsForPromise -> - workspace.open('file1') - - runs -> - expect(notificationSpy).toHaveBeenCalled() - notification = notificationSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'warning' - expect(notification.getMessage()).toContain '< 2MB' - - describe "when a file does not exist", -> - it "creates an empty buffer for the specified path", -> - waitsForPromise -> - workspace.open('not-a-file.md') - - runs -> - editor = workspace.getActiveTextEditor() - expect(notificationSpy).not.toHaveBeenCalled() - expect(editor.getPath()).toContain 'not-a-file.md' - - describe "when the user does not have access to the file", -> - beforeEach -> - spyOn(fs, 'openSync').andCallFake (path) -> - error = new Error("EACCES, permission denied '#{path}'") - error.path = path - error.code = 'EACCES' - throw error - - it "creates a notification", -> - waitsForPromise -> - workspace.open('file1') - - runs -> - expect(notificationSpy).toHaveBeenCalled() - notification = notificationSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'warning' - expect(notification.getMessage()).toContain 'Permission denied' - expect(notification.getMessage()).toContain 'file1' - - describe "when the the operation is not permitted", -> - beforeEach -> - spyOn(fs, 'openSync').andCallFake (path) -> - error = new Error("EPERM, operation not permitted '#{path}'") - error.path = path - error.code = 'EPERM' - throw error - - it "creates a notification", -> - waitsForPromise -> - workspace.open('file1') - - runs -> - expect(notificationSpy).toHaveBeenCalled() - notification = notificationSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'warning' - expect(notification.getMessage()).toContain 'Unable to open' - expect(notification.getMessage()).toContain 'file1' - - describe "when the the file is already open in windows", -> - beforeEach -> - spyOn(fs, 'openSync').andCallFake (path) -> - error = new Error("EBUSY, resource busy or locked '#{path}'") - error.path = path - error.code = 'EBUSY' - throw error - - it "creates a notification", -> - waitsForPromise -> - workspace.open('file1') - - runs -> - expect(notificationSpy).toHaveBeenCalled() - notification = notificationSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'warning' - expect(notification.getMessage()).toContain 'Unable to open' - expect(notification.getMessage()).toContain 'file1' - - describe "when there is an unhandled error", -> - beforeEach -> - spyOn(fs, 'openSync').andCallFake (path) -> - throw new Error("I dont even know what is happening right now!!") - - it "creates a notification", -> - open = -> workspace.open('file1', workspace.getActivePane()) - expect(open).toThrow() - - describe "::reopenItem()", -> - it "opens the uri associated with the last closed pane that isn't currently open", -> - pane = workspace.getActivePane() - waitsForPromise -> - workspace.open('a').then -> - workspace.open('b').then -> - workspace.open('file1').then -> - workspace.open() - - runs -> - # does not reopen items with no uri - expect(workspace.getActivePaneItem().getURI()).toBeUndefined() - pane.destroyActiveItem() - - waitsForPromise -> - workspace.reopenItem() - - runs -> - expect(workspace.getActivePaneItem().getURI()).not.toBeUndefined() - - # destroy all items - expect(workspace.getActivePaneItem().getURI()).toBe atom.project.getDirectories()[0]?.resolve('file1') - pane.destroyActiveItem() - expect(workspace.getActivePaneItem().getURI()).toBe atom.project.getDirectories()[0]?.resolve('b') - pane.destroyActiveItem() - expect(workspace.getActivePaneItem().getURI()).toBe atom.project.getDirectories()[0]?.resolve('a') - pane.destroyActiveItem() - - # reopens items with uris - expect(workspace.getActivePaneItem()).toBeUndefined() - - waitsForPromise -> - workspace.reopenItem() - - runs -> - expect(workspace.getActivePaneItem().getURI()).toBe atom.project.getDirectories()[0]?.resolve('a') - - # does not reopen items that are already open - waitsForPromise -> - workspace.open('b') - - runs -> - expect(workspace.getActivePaneItem().getURI()).toBe atom.project.getDirectories()[0]?.resolve('b') - - waitsForPromise -> - workspace.reopenItem() - - runs -> - expect(workspace.getActivePaneItem().getURI()).toBe atom.project.getDirectories()[0]?.resolve('file1') - - describe "::increase/decreaseFontSize()", -> - it "increases/decreases the font size without going below 1", -> - atom.config.set('editor.fontSize', 1) - workspace.increaseFontSize() - expect(atom.config.get('editor.fontSize')).toBe 2 - workspace.increaseFontSize() - expect(atom.config.get('editor.fontSize')).toBe 3 - workspace.decreaseFontSize() - expect(atom.config.get('editor.fontSize')).toBe 2 - workspace.decreaseFontSize() - expect(atom.config.get('editor.fontSize')).toBe 1 - workspace.decreaseFontSize() - expect(atom.config.get('editor.fontSize')).toBe 1 - - describe "::openLicense()", -> - it "opens the license as plain-text in a buffer", -> - waitsForPromise -> workspace.openLicense() - runs -> expect(workspace.getActivePaneItem().getText()).toMatch /Copyright/ - - describe "::observeTextEditors()", -> - it "invokes the observer with current and future text editors", -> - observed = [] - - waitsForPromise -> workspace.open() - waitsForPromise -> workspace.open() - waitsForPromise -> workspace.openLicense() - - runs -> - workspace.observeTextEditors (editor) -> observed.push(editor) - - waitsForPromise -> workspace.open() - - expect(observed).toEqual workspace.getTextEditors() - - describe "when an editor is destroyed", -> - it "removes the editor", -> - editor = null - - waitsForPromise -> - workspace.open("a").then (e) -> editor = e - - runs -> - expect(workspace.getTextEditors()).toHaveLength 1 - editor.destroy() - expect(workspace.getTextEditors()).toHaveLength 0 - - it "stores the active grammars used by all the open editors", -> - waitsForPromise -> - atom.packages.activatePackage('language-javascript') - - waitsForPromise -> - atom.packages.activatePackage('language-coffee-script') - - waitsForPromise -> - atom.packages.activatePackage('language-todo') - - waitsForPromise -> - atom.workspace.open('sample.coffee') - - runs -> - atom.workspace.getActiveTextEditor().setText """ - i = /test/; #FIXME - """ - - state = atom.workspace.serialize() - expect(state.packagesWithActiveGrammars).toEqual ['language-coffee-script', 'language-javascript', 'language-todo'] - - jsPackage = atom.packages.getLoadedPackage('language-javascript') - coffeePackage = atom.packages.getLoadedPackage('language-coffee-script') - spyOn(jsPackage, 'loadGrammarsSync') - spyOn(coffeePackage, 'loadGrammarsSync') - - workspace2 = Workspace.deserialize(state) - expect(jsPackage.loadGrammarsSync.callCount).toBe 1 - expect(coffeePackage.loadGrammarsSync.callCount).toBe 1 - - describe "document.title", -> - describe "when the project has no path", -> - it "sets the title to 'untitled'", -> - atom.project.setPaths([]) - expect(document.title).toBe 'untitled - Atom' - - describe "when the project has a path", -> - beforeEach -> - waitsForPromise -> - atom.workspace.open('b') - - describe "when there is an active pane item", -> - it "sets the title to the pane item's title plus the project path", -> - item = atom.workspace.getActivePaneItem() - expect(document.title).toBe "#{item.getTitle()} - #{atom.project.getPaths()[0]} - Atom" - - describe "when the title of the active pane item changes", -> - it "updates the window title based on the item's new title", -> - editor = atom.workspace.getActivePaneItem() - editor.buffer.setPath(path.join(temp.dir, 'hi')) - expect(document.title).toBe "#{editor.getTitle()} - #{atom.project.getPaths()[0]} - Atom" - - describe "when the active pane's item changes", -> - it "updates the title to the new item's title plus the project path", -> - atom.workspace.getActivePane().activateNextItem() - item = atom.workspace.getActivePaneItem() - expect(document.title).toBe "#{item.getTitle()} - #{atom.project.getPaths()[0]} - Atom" - - describe "when the last pane item is removed", -> - it "updates the title to contain the project's path", -> - atom.workspace.getActivePane().destroy() - expect(atom.workspace.getActivePaneItem()).toBeUndefined() - expect(document.title).toBe "#{atom.project.getPaths()[0]} - Atom" - - describe "when an inactive pane's item changes", -> - it "does not update the title", -> - pane = atom.workspace.getActivePane() - pane.splitRight() - initialTitle = document.title - pane.activateNextItem() - expect(document.title).toBe initialTitle - - describe "when the workspace is deserialized", -> - beforeEach -> - waitsForPromise -> atom.workspace.open('a') - - it "updates the title to contain the project's path", -> - document.title = null - workspace2 = atom.workspace.testSerialization() - item = atom.workspace.getActivePaneItem() - expect(document.title).toBe "#{item.getTitle()} - #{atom.project.getPaths()[0]} - Atom" - workspace2.destroy() - - describe "document edited status", -> - [item1, item2] = [] - - beforeEach -> - waitsForPromise -> atom.workspace.open('a') - waitsForPromise -> atom.workspace.open('b') - runs -> - [item1, item2] = atom.workspace.getPaneItems() - spyOn(atom, 'setDocumentEdited') - - it "calls atom.setDocumentEdited when the active item changes", -> - expect(atom.workspace.getActivePaneItem()).toBe item2 - item1.insertText('a') - expect(item1.isModified()).toBe true - atom.workspace.getActivePane().activateNextItem() - - expect(atom.setDocumentEdited).toHaveBeenCalledWith(true) - - it "calls atom.setDocumentEdited when the active item's modified status changes", -> - expect(atom.workspace.getActivePaneItem()).toBe item2 - item2.insertText('a') - advanceClock(item2.getBuffer().getStoppedChangingDelay()) - - expect(item2.isModified()).toBe true - expect(atom.setDocumentEdited).toHaveBeenCalledWith(true) - - item2.undo() - advanceClock(item2.getBuffer().getStoppedChangingDelay()) - - expect(item2.isModified()).toBe false - expect(atom.setDocumentEdited).toHaveBeenCalledWith(false) - - describe "adding panels", -> - class TestItem - - class TestItemElement extends HTMLElement - constructor: -> - initialize: (@model) -> this - getModel: -> @model - - beforeEach -> - atom.views.addViewProvider TestItem, (model) -> - new TestItemElement().initialize(model) - - describe '::addLeftPanel(model)', -> - it 'adds a panel to the correct panel container', -> - expect(atom.workspace.getLeftPanels().length).toBe(0) - atom.workspace.panelContainers.left.onDidAddPanel addPanelSpy = jasmine.createSpy() - - model = new TestItem - panel = atom.workspace.addLeftPanel(item: model) - - expect(panel).toBeDefined() - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) - - itemView = atom.views.getView(atom.workspace.getLeftPanels()[0].getItem()) - expect(itemView instanceof TestItemElement).toBe(true) - expect(itemView.getModel()).toBe(model) - - describe '::addRightPanel(model)', -> - it 'adds a panel to the correct panel container', -> - expect(atom.workspace.getRightPanels().length).toBe(0) - atom.workspace.panelContainers.right.onDidAddPanel addPanelSpy = jasmine.createSpy() - - model = new TestItem - panel = atom.workspace.addRightPanel(item: model) - - expect(panel).toBeDefined() - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) - - itemView = atom.views.getView(atom.workspace.getRightPanels()[0].getItem()) - expect(itemView instanceof TestItemElement).toBe(true) - expect(itemView.getModel()).toBe(model) - - describe '::addTopPanel(model)', -> - it 'adds a panel to the correct panel container', -> - expect(atom.workspace.getTopPanels().length).toBe(0) - atom.workspace.panelContainers.top.onDidAddPanel addPanelSpy = jasmine.createSpy() - - model = new TestItem - panel = atom.workspace.addTopPanel(item: model) - - expect(panel).toBeDefined() - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) - - itemView = atom.views.getView(atom.workspace.getTopPanels()[0].getItem()) - expect(itemView instanceof TestItemElement).toBe(true) - expect(itemView.getModel()).toBe(model) - - describe '::addBottomPanel(model)', -> - it 'adds a panel to the correct panel container', -> - expect(atom.workspace.getBottomPanels().length).toBe(0) - atom.workspace.panelContainers.bottom.onDidAddPanel addPanelSpy = jasmine.createSpy() - - model = new TestItem - panel = atom.workspace.addBottomPanel(item: model) - - expect(panel).toBeDefined() - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) - - itemView = atom.views.getView(atom.workspace.getBottomPanels()[0].getItem()) - expect(itemView instanceof TestItemElement).toBe(true) - expect(itemView.getModel()).toBe(model) - - describe '::addModalPanel(model)', -> - it 'adds a panel to the correct panel container', -> - expect(atom.workspace.getModalPanels().length).toBe(0) - atom.workspace.panelContainers.modal.onDidAddPanel addPanelSpy = jasmine.createSpy() - - model = new TestItem - panel = atom.workspace.addModalPanel(item: model) - - expect(panel).toBeDefined() - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) - - itemView = atom.views.getView(atom.workspace.getModalPanels()[0].getItem()) - expect(itemView instanceof TestItemElement).toBe(true) - expect(itemView.getModel()).toBe(model) - - describe "::panelForItem(item)", -> - it "returns the panel associated with the item", -> - item = new TestItem - panel = atom.workspace.addLeftPanel(item: item) - - itemWithNoPanel = new TestItem - - expect(atom.workspace.panelForItem(item)).toBe panel - expect(atom.workspace.panelForItem(itemWithNoPanel)).toBe null - - describe "::scan(regex, options, callback)", -> - describe "when called with a regex", -> - it "calls the callback with all regex results in all files in the project", -> - results = [] - waitsForPromise -> - atom.workspace.scan /(a)+/, (result) -> - results.push(result) - - runs -> - expect(results).toHaveLength(3) - expect(results[0].filePath).toBe atom.project.getDirectories()[0]?.resolve('a') - expect(results[0].matches).toHaveLength(3) - expect(results[0].matches[0]).toEqual - matchText: 'aaa' - lineText: 'aaa bbb' - lineTextOffset: 0 - range: [[0, 0], [0, 3]] - - it "works with with escaped literals (like $ and ^)", -> - results = [] - waitsForPromise -> - atom.workspace.scan /\$\w+/, (result) -> results.push(result) - - runs -> - expect(results.length).toBe 1 - - {filePath, matches} = results[0] - expect(filePath).toBe atom.project.getDirectories()[0]?.resolve('a') - expect(matches).toHaveLength 1 - expect(matches[0]).toEqual - matchText: '$bill' - lineText: 'dollar$bill' - lineTextOffset: 0 - range: [[2, 6], [2, 11]] - - it "works on evil filenames", -> - platform.generateEvilFiles() - atom.project.setPaths([path.join(__dirname, 'fixtures', 'evil-files')]) - paths = [] - matches = [] - waitsForPromise -> - atom.workspace.scan /evil/, (result) -> - paths.push(result.filePath) - matches = matches.concat(result.matches) - - runs -> - _.each(matches, (m) -> expect(m.matchText).toEqual 'evil') - - if platform.isWindows() - expect(paths.length).toBe 3 - expect(paths[0]).toMatch /a_file_with_utf8.txt$/ - expect(paths[1]).toMatch /file with spaces.txt$/ - expect(path.basename(paths[2])).toBe "utfa\u0306.md" - else - expect(paths.length).toBe 5 - expect(paths[0]).toMatch /a_file_with_utf8.txt$/ - expect(paths[1]).toMatch /file with spaces.txt$/ - expect(paths[2]).toMatch /goddam\nnewlines$/m - expect(paths[3]).toMatch /quote".txt$/m - expect(path.basename(paths[4])).toBe "utfa\u0306.md" - - it "ignores case if the regex includes the `i` flag", -> - results = [] - waitsForPromise -> - atom.workspace.scan /DOLLAR/i, (result) -> results.push(result) - - runs -> - expect(results).toHaveLength 1 - - describe "when the core.excludeVcsIgnoredPaths config is truthy", -> - [projectPath, ignoredPath] = [] - - beforeEach -> - sourceProjectPath = path.join(__dirname, 'fixtures', 'git', 'working-dir') - projectPath = path.join(temp.mkdirSync("atom")) - - writerStream = fstream.Writer(projectPath) - fstream.Reader(sourceProjectPath).pipe(writerStream) - - waitsFor (done) -> - writerStream.on 'close', done - writerStream.on 'error', done - - runs -> - fs.rename(path.join(projectPath, 'git.git'), path.join(projectPath, '.git')) - ignoredPath = path.join(projectPath, 'ignored.txt') - fs.writeFileSync(ignoredPath, 'this match should not be included') - - afterEach -> - fs.removeSync(projectPath) if fs.existsSync(projectPath) - - it "excludes ignored files", -> - atom.project.setPaths([projectPath]) - atom.config.set('core.excludeVcsIgnoredPaths', true) - resultHandler = jasmine.createSpy("result found") - waitsForPromise -> - atom.workspace.scan /match/, (results) -> - resultHandler() - - runs -> - expect(resultHandler).not.toHaveBeenCalled() - - it "includes only files when a directory filter is specified", -> - projectPath = path.join(path.join(__dirname, 'fixtures', 'dir')) - atom.project.setPaths([projectPath]) - - filePath = path.join(projectPath, 'a-dir', 'oh-git') - - paths = [] - matches = [] - waitsForPromise -> - atom.workspace.scan /aaa/, paths: ["a-dir#{path.sep}"], (result) -> - paths.push(result.filePath) - matches = matches.concat(result.matches) - - runs -> - expect(paths.length).toBe 1 - expect(paths[0]).toBe filePath - expect(matches.length).toBe 1 - - it "includes files and folders that begin with a '.'", -> - projectPath = temp.mkdirSync() - filePath = path.join(projectPath, '.text') - fs.writeFileSync(filePath, 'match this') - atom.project.setPaths([projectPath]) - paths = [] - matches = [] - waitsForPromise -> - atom.workspace.scan /match this/, (result) -> - paths.push(result.filePath) - matches = matches.concat(result.matches) - - runs -> - expect(paths.length).toBe 1 - expect(paths[0]).toBe filePath - expect(matches.length).toBe 1 - - it "excludes values in core.ignoredNames", -> - projectPath = path.join(__dirname, 'fixtures', 'git', 'working-dir') - ignoredNames = atom.config.get("core.ignoredNames") - ignoredNames.push("a") - atom.config.set("core.ignoredNames", ignoredNames) - - resultHandler = jasmine.createSpy("result found") - waitsForPromise -> - atom.workspace.scan /dollar/, (results) -> - resultHandler() - - runs -> - expect(resultHandler).not.toHaveBeenCalled() - - it "scans buffer contents if the buffer is modified", -> - editor = null - results = [] - - waitsForPromise -> - atom.project.open('a').then (o) -> - editor = o - editor.setText("Elephant") - - waitsForPromise -> - atom.workspace.scan /a|Elephant/, (result) -> results.push result - - runs -> - expect(results).toHaveLength 3 - resultForA = _.find results, ({filePath}) -> path.basename(filePath) == 'a' - expect(resultForA.matches).toHaveLength 1 - expect(resultForA.matches[0].matchText).toBe 'Elephant' - - it "ignores buffers outside the project", -> - editor = null - results = [] - - waitsForPromise -> - atom.project.open(temp.openSync().path).then (o) -> - editor = o - editor.setText("Elephant") - - waitsForPromise -> - atom.workspace.scan /Elephant/, (result) -> results.push result - - runs -> - expect(results).toHaveLength 0 - - describe "::replace(regex, replacementText, paths, iterator)", -> - [filePath, commentFilePath, sampleContent, sampleCommentContent] = [] - - beforeEach -> - atom.project.setPaths([atom.project.getDirectories()[0]?.resolve('../')]) - - filePath = atom.project.getDirectories()[0]?.resolve('sample.js') - commentFilePath = atom.project.getDirectories()[0]?.resolve('sample-with-comments.js') - sampleContent = fs.readFileSync(filePath).toString() - sampleCommentContent = fs.readFileSync(commentFilePath).toString() - - afterEach -> - fs.writeFileSync(filePath, sampleContent) - fs.writeFileSync(commentFilePath, sampleCommentContent) - - describe "when a file doesn't exist", -> - it "calls back with an error", -> - errors = [] - missingPath = path.resolve('/not-a-file.js') - expect(fs.existsSync(missingPath)).toBeFalsy() - - waitsForPromise -> - atom.workspace.replace /items/gi, 'items', [missingPath], (result, error) -> - errors.push(error) - - runs -> - expect(errors).toHaveLength 1 - expect(errors[0].path).toBe missingPath - - describe "when called with unopened files", -> - it "replaces properly", -> - results = [] - waitsForPromise -> - atom.workspace.replace /items/gi, 'items', [filePath], (result) -> - results.push(result) - - runs -> - expect(results).toHaveLength 1 - expect(results[0].filePath).toBe filePath - expect(results[0].replacements).toBe 6 - - describe "when a buffer is already open", -> - it "replaces properly and saves when not modified", -> - editor = null - results = [] - - waitsForPromise -> - atom.project.open('sample.js').then (o) -> editor = o - - runs -> - expect(editor.isModified()).toBeFalsy() - - waitsForPromise -> - atom.workspace.replace /items/gi, 'items', [filePath], (result) -> - results.push(result) - - runs -> - expect(results).toHaveLength 1 - expect(results[0].filePath).toBe filePath - expect(results[0].replacements).toBe 6 - - expect(editor.isModified()).toBeFalsy() - - it "does not replace when the path is not specified", -> - editor = null - results = [] - - waitsForPromise -> - atom.project.open('sample-with-comments.js').then (o) -> editor = o - - waitsForPromise -> - atom.workspace.replace /items/gi, 'items', [commentFilePath], (result) -> - results.push(result) - - runs -> - expect(results).toHaveLength 1 - expect(results[0].filePath).toBe commentFilePath - - it "does NOT save when modified", -> - editor = null - results = [] - - waitsForPromise -> - atom.project.open('sample.js').then (o) -> editor = o - - runs -> - editor.buffer.setTextInRange([[0,0],[0,0]], 'omg') - expect(editor.isModified()).toBeTruthy() - - waitsForPromise -> - atom.workspace.replace /items/gi, 'okthen', [filePath], (result) -> - results.push(result) - - runs -> - expect(results).toHaveLength 1 - expect(results[0].filePath).toBe filePath - expect(results[0].replacements).toBe 6 - - expect(editor.isModified()).toBeTruthy() - - describe "::saveActivePaneItem()", -> - describe "when there is an error", -> - it "emits a warning notification when the file cannot be saved", -> - spyOn(Pane::, 'saveActiveItem').andCallFake -> - throw new Error("'/some/file' is a directory") - - atom.notifications.onDidAddNotification addedSpy = jasmine.createSpy() - atom.workspace.saveActivePaneItem() - expect(addedSpy).toHaveBeenCalled() - expect(addedSpy.mostRecentCall.args[0].getType()).toBe 'warning' - - it "emits a warning notification when the directory cannot be written to", -> - spyOn(Pane::, 'saveActiveItem').andCallFake -> - throw new Error("ENOTDIR, not a directory '/Some/dir/and-a-file.js'") - - atom.notifications.onDidAddNotification addedSpy = jasmine.createSpy() - atom.workspace.saveActivePaneItem() - expect(addedSpy).toHaveBeenCalled() - expect(addedSpy.mostRecentCall.args[0].getType()).toBe 'warning' - - it "emits a warning notification when the user does not have permission", -> - spyOn(Pane::, 'saveActiveItem').andCallFake -> - error = new Error("EACCES, permission denied '/Some/dir/and-a-file.js'") - error.code = 'EACCES' - error.path = '/Some/dir/and-a-file.js' - throw error - - atom.notifications.onDidAddNotification addedSpy = jasmine.createSpy() - atom.workspace.saveActivePaneItem() - expect(addedSpy).toHaveBeenCalled() - expect(addedSpy.mostRecentCall.args[0].getType()).toBe 'warning' - - it "emits a warning notification when the operation is not permitted", -> - spyOn(Pane::, 'saveActiveItem').andCallFake -> - error = new Error("EPERM, operation not permitted '/Some/dir/and-a-file.js'") - error.code = 'EPERM' - error.path = '/Some/dir/and-a-file.js' - throw error - - it "emits a warning notification when the file is already open by another app", -> - spyOn(Pane::, 'saveActiveItem').andCallFake -> - error = new Error("EBUSY, resource busy or locked '/Some/dir/and-a-file.js'") - error.code = 'EBUSY' - error.path = '/Some/dir/and-a-file.js' - throw error - - atom.notifications.onDidAddNotification addedSpy = jasmine.createSpy() - atom.workspace.saveActivePaneItem() - expect(addedSpy).toHaveBeenCalled() - - notificaiton = addedSpy.mostRecentCall.args[0] - expect(notificaiton.getType()).toBe 'warning' - expect(notificaiton.getMessage()).toContain 'Unable to save' - - it "emits a warning notification when the file system is read-only", -> - spyOn(Pane::, 'saveActiveItem').andCallFake -> - error = new Error("EROFS, read-only file system '/Some/dir/and-a-file.js'") - error.code = 'EROFS' - error.path = '/Some/dir/and-a-file.js' - throw error - - atom.notifications.onDidAddNotification addedSpy = jasmine.createSpy() - atom.workspace.saveActivePaneItem() - expect(addedSpy).toHaveBeenCalled() - - notification = addedSpy.mostRecentCall.args[0] - expect(notification.getType()).toBe 'warning' - expect(notification.getMessage()).toContain 'Unable to save' - - it "emits a warning notification when the file cannot be saved", -> - spyOn(Pane::, 'saveActiveItem').andCallFake -> - throw new Error("no one knows") - - save = -> atom.workspace.saveActivePaneItem() - expect(save).toThrow() diff --git a/src/browser/main.coffee b/src/browser/main.coffee index 527bf2dff..52f2657dc 100644 --- a/src/browser/main.coffee +++ b/src/browser/main.coffee @@ -144,9 +144,9 @@ parseCommandLine = -> # want to test. if test and toString.call(test) is "[object String]" if test is "core" - specDirectory = path.join(global.devResourcePath, "spec-nylas") + specDirectory = path.join(global.devResourcePath, "spec") else if test is "window" - specDirectory = path.join(global.devResourcePath, "spec-nylas") + specDirectory = path.join(global.devResourcePath, "spec") specsOnCommandLine = false else specDirectory = path.resolve(path.join(global.devResourcePath, "internal_packages", test)) diff --git a/src/browser/main.js b/src/browser/main.js index e29665568..46e82d057 100644 --- a/src/browser/main.js +++ b/src/browser/main.js @@ -158,9 +158,9 @@ } else { if (test && toString.call(test) === "[object String]") { if (test === "core") { - specDirectory = path.join(global.devResourcePath, "spec-nylas"); + specDirectory = path.join(global.devResourcePath, "spec"); } else if (test === "window") { - specDirectory = path.join(global.devResourcePath, "spec-nylas"); + specDirectory = path.join(global.devResourcePath, "spec"); specsOnCommandLine = false; } else { specDirectory = path.resolve(path.join(global.devResourcePath, "internal_packages", test)); diff --git a/src/flux/stores/database-store.coffee b/src/flux/stores/database-store.coffee index c432d6094..507df5945 100644 --- a/src/flux/stores/database-store.coffee +++ b/src/flux/stores/database-store.coffee @@ -7,7 +7,7 @@ Model = require '../models/model' Utils = require '../models/utils' Actions = require '../actions' ModelQuery = require '../models/query' -NylasStore = require 'nylas-store' +NylasStore = require '../../global/nylas-store' DatabaseSetupQueryBuilder = require './database-setup-query-builder' PriorityUICoordinator = require '../../priority-ui-coordinator' diff --git a/src/global/nylas-exports.coffee b/src/global/nylas-exports.coffee index 679bdc638..b66eb2d96 100644 --- a/src/global/nylas-exports.coffee +++ b/src/global/nylas-exports.coffee @@ -148,6 +148,6 @@ class NylasExports @get "APMWrapper", -> require('../apm-wrapper') # Testing - @get "NylasTestUtils", -> require '../../spec-nylas/test_utils' + @get "NylasTestUtils", -> require '../../spec/test_utils' module.exports = NylasExports diff --git a/src/package-manager.coffee b/src/package-manager.coffee index c8b2052dc..9613a1d93 100644 --- a/src/package-manager.coffee +++ b/src/package-manager.coffee @@ -38,7 +38,7 @@ class PackageManager @emitter = new Emitter @packageDirPaths = [] if @specMode - @packageDirPaths.push(path.join(@resourcePath, "spec-nylas", "fixtures", "packages")) + @packageDirPaths.push(path.join(@resourcePath, "spec", "fixtures", "packages")) else @packageDirPaths.push(path.join(@resourcePath, "internal_packages")) if not safeMode