mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
@@ -20,13 +20,34 @@ describe "@load(name)", ->
|
||||
expect($(".editor").css("background-color")).toBe("rgb(20, 20, 20)")
|
||||
|
||||
describe "AtomTheme", ->
|
||||
it "Loads and applies css from package.json in the correct order", ->
|
||||
expect($(".editor").css("padding-top")).not.toBe("101px")
|
||||
expect($(".editor").css("padding-right")).not.toBe("102px")
|
||||
expect($(".editor").css("padding-bottom")).not.toBe("103px")
|
||||
describe "when the theme contains a package.json file", ->
|
||||
it "loads and applies css from package.json in the correct order", ->
|
||||
expect($(".editor").css("padding-top")).not.toBe("101px")
|
||||
expect($(".editor").css("padding-right")).not.toBe("102px")
|
||||
expect($(".editor").css("padding-bottom")).not.toBe("103px")
|
||||
|
||||
themePath = require.resolve(fs.join('fixtures', 'test-atom-theme'))
|
||||
theme = Theme.load(themePath)
|
||||
expect($(".editor").css("padding-top")).toBe("101px")
|
||||
expect($(".editor").css("padding-right")).toBe("102px")
|
||||
expect($(".editor").css("padding-bottom")).toBe("103px")
|
||||
themePath = fixturesProject.resolve('themes/theme-with-package-file')
|
||||
theme = Theme.load(themePath)
|
||||
expect($(".editor").css("padding-top")).toBe("101px")
|
||||
expect($(".editor").css("padding-right")).toBe("102px")
|
||||
expect($(".editor").css("padding-bottom")).toBe("103px")
|
||||
|
||||
describe "when the theme is a CSS file", ->
|
||||
it "loads and applies the stylesheet", ->
|
||||
expect($(".editor").css("padding-bottom")).not.toBe "1234px"
|
||||
|
||||
themePath = fixturesProject.resolve('themes/theme-stylesheet.css')
|
||||
theme = Theme.load(themePath)
|
||||
expect($(".editor").css("padding-top")).toBe "1234px"
|
||||
|
||||
describe "when the theme does not contain a package.json file and is a directory", ->
|
||||
it "loads all CSS files in the directory", ->
|
||||
expect($(".editor").css("padding-top")).not.toBe "10px"
|
||||
expect($(".editor").css("padding-right")).not.toBe "20px"
|
||||
expect($(".editor").css("padding-bottom")).not.toBe "30px"
|
||||
|
||||
themePath = fixturesProject.resolve('themes/theme-without-package-file')
|
||||
theme = Theme.load(themePath)
|
||||
expect($(".editor").css("padding-top")).toBe "10px"
|
||||
expect($(".editor").css("padding-right")).toBe "20px"
|
||||
expect($(".editor").css("padding-bottom")).toBe "30px"
|
||||
|
||||
3
spec/fixtures/themes/theme-stylesheet.css
vendored
Normal file
3
spec/fixtures/themes/theme-stylesheet.css
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.editor {
|
||||
padding-top: 1234px;
|
||||
}
|
||||
5
spec/fixtures/themes/theme-without-package-file/a.css
vendored
Normal file
5
spec/fixtures/themes/theme-without-package-file/a.css
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
.editor {
|
||||
padding-top: 10px;
|
||||
padding-right: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
4
spec/fixtures/themes/theme-without-package-file/b.css
vendored
Normal file
4
spec/fixtures/themes/theme-without-package-file/b.css
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.editor {
|
||||
padding-right: 20px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
3
spec/fixtures/themes/theme-without-package-file/c.css
vendored
Normal file
3
spec/fixtures/themes/theme-without-package-file/c.css
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.editor {
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
5
spec/fixtures/themes/theme-without-package-file/d.csv
vendored
Normal file
5
spec/fixtures/themes/theme-without-package-file/d.csv
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
.editor {
|
||||
padding-top: 100px;
|
||||
padding-right: 100px;
|
||||
padding-bottom: 100px;
|
||||
}
|
||||
|
@@ -12,6 +12,11 @@ class AtomTheme extends Theme
|
||||
@loadStylesheet(@path)
|
||||
else
|
||||
metadataPath = fs.resolveExtension(fs.join(@path, 'package'), ['cson', 'json'])
|
||||
stylesheetNames = fs.readObject(metadataPath).stylesheets
|
||||
@loadStylesheet(fs.join(@path, name)) for name in stylesheetNames
|
||||
if fs.isFile(metadataPath)
|
||||
stylesheetNames = fs.readObject(metadataPath)?.stylesheets
|
||||
if stylesheetNames
|
||||
@loadStylesheet(fs.join(@path, name)) for name in stylesheetNames
|
||||
else
|
||||
@loadStylesheet(stylesheetPath) for stylesheetPath in fs.list(@path, ['.css'])
|
||||
|
||||
super
|
||||
|
||||
Reference in New Issue
Block a user