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

Commit

Permalink
Add specs
Browse files Browse the repository at this point in the history
Add some basic specs ensuring the linter is working.

Fixes #37.
  • Loading branch information
Arcanemagus committed Sep 22, 2016
1 parent f7e716c commit 787abf0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
6 changes: 6 additions & 0 deletions spec/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
env: {
jasmine: true,
atomtest: true
}
};
4 changes: 0 additions & 4 deletions spec/fixtures/test_warnings.pp

This file was deleted.

51 changes: 51 additions & 0 deletions spec/linter-puppet-lint-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use babel';

import * as path from 'path';

const cleanPath = path.join(__dirname, 'fixtures', 'test_clean.pp');
const errorsPath = path.join(__dirname, 'fixtures', 'test_errors.pp');

describe('The puppet-lint provider for Linter', () => {
const lint = require(path.join('..', 'lib', 'main.js')).provideLinter().lint;

beforeEach(() => {
atom.workspace.destroyActivePaneItem();

waitsForPromise(() =>
Promise.all([
atom.packages.activatePackage('linter-puppet-lint'),
atom.packages.activatePackage('language-puppet'),
])
);
});

it('finds nothing wrong with a valid file', () => {
waitsForPromise(() =>
atom.workspace.open(cleanPath).then(editor => lint(editor)).then((messages) => {
expect(messages.length).toBe(0);
})
);
});

it('handles messages from puppet-lint', () => {
waitsForPromise(() =>
atom.workspace.open(errorsPath).then(editor => lint(editor)).then((messages) => {
expect(messages.length).toBe(2);

expect(messages[0].type).toBe('error');
expect(messages[0].severity).toBe('error');
expect(messages[0].html).not.toBeDefined();
expect(messages[0].text).toBe('does_not::exist not in autoload module layout');
expect(messages[0].filePath).toBe(errorsPath);
expect(messages[0].range).toEqual([[0, 6], [0, 14]]);

expect(messages[1].type).toBe('warning');
expect(messages[1].severity).toBe('warning');
expect(messages[1].html).not.toBeDefined();
expect(messages[1].text).toBe('class not documented');
expect(messages[1].filePath).toBe(errorsPath);
expect(messages[1].range).toEqual([[0, 0], [0, 5]]);
})
);
});
});

0 comments on commit 787abf0

Please sign in to comment.