mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Don't use atom.{config,styles} global in Package
This commit is contained in:
committed by
Nathan Sobo
parent
b7d6dd5e8c
commit
c192004b06
@@ -13,29 +13,29 @@ describe "Package", ->
|
||||
|
||||
it "does not activate it", ->
|
||||
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-incompatible-native-module')
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages)
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
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 "utilizes _atomModuleCache if present to determine the package's native dependencies", ->
|
||||
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-ignored-incompatible-native-module')
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages)
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
expect(pack.getNativeModuleDependencyPaths().length).toBe(1) # doesn't see the incompatible module
|
||||
expect(pack.isCompatible()).toBe true
|
||||
|
||||
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-cached-incompatible-native-module')
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages)
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
expect(pack.isCompatible()).toBe false
|
||||
|
||||
it "caches the incompatible native modules in local storage", ->
|
||||
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-incompatible-native-module')
|
||||
|
||||
expect(new Package(path: packagePath, packageManager: atom.packages).isCompatible()).toBe false
|
||||
expect(new Package(path: packagePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles).isCompatible()).toBe false
|
||||
expect(global.localStorage.getItem.callCount).toBe 1
|
||||
expect(global.localStorage.setItem.callCount).toBe 1
|
||||
|
||||
expect(new Package(path: packagePath, packageManager: atom.packages).isCompatible()).toBe false
|
||||
expect(new Package(path: packagePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles).isCompatible()).toBe false
|
||||
expect(global.localStorage.getItem.callCount).toBe 2
|
||||
expect(global.localStorage.setItem.callCount).toBe 1
|
||||
|
||||
@@ -49,7 +49,7 @@ describe "Package", ->
|
||||
|
||||
it "returns a promise resolving to the results of `apm rebuild`", ->
|
||||
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-index')
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages)
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
rebuildCallbacks = []
|
||||
spyOn(pack, 'runRebuildProcess').andCallFake ((callback) -> rebuildCallbacks.push(callback))
|
||||
|
||||
@@ -63,7 +63,7 @@ describe "Package", ->
|
||||
|
||||
it "persists build failures in local storage", ->
|
||||
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-index')
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages)
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
|
||||
expect(pack.isCompatible()).toBe true
|
||||
expect(pack.getBuildFailureOutput()).toBeNull()
|
||||
@@ -79,7 +79,7 @@ describe "Package", ->
|
||||
expect(pack.isCompatible()).toBe false
|
||||
|
||||
# A different package instance has the same failure output (simulates reload)
|
||||
pack2 = new Package(path: packagePath, packageManager: atom.packages)
|
||||
pack2 = new Package(path: packagePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
expect(pack2.getBuildFailureOutput()).toBe 'It is broken'
|
||||
expect(pack2.isCompatible()).toBe false
|
||||
|
||||
@@ -92,7 +92,7 @@ describe "Package", ->
|
||||
|
||||
it "sets cached incompatible modules to an empty array when the rebuild completes (there may be a build error, but rebuilding *deletes* native modules)", ->
|
||||
packagePath = atom.project.getDirectories()[0]?.resolve('packages/package-with-incompatible-native-module')
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages)
|
||||
pack = new Package(path: packagePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
|
||||
expect(pack.getIncompatibleNativeModules().length).toBeGreaterThan(0)
|
||||
|
||||
@@ -118,14 +118,14 @@ describe "Package", ->
|
||||
it "loads and applies css", ->
|
||||
expect(getComputedStyle(editorElement).paddingBottom).not.toBe "1234px"
|
||||
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-with-index-css')
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages)
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
theme.activate()
|
||||
expect(getComputedStyle(editorElement).paddingTop).toBe "1234px"
|
||||
|
||||
it "parses, loads and applies less", ->
|
||||
expect(getComputedStyle(editorElement).paddingBottom).not.toBe "1234px"
|
||||
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-with-index-less')
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages)
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
theme.activate()
|
||||
expect(getComputedStyle(editorElement).paddingTop).toBe "4321px"
|
||||
|
||||
@@ -136,7 +136,7 @@ describe "Package", ->
|
||||
expect(getComputedStyle(editorElement).paddingBottom).not.toBe("103px")
|
||||
|
||||
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-with-package-file')
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages)
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
theme.activate()
|
||||
expect(getComputedStyle(editorElement).paddingTop).toBe("101px")
|
||||
expect(getComputedStyle(editorElement).paddingRight).toBe("102px")
|
||||
@@ -149,7 +149,7 @@ describe "Package", ->
|
||||
expect(getComputedStyle(editorElement).paddingBottom).not.toBe "30px"
|
||||
|
||||
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-without-package-file')
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages)
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
theme.activate()
|
||||
expect(getComputedStyle(editorElement).paddingTop).toBe "10px"
|
||||
expect(getComputedStyle(editorElement).paddingRight).toBe "20px"
|
||||
@@ -158,7 +158,7 @@ describe "Package", ->
|
||||
describe "reloading a theme", ->
|
||||
beforeEach ->
|
||||
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-with-package-file')
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages)
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
theme.activate()
|
||||
|
||||
it "reloads without readding to the stylesheets list", ->
|
||||
@@ -169,7 +169,7 @@ describe "Package", ->
|
||||
describe "events", ->
|
||||
beforeEach ->
|
||||
themePath = atom.project.getDirectories()[0]?.resolve('packages/theme-with-package-file')
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages)
|
||||
theme = new ThemePackage(path: themePath, packageManager: atom.packages, config: atom.config, styleManager: atom.styles)
|
||||
theme.activate()
|
||||
|
||||
it "deactivated event fires on .deactivate()", ->
|
||||
|
||||
Reference in New Issue
Block a user