Files
atom/spec/app/syntax-spec.coffee
Nathan Sobo f76bab512f Most recently added scoped properties win in case of a specificity tie
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.
2012-12-23 13:19:20 -07:00

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