From 2b0aa7d176bafc9c3cf1c60b9b33e9f6c44b992a Mon Sep 17 00:00:00 2001 From: Scott Bronson Date: Wed, 3 Jan 2018 13:14:40 -0800 Subject: [PATCH] add tests for the tooltip --- spec/grammar-selector-spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/grammar-selector-spec.js b/spec/grammar-selector-spec.js index 07f0a42..042ecb6 100644 --- a/spec/grammar-selector-spec.js +++ b/spec/grammar-selector-spec.js @@ -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 () => { @@ -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() @@ -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') }) ) @@ -187,3 +191,9 @@ describe('GrammarSelector', () => { ) }) }) + +function getTooltipText (element) { + debugger + const [tooltip] = atom.tooltips.findTooltips(element) + return tooltip.getTitle() +}