Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

Commit

Permalink
add tests for the tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
bronson committed Jan 3, 2018
1 parent bd2c05d commit 2b0aa7d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spec/grammar-selector-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ describe('GrammarSelector', () => {

it('displays the name of the current grammar', () => {
expect(grammarStatus.querySelector('a').textContent).toBe('JavaScript')
expect(getTooltipText(grammarStatus)).toBe('File uses the JavaScript grammar')
})

it('displays Plain Text when the current grammar is the null grammar', async () => {
Expand All @@ -122,6 +123,7 @@ describe('GrammarSelector', () => {

expect(grammarStatus.querySelector('a').textContent).toBe('Plain Text')
expect(grammarStatus).toBeVisible()
expect(getTooltipText(grammarStatus)).toBe('File uses the Plain Text grammar')

editor.setGrammar(atom.grammars.grammarForScopeName('source.js'))
await atom.views.getNextUpdatePromise()
Expand Down Expand Up @@ -161,11 +163,13 @@ describe('GrammarSelector', () => {
await atom.views.getNextUpdatePromise()

expect(grammarStatus.querySelector('a').textContent).toBe('Plain Text')
expect(getTooltipText(grammarStatus)).toBe('File uses the Plain Text grammar')

editor.setGrammar(atom.grammars.grammarForScopeName('source.a'))
await atom.views.getNextUpdatePromise()

expect(grammarStatus.querySelector('a').textContent).toBe('source.a')
expect(getTooltipText(grammarStatus)).toBe('File uses the source.a grammar')
})
)

Expand All @@ -187,3 +191,9 @@ describe('GrammarSelector', () => {
)
})
})

function getTooltipText (element) {
debugger
const [tooltip] = atom.tooltips.findTooltips(element)
return tooltip.getTitle()
}

0 comments on commit 2b0aa7d

Please sign in to comment.