Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Async-ify the specs #128

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Async-ify the specs
Bring in `async` compatible versions of `beforeEach` and `it` from the
`jasmine-fix` module and refactor the code accordingly.
  • Loading branch information
Arcanemagus committed Apr 10, 2017
commit a5f05fd4b26a97fc0bf12e0d3fe1ea21156d00a5
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"eslint": "^3.13.0",
"eslint-config-airbnb-base": "^11.0.1",
"eslint-plugin-import": "^2.2.0",
"jasmine-fix": "^1.0.1",
"remark-cli": "^3.0.0"
},
"eslintConfig": {
Expand Down
67 changes: 28 additions & 39 deletions spec/linter-markdown-spec.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,49 @@
'use babel';

import * as path from 'path';
// eslint-disable-next-line import/no-extraneous-dependencies
import { beforeEach, it } from 'jasmine-fix';
// NOTE: If using fit you must add it to the list above!

import * as lint from '..';

const validPath = path.join(__dirname, 'fixtures', 'definition-use-valid.md');
const invalidPath = path.join(__dirname, 'fixtures', 'definition-use-invalid.md');

describe('The remark-lint provider for Linter', () => {
beforeEach(() => {
beforeEach(async () => {
atom.workspace.destroyActivePaneItem();
waitsForPromise(() => {
atom.packages.activatePackage('linter-markdown');
return atom.packages.activatePackage('language-gfm').then(() =>
atom.workspace.open(path.join(__dirname, 'fixtures', 'definition-use-valid.md'))
);
});
await atom.packages.activatePackage('linter-markdown');
await atom.packages.activatePackage('language-gfm');
});

describe('checks a file with issues and', () => {
let editor = null;
const invalidPath = path.join(__dirname, 'fixtures', 'definition-use-invalid.md');
beforeEach(() => {
waitsForPromise(() =>
atom.workspace.open(invalidPath).then((openEditor) => { editor = openEditor; })
);
beforeEach(async () => {
editor = await atom.workspace.open(invalidPath);
});

it('finds at least one message', () => {
waitsForPromise(() =>
lint.provideLinter().lint(editor).then(messages =>
expect(messages.length).toBeGreaterThan(0)
)
);
it('finds at least one message', async () => {
const messages = await lint.provideLinter().lint(editor);
expect(messages.length).toBeGreaterThan(0);
});

it('verifies the first message', () => {
waitsForPromise(() =>
lint.provideLinter().lint(editor).then((messages) => {
expect(messages[0].type).toEqual('Warning');
expect(messages[0].text).not.toBeDefined();
expect(messages[0].html).toEqual(
'<span class="badge badge-flexible">remark-lint:' +
'no-unused-definitions</span> Found unused definition'
);
expect(messages[0].filePath).toMatch(/.+definition-use-invalid\.md$/);
expect(messages[0].range).toEqual([[2, 0], [2, 58]]);
})
it('verifies the first message', async () => {
const messages = await lint.provideLinter().lint(editor);
expect(messages[0].type).toEqual('Warning');
expect(messages[0].text).not.toBeDefined();
expect(messages[0].html).toEqual(
'<span class="badge badge-flexible">remark-lint:' +
'no-unused-definitions</span> Found unused definition'
);
expect(messages[0].filePath).toMatch(/.+definition-use-invalid\.md$/);
expect(messages[0].range).toEqual([[2, 0], [2, 58]]);
});
});

it('finds nothing wrong with a valid file', () => {
const validPath = path.join(__dirname, 'fixtures', 'definition-use-valid.md');
waitsForPromise(() =>
atom.workspace.open(validPath).then(editor =>
lint.provideLinter().lint(editor).then(messages =>
expect(messages.length).toBe(0)
)
)
);
it('finds nothing wrong with a valid file', async () => {
const editor = await atom.workspace.open(validPath);
const messages = await lint.provideLinter().lint(editor);
expect(messages.length).toBe(0);
});
});