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

Asyncify the specs #165

Merged
merged 1 commit into from
Sep 22, 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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"devDependencies": {
"eslint": "^4.6.0",
"eslint-config-airbnb-base": "^12.0.0",
"eslint-plugin-import": "^2.7.0"
"eslint-plugin-import": "^2.7.0",
"jasmine-fix": "^1.3.1"
},
"eslintConfig": {
"rules": {
Expand Down
14 changes: 10 additions & 4 deletions spec/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
module.exports = {
globals: {
waitsForPromise: true
},
env: {
jasmine: true
atomtest: true,
jasmine: true,
},
rules: {
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
]
}
};
45 changes: 20 additions & 25 deletions spec/linter-htmlhint-spec.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
'use babel';

import * as path from 'path';
// eslint-disable-next-line no-unused-vars
import { it, fit, wait, beforeEach, afterEach } from 'jasmine-fix';

const { lint } = require('../lib/index.js').provideLinter();

describe('The htmlhint provider for Linter', () => {
beforeEach(() => {
beforeEach(async () => {
atom.workspace.destroyActivePaneItem();
waitsForPromise(() =>
Promise.all([
atom.packages.activatePackage('linter-htmlhint'),
atom.packages.activatePackage('language-html')
]));
await atom.packages.activatePackage('linter-htmlhint');
await atom.packages.activatePackage('language-html');
});

it('detects invalid coding style in bad.html and report as error', () => {
waitsForPromise(() => {
const bad = path.join(__dirname, 'fixtures', 'bad.html');
return atom.workspace.open(bad).then(editor => lint(editor)).then((messages) => {
expect(messages.length).toEqual(1);
it('detects invalid coding style in bad.html and report as error', async () => {
const bad = path.join(__dirname, 'fixtures', 'bad.html');
const editor = await atom.workspace.open(bad);
const messages = await lint(editor);

// test only the first error
expect(messages[0].type).toBe('error');
expect(messages[0].text).toBe('Doctype must be declared first.');
expect(messages[0].filePath).toBe(bad);
expect(messages[0].range).toEqual([[0, 0], [0, 5]]);
});
});
expect(messages.length).toEqual(1);
expect(messages[0].type).toBe('error');
expect(messages[0].text).toBe('Doctype must be declared first.');
expect(messages[0].filePath).toBe(bad);
expect(messages[0].range).toEqual([[0, 0], [0, 5]]);
});

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

expect(messages.length).toBe(0);
});
});