mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-08 16:19:17 +03:00
d3371dbcd2
This will take over raw stylesheet management from the theme manager now that it’s becoming more complex with the need to target specific host elements. Instead of actually adding nodes to the head of the document, it will instead simply manage a set of stylesheets we want to apply and leave actual DOM manipulation to <atom-styles> custom elements that can render the set of active stylesheets in the appropriate locations.
30 lines
1017 B
CoffeeScript
30 lines
1017 B
CoffeeScript
StyleManager = require '../src/style-manager'
|
|
|
|
describe "StyleManager", ->
|
|
manager = null
|
|
|
|
beforeEach ->
|
|
manager = new StyleManager
|
|
|
|
describe "::addStyleSheet(source, params)", ->
|
|
it "adds a stylesheet based on the given source and returns a disposable allowing it to be removed", ->
|
|
addEvents = []
|
|
removeEvents = []
|
|
manager.onDidAddStyleSheet (event) -> addEvents.push(event)
|
|
manager.onDidRemoveStyleSheet (event) -> removeEvents.push(event)
|
|
|
|
disposable = manager.addStyleSheet("a {color: red;}")
|
|
|
|
expect(addEvents.length).toBe 1
|
|
expect(addEvents[0].styleElement.textContent).toBe "a {color: red;}"
|
|
|
|
styleElements = manager.getStyleElements()
|
|
expect(styleElements.length).toBe 1
|
|
expect(styleElements[0].textContent).toBe "a {color: red;}"
|
|
|
|
disposable.dispose()
|
|
|
|
expect(removeEvents.length).toBe 1
|
|
expect(removeEvents[0].styleElement.textContent).toBe "a {color: red;}"
|
|
expect(manager.getStyleElements().length).toBe 0
|