Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Add groups to test suite
  • Loading branch information
Marc Littlemore committed Aug 8, 2017
commit c606be2bb44ad03682b627701211fb2e96ba66ba
62 changes: 35 additions & 27 deletions test/day2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,53 @@ import {expect} from 'chai';
import day2 from '../src/day2';

describe('day2 tests', () => {
it('should return undefined when no parameters are passed', () => {
expect(day2()).to.be.undefined;
});
describe('check data type', () => {
it('should return undefined when no parameters are passed', () => {
expect(day2()).to.be.undefined;
});

it('should return a string when a string is passed', () => {
expect(day2('a string')).to.be.a('string');
});
it('should return a string when a string is passed', () => {
expect(day2('a string')).to.be.a('string');
});

it('should return a number when a number is passed', () => {
expect(day2(10)).to.be.a('Number');
});
it('should return a number when a number is passed', () => {
expect(day2(10)).to.be.a('Number');
});

it('should not be a string when a number is passed', () => {
expect(day2(10)).to.not.be.a('string');
it('should not be a string when a number is passed', () => {
expect(day2(10)).to.not.be.a('string');
});
});

it('should equal the string passed', () => {
expect(day2('same string')).to.equal('same string');
});
describe('checking equals', () => {
it('should equal the string passed', () => {
expect(day2('same string')).to.equal('same string');
});

it('should deep equal the object passed', () => {
const givenObject = {
hello: 'world'
};
it('should deep equal the object passed', () => {
const givenObject = {
hello: 'world'
};

expect(day2(givenObject)).to.deep.equal(givenObject);
expect(day2(givenObject)).to.deep.equal(givenObject);
});
});

it('should contain part of the string passed', () => {
const givenString = 'hello world';
describe('checking contains', () => {
it('should contain part of the string passed', () => {
const givenString = 'hello world';

expect(day2(givenString)).to.contain('world');
expect(day2(givenString)).to.contain('world');
});
});

it('should throw an error when "error" is passed', () => {
function wrappedFunction() {
day2('error');
}
describe('checking errors', () => {
it('should throw an error when "error" is passed', () => {
function wrappedFunction() {
day2('error');
}

expect(wrappedFunction).to.throw('Cannot pass error');
expect(wrappedFunction).to.throw('Cannot pass error');
});
});
});