mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
This makes the scoped property system mimic the behavior of CSS. When there is a tie, the scoped properties loaded later in the cascade win. I also optimize the scanning of all the properties, checking only those sets of properties that have a value for the desired key path, to reduce the need to match a ton of scope selectors.
20 lines
1.2 KiB
CoffeeScript
20 lines
1.2 KiB
CoffeeScript
describe "the `syntax` global", ->
|
|
describe ".getProperty(scopeDescriptor)", ->
|
|
it "returns the property with the most specific scope selector", ->
|
|
syntax.addProperties(".source.coffee .string.quoted.double.coffee", foo: bar: baz: 42)
|
|
syntax.addProperties(".source .string.quoted.double", foo: bar: baz: 22)
|
|
syntax.addProperties(".source", foo: bar: baz: 11)
|
|
syntax.addProperties(foo: bar: baz: 1)
|
|
|
|
expect(syntax.getProperty([".source.coffee", ".string.quoted.double.coffee"], "foo.bar.baz")).toBe 42
|
|
expect(syntax.getProperty([".source.js", ".string.quoted.double.js"], "foo.bar.baz")).toBe 22
|
|
expect(syntax.getProperty([".source.js", ".variable.assignment.js"], "foo.bar.baz")).toBe 11
|
|
expect(syntax.getProperty([".text"], "foo.bar.baz")).toBe 1
|
|
|
|
it "favors the most recently added properties in the event of a specificity tie", ->
|
|
syntax.addProperties(".source.coffee .string.quoted.single", foo: bar: baz: 42)
|
|
syntax.addProperties(".source.coffee .string.quoted.double", foo: bar: baz: 22)
|
|
|
|
expect(syntax.getProperty([".source.coffee", ".string.quoted.single"], "foo.bar.baz")).toBe 42
|
|
expect(syntax.getProperty([".source.coffee", ".string.quoted.single.double"], "foo.bar.baz")).toBe 22
|