Skip to content

Commit

Permalink
Add custom error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilsson committed Mar 13, 2017
1 parent 2f5dd40 commit e44b25f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/specs/errors/lesshint-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

const LesshintError = require('../../../lib/errors/lesshint-error');
const expect = require('chai').expect;
const path = require('path');

describe('LesshintError', function () {
it('should handle an Error object', function () {
const message = 'Something went wrong';
const error = new Error(message);

const lesshintError = new LesshintError(error, '/path/to/file.less');

expect(lesshintError.message).to.equal(message);
});

it('should handle a a string', function () {
const message = 'Something went wrong';

const lesshintError = new LesshintError(message, '/path/to/file.less');

expect(lesshintError.message).to.equal(message);
});

it('should resolve paths', function () {
const file = 'file.less';
const errorPath = path.resolve(process.cwd(), file);

const lesshintError = new LesshintError('Something went wrong', file);

expect(lesshintError.path).to.equal(errorPath);
});
});
30 changes: 30 additions & 0 deletions test/specs/errors/runner-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

const RunnerError = require('../../../lib/errors/runner-error');
const expect = require('chai').expect;

describe('RunnerError', function () {
it('should handle an Error object', function () {
const message = 'Something went wrong';
const error = new Error(message);

const runnerError = new RunnerError(error, 1);

expect(runnerError.message).to.equal(message);
});

it('should handle a a string', function () {
const message = 'Something went wrong';

const runnerError = new RunnerError(message, 1);

expect(runnerError.message).to.equal(message);
});

it('should set the status', function () {
const status = 1;
const runnerError = new RunnerError('Something went wrong', status);

expect(runnerError.status).to.equal(status);
});
});

0 comments on commit e44b25f

Please sign in to comment.