mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Register style elements change events in AtomEnvironment.initialize
...and fix spec/workspace-element-spec.js
This commit is contained in:
@@ -230,28 +230,32 @@ describe('WorkspaceElement', () => {
|
||||
editorElement = editor.getElement()
|
||||
})
|
||||
|
||||
it("updates the font-size based on the 'editor.fontSize' config value", () => {
|
||||
it("updates the font-size based on the 'editor.fontSize' config value", async () => {
|
||||
const initialCharWidth = editor.getDefaultCharWidth()
|
||||
expect(getComputedStyle(editorElement).fontSize).toBe(atom.config.get('editor.fontSize') + 'px')
|
||||
|
||||
atom.config.set('editor.fontSize', atom.config.get('editor.fontSize') + 5)
|
||||
await editorElement.component.getNextUpdatePromise()
|
||||
expect(getComputedStyle(editorElement).fontSize).toBe(atom.config.get('editor.fontSize') + 'px')
|
||||
expect(editor.getDefaultCharWidth()).toBeGreaterThan(initialCharWidth)
|
||||
})
|
||||
|
||||
it("updates the font-family based on the 'editor.fontFamily' config value", () => {
|
||||
it("updates the font-family based on the 'editor.fontFamily' config value", async () => {
|
||||
const initialCharWidth = editor.getDefaultCharWidth()
|
||||
let fontFamily = atom.config.get('editor.fontFamily')
|
||||
expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily)
|
||||
|
||||
atom.config.set('editor.fontFamily', 'sans-serif')
|
||||
fontFamily = atom.config.get('editor.fontFamily')
|
||||
await editorElement.component.getNextUpdatePromise()
|
||||
expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily)
|
||||
expect(editor.getDefaultCharWidth()).not.toBe(initialCharWidth)
|
||||
})
|
||||
|
||||
it("updates the line-height based on the 'editor.lineHeight' config value", () => {
|
||||
it("updates the line-height based on the 'editor.lineHeight' config value", async () => {
|
||||
const initialLineHeight = editor.getLineHeightInPixels()
|
||||
atom.config.set('editor.lineHeight', '30px')
|
||||
await editorElement.component.getNextUpdatePromise()
|
||||
expect(getComputedStyle(editorElement).lineHeight).toBe(atom.config.get('editor.lineHeight'))
|
||||
expect(editor.getLineHeightInPixels()).not.toBe(initialLineHeight)
|
||||
})
|
||||
|
||||
@@ -250,6 +250,11 @@ class AtomEnvironment extends Model
|
||||
@attachSaveStateListeners()
|
||||
@windowEventHandler.initialize(@window, @document)
|
||||
|
||||
didChangeStyles = @didChangeStyles.bind(this)
|
||||
@disposables.add(@styles.onDidAddStyleElement(didChangeStyles))
|
||||
@disposables.add(@styles.onDidUpdateStyleElement(didChangeStyles))
|
||||
@disposables.add(@styles.onDidRemoveStyleElement(didChangeStyles))
|
||||
|
||||
@observeAutoHideMenuBar()
|
||||
|
||||
@history.initialize(@window.localStorage)
|
||||
@@ -697,11 +702,6 @@ class AtomEnvironment extends Model
|
||||
callback = => @applicationDelegate.didSaveWindowState()
|
||||
@saveState({isUnloading: true}).catch(callback).then(callback)
|
||||
|
||||
didChangeStyles = @didChangeStyles.bind(this)
|
||||
@disposables.add(@styles.onDidAddStyleElement(didChangeStyles))
|
||||
@disposables.add(@styles.onDidUpdateStyleElement(didChangeStyles))
|
||||
@disposables.add(@styles.onDidRemoveStyleElement(didChangeStyles))
|
||||
|
||||
@listenForUpdates()
|
||||
|
||||
@registerDefaultTargetForKeymaps()
|
||||
|
||||
Reference in New Issue
Block a user