Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update errors.spec.js #718

Merged
merged 2 commits into from
Feb 5, 2019
Merged
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
20 changes: 11 additions & 9 deletions tests/spec/errors.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var Filer = require('../../src');
var expect = require('chai').expect;
'use strict';

const Filer = require('../../src');
const expect = require('chai').expect;

describe('Filer.Errors', function() {
it('has expected errors', function() {
Expand Down Expand Up @@ -135,15 +137,15 @@ describe('Filer.Errors', function() {
});

it('should include all expected properties by default', function() {
var err = new Filer.Errors.ENOENT();
const err = new Filer.Errors.ENOENT();
expect(err.name).to.equal('ENOENT');
expect(err.code).to.equal('ENOENT');
expect(err.errno).to.equal(34);
expect(err.message).to.equal('no such file or directory');
});

it('should include extra properties when provided', function() {
var err = new Filer.Errors.ENOENT('This is the message', '/this/is/the/path');
const err = new Filer.Errors.ENOENT('This is the message', '/this/is/the/path');
expect(err.name).to.equal('ENOENT');
expect(err.code).to.equal('ENOENT');
expect(err.errno).to.equal(34);
Expand All @@ -152,29 +154,29 @@ describe('Filer.Errors', function() {
});

it('should include default message and path info when provided', function() {
var err = new Filer.Errors.ENOENT(null, '/this/is/the/path');
const err = new Filer.Errors.ENOENT(null, '/this/is/the/path');
expect(err.message).to.equal('no such file or directory');
expect(err.path).to.equal('/this/is/the/path');
});

it('should include just the message when no path provided', function() {
var err = new Filer.Errors.ENOENT();
const err = new Filer.Errors.ENOENT();
expect(err.message).to.equal('no such file or directory');
expect(err.path).not.to.exist;
});

it('should not include path in toString() when not provided', function() {
var err = new Filer.Errors.ENOENT('This is the message');
const err = new Filer.Errors.ENOENT('This is the message');
expect(err.toString()).to.equal('ENOENT: This is the message');
});

it('should include path in toString() when provided', function() {
var err = new Filer.Errors.ENOENT(null, '/this/is/the/path');
const err = new Filer.Errors.ENOENT(null, '/this/is/the/path');
expect(err.toString()).to.equal('ENOENT: no such file or directory, \'/this/is/the/path\'');
});

it('should include message and path info when provided', function() {
var err = new Filer.Errors.ENOENT('This is the message', '/this/is/the/path');
const err = new Filer.Errors.ENOENT('This is the message', '/this/is/the/path');
expect(err.message).to.equal('This is the message');
expect(err.path).to.equal('/this/is/the/path');
});
Expand Down