Add data-grammar to editor element

This commit is contained in:
Antonio Scandurra
2017-04-13 18:06:14 +02:00
parent 0a702d1680
commit 2a1ba7f05b
2 changed files with 18 additions and 0 deletions

View File

@@ -410,6 +410,17 @@ describe('TextEditorComponent', () => {
const {element} = buildComponent({placeholderText, text: ''})
expect(element.textContent).toContain(placeholderText)
})
it('adds the data-grammar attribute and updates it when the grammar changes', async () => {
await atom.packages.activatePackage('language-javascript')
const {editor, element, component} = buildComponent()
expect(element.dataset.grammar).toBe('text plain null-grammar')
editor.setGrammar(atom.grammars.grammarForScopeName('source.js'))
await component.getNextUpdatePromise()
expect(element.dataset.grammar).toBe('source js')
})
})
describe('mini editors', () => {