mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 04:48:44 +03:00
3a8fe2b24e
Previously, we were rendering every prefix of the dot-separated scope as its own class. So the scope meta.delimiter.method.period.coffee would make a token w/ classes: class="meta, meta-delimiter, meta-delimiter-method, meta-delimiter-method-period…" Now we just give the token each piece of the scope as a class: class="meta delimiter method period coffee" We lose a bit of meaning, in that a scope selector method.period.coffee would match this element in CSS even though it *wouldn't* in TextMate. But we also gain the behavior where longer prefixes are more specific by naturally producing more specific css selectors. So '.meta.delimiter.method' is always more specific than '.meta.delimiter', whereas '.meta-delimiter-method' ties with '.meta-delimiter'. If prefix ambiguities become a problem later we may need to revisit this approach, but I think it's good enough for now.
66 lines
2.0 KiB
CoffeeScript
66 lines
2.0 KiB
CoffeeScript
fs = require 'fs'
|
||
plist = require 'plist'
|
||
TextMateTheme = require 'text-mate-theme'
|
||
|
||
describe "TextMateTheme", ->
|
||
theme = null
|
||
beforeEach ->
|
||
theme = TextMateTheme.getTheme('Twilight')
|
||
|
||
describe "@getNames()", ->
|
||
it "returns an array of available theme names", ->
|
||
names = TextMateTheme.getNames()
|
||
expect(names).toContain("Twilight")
|
||
expect(names).toContain("Blackboard")
|
||
|
||
describe "@activate(name)", ->
|
||
it "activates a theme by name", ->
|
||
spyOn theme, 'activate'
|
||
TextMateTheme.activate('Twilight')
|
||
expect(theme.activate).toHaveBeenCalled()
|
||
|
||
describe ".activate()", ->
|
||
it "applies the theme's stylesheet to the current window", ->
|
||
spyOn window, 'applyStylesheet'
|
||
theme.activate()
|
||
expect(window.applyStylesheet).toHaveBeenCalledWith(theme.name, theme.getStylesheet())
|
||
|
||
describe ".getRulesets()", ->
|
||
rulesets = null
|
||
|
||
beforeEach ->
|
||
rulesets = theme.getRulesets()
|
||
|
||
it "returns rulesets representing the theme's global style settings", ->
|
||
expect(rulesets[0]).toEqual
|
||
selector: '.editor'
|
||
properties:
|
||
'background-color': '#141414'
|
||
'color': '#F8F8F8'
|
||
|
||
expect(rulesets[1]).toEqual
|
||
selector: '.editor.focused .cursor'
|
||
properties:
|
||
'border-color': '#A7A7A7'
|
||
|
||
expect(rulesets[2]).toEqual
|
||
selector: '.editor.focused .selection'
|
||
properties:
|
||
'background-color': "rgba(221, 240, 255, 0.2)"
|
||
|
||
it "returns an array of objects representing the theme's scope selectors", ->
|
||
expect(rulesets[11]).toEqual
|
||
comment: "Invalid – Deprecated"
|
||
selector: ".invalid.deprecated"
|
||
properties:
|
||
'color': "#D2A8A1"
|
||
# 'font-style': 'italic'
|
||
'text-decoration': 'underline'
|
||
|
||
expect(rulesets[12]).toEqual
|
||
comment: "Invalid – Illegal"
|
||
selector: ".invalid.illegal"
|
||
properties:
|
||
'color': "#F8F8F8"
|
||
'background-color': 'rgba(86, 45, 86, 0.75)'
|