Skip to content

Commit

Permalink
Refactor test from async to sync
Browse files Browse the repository at this point in the history
Reason for change: This test has been flaky on our CI due to its async
nature.

The expectation is for .build to construct TextEditor with the right
params.

We don't have to load the correct language package for this test. We can
load a dummy languageMode and assert that the correct grammar is set on
TextEditor
  • Loading branch information
sadick254 committed Sep 18, 2020
1 parent 2ac4204 commit c859f20
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions spec/text-editor-registry-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const TextEditor = require('../src/text-editor');
const TextBuffer = require('text-buffer');
const { Point, Range } = TextBuffer;
const dedent = require('dedent');
const NullGrammar = require('../src/null-grammar');

describe('TextEditorRegistry', function() {
let registry, editor, initialPackageActivation;
Expand Down Expand Up @@ -69,16 +70,24 @@ describe('TextEditorRegistry', function() {
});

describe('.build', function() {
it('constructs a TextEditor with the right parameters based on its path and text', async function() {
await atom.packages.activatePackage('language-javascript');
await atom.packages.activatePackage('language-c');

it('constructs a TextEditor with the right parameters based on its path and text', function() {
atom.config.set('editor.tabLength', 8, { scope: '.source.js' });

const languageMode = {
grammar: NullGrammar,
onDidChangeHighlighting: jasmine.createSpy()
};

const buffer = new TextBuffer({ filePath: 'test.js' });
buffer.setLanguageMode(languageMode);

const editor = registry.build({
buffer: new TextBuffer({ filePath: 'test.js' })
buffer
});

expect(editor.getTabLength()).toBe(8);
expect(editor.getGrammar()).toEqual(NullGrammar);
expect(languageMode.onDidChangeHighlighting.calls.length).toBe(1);
});
});

Expand Down

0 comments on commit c859f20

Please sign in to comment.