mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 21:57:55 +08:00
51602f69a5
Converted all references of global atom to NylasEnv Temporary rename atom.io find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.io/temporaryAtomIoReplacement/g' atom.config to NylasEnv.config find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.config/NylasEnv.config/g' atom.packages -> NylasEnv.packages atom.commands -> NylasEnv.commands atom.getLoadSettings find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.commands/NylasEnv.commands/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.getLoadSettings/NylasEnv.getLoadSettings/g' More common atom methods find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.styles/NylasEnv.styles/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.emitError/NylasEnv.emitError/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.inSpecMode/NylasEnv.inSpecMode/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.inDevMode/NylasEnv.inDevMode/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.getWindowType/NylasEnv.getWindowType/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.displayWindow/NylasEnv.displayWindow/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.quit/NylasEnv.quit/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.close/NylasEnv.close/g' More atom method changes find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.keymaps/NylasEnv.keymaps/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.hide/NylasEnv.hide/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.getCurrentWindow/NylasEnv.getCurrentWindow/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.menu/NylasEnv.menu/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.getConfigDirPath/NylasEnv.getConfigDirPath/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.isMainWindow/NylasEnv.isMainWindow/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.finishUnload/NylasEnv.finishUnload/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.isWorkWindow/NylasEnv.isWorkWindow/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.showSaveDialog/NylasEnv.showSaveDialog/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.append/NylasEnv.append/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.confirm/NylasEnv.confirm/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.clipboard/NylasEnv.clipboard/g' find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed -i "" 's/atom.getVersion/NylasEnv.getVersion/g' More atom renaming Rename atom methods More atom methods Fix grunt config variable Change atom.cmd to N1.cmd Rename atom.coffee and atom.js to nylas-env.coffee nylas-env.js Fix atom global reference in specs manually Fix atom requires Change engine from atom to nylas got rid of global/nylas-env rename to nylas-win-bootup Fix onWindowPropsChanged to onWindowPropsReceived fix nylas-workspace atom-text-editor to nylas-theme-wrap atom-text-editor -> nylas-theme-wrap Replacing atom keyword AtomWindow -> NylasWindow Replace Atom -> N1 Rename atom items nylas.asar -> atom.asar Remove more atom references Remove 6to5 references Remove license exception for atom
110 lines
4.6 KiB
CoffeeScript
110 lines
4.6 KiB
CoffeeScript
{$} = require '../src/space-pen-extensions'
|
|
path = require 'path'
|
|
Package = require '../src/package'
|
|
ThemePackage = require '../src/theme-package'
|
|
|
|
resolveFixturePath = (packagename) ->
|
|
path.join(__dirname, 'fixtures', 'packages', packagename)
|
|
|
|
describe "Package", ->
|
|
describe "when the package contains incompatible native modules", ->
|
|
beforeEach ->
|
|
spyOn(NylasEnv, 'inDevMode').andReturn(false)
|
|
|
|
it "does not activate it", ->
|
|
packagePath = resolveFixturePath('package-with-incompatible-native-module')
|
|
pack = new Package(packagePath)
|
|
expect(pack.isCompatible()).toBe false
|
|
expect(pack.incompatibleModules[0].name).toBe 'native-module'
|
|
expect(pack.incompatibleModules[0].path).toBe path.join(packagePath, 'node_modules', 'native-module')
|
|
|
|
it "caches the incompatible native modules in local storage", ->
|
|
packagePath = resolveFixturePath('package-with-incompatible-native-module')
|
|
cacheKey = null
|
|
cacheItem = null
|
|
|
|
spyOn(global.localStorage, 'setItem').andCallFake (key, item) ->
|
|
cacheKey = key
|
|
cacheItem = item
|
|
spyOn(global.localStorage, 'getItem').andCallFake (key) ->
|
|
return cacheItem if cacheKey is key
|
|
|
|
expect(new Package(packagePath).isCompatible()).toBe false
|
|
expect(global.localStorage.getItem.callCount).toBe 1
|
|
expect(global.localStorage.setItem.callCount).toBe 1
|
|
|
|
expect(new Package(packagePath).isCompatible()).toBe false
|
|
expect(global.localStorage.getItem.callCount).toBe 2
|
|
expect(global.localStorage.setItem.callCount).toBe 1
|
|
|
|
describe "theme", ->
|
|
theme = null
|
|
|
|
beforeEach ->
|
|
$("#jasmine-content").append $("<nylas-theme-wrap></nylas-theme-wrap>")
|
|
|
|
afterEach ->
|
|
theme.deactivate() if theme?
|
|
|
|
describe "when the theme contains a single style file", ->
|
|
it "loads and applies css", ->
|
|
expect($("nylas-theme-wrap").css("padding-bottom")).not.toBe "1234px"
|
|
themePath = resolveFixturePath('theme-with-index-css')
|
|
theme = new ThemePackage(themePath)
|
|
theme.activate()
|
|
expect($("nylas-theme-wrap").css("padding-top")).toBe "1234px"
|
|
|
|
it "parses, loads and applies less", ->
|
|
expect($("nylas-theme-wrap").css("padding-bottom")).not.toBe "1234px"
|
|
themePath = resolveFixturePath('theme-with-index-less')
|
|
theme = new ThemePackage(themePath)
|
|
theme.activate()
|
|
expect($("nylas-theme-wrap").css("padding-top")).toBe "4321px"
|
|
|
|
describe "when the theme contains a package.json file", ->
|
|
it "loads and applies stylesheets from package.json in the correct order", ->
|
|
expect($("nylas-theme-wrap").css("padding-top")).not.toBe("101px")
|
|
expect($("nylas-theme-wrap").css("padding-right")).not.toBe("102px")
|
|
expect($("nylas-theme-wrap").css("padding-bottom")).not.toBe("103px")
|
|
|
|
themePath = resolveFixturePath('theme-with-package-file')
|
|
theme = new ThemePackage(themePath)
|
|
theme.activate()
|
|
expect($("nylas-theme-wrap").css("padding-top")).toBe("101px")
|
|
expect($("nylas-theme-wrap").css("padding-right")).toBe("102px")
|
|
expect($("nylas-theme-wrap").css("padding-bottom")).toBe("103px")
|
|
|
|
describe "when the theme does not contain a package.json file and is a directory", ->
|
|
it "loads all stylesheet files in the directory", ->
|
|
expect($("nylas-theme-wrap").css("padding-top")).not.toBe "10px"
|
|
expect($("nylas-theme-wrap").css("padding-right")).not.toBe "20px"
|
|
expect($("nylas-theme-wrap").css("padding-bottom")).not.toBe "30px"
|
|
|
|
themePath = resolveFixturePath('theme-without-package-file')
|
|
theme = new ThemePackage(themePath)
|
|
theme.activate()
|
|
expect($("nylas-theme-wrap").css("padding-top")).toBe "10px"
|
|
expect($("nylas-theme-wrap").css("padding-right")).toBe "20px"
|
|
expect($("nylas-theme-wrap").css("padding-bottom")).toBe "30px"
|
|
|
|
describe "reloading a theme", ->
|
|
beforeEach ->
|
|
themePath = resolveFixturePath('theme-with-package-file')
|
|
theme = new ThemePackage(themePath)
|
|
theme.activate()
|
|
|
|
it "reloads without readding to the stylesheets list", ->
|
|
expect(theme.getStylesheetPaths().length).toBe 3
|
|
theme.reloadStylesheets()
|
|
expect(theme.getStylesheetPaths().length).toBe 3
|
|
|
|
describe "events", ->
|
|
beforeEach ->
|
|
themePath = resolveFixturePath('theme-with-package-file')
|
|
theme = new ThemePackage(themePath)
|
|
theme.activate()
|
|
|
|
it "deactivated event fires on .deactivate()", ->
|
|
theme.onDidDeactivate spy = jasmine.createSpy()
|
|
theme.deactivate()
|
|
expect(spy).toHaveBeenCalled()
|