Skip to content

Commit c606be2

Browse files
author
Marc Littlemore
committed
Add groups to test suite
1 parent 1691f7e commit c606be2

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

test/day2.test.js

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,53 @@ import {expect} from 'chai';
22
import day2 from '../src/day2';
33

44
describe('day2 tests', () => {
5-
it('should return undefined when no parameters are passed', () => {
6-
expect(day2()).to.be.undefined;
7-
});
5+
describe('check data type', () => {
6+
it('should return undefined when no parameters are passed', () => {
7+
expect(day2()).to.be.undefined;
8+
});
89

9-
it('should return a string when a string is passed', () => {
10-
expect(day2('a string')).to.be.a('string');
11-
});
10+
it('should return a string when a string is passed', () => {
11+
expect(day2('a string')).to.be.a('string');
12+
});
1213

13-
it('should return a number when a number is passed', () => {
14-
expect(day2(10)).to.be.a('Number');
15-
});
14+
it('should return a number when a number is passed', () => {
15+
expect(day2(10)).to.be.a('Number');
16+
});
1617

17-
it('should not be a string when a number is passed', () => {
18-
expect(day2(10)).to.not.be.a('string');
18+
it('should not be a string when a number is passed', () => {
19+
expect(day2(10)).to.not.be.a('string');
20+
});
1921
});
2022

21-
it('should equal the string passed', () => {
22-
expect(day2('same string')).to.equal('same string');
23-
});
23+
describe('checking equals', () => {
24+
it('should equal the string passed', () => {
25+
expect(day2('same string')).to.equal('same string');
26+
});
2427

25-
it('should deep equal the object passed', () => {
26-
const givenObject = {
27-
hello: 'world'
28-
};
28+
it('should deep equal the object passed', () => {
29+
const givenObject = {
30+
hello: 'world'
31+
};
2932

30-
expect(day2(givenObject)).to.deep.equal(givenObject);
33+
expect(day2(givenObject)).to.deep.equal(givenObject);
34+
});
3135
});
3236

33-
it('should contain part of the string passed', () => {
34-
const givenString = 'hello world';
37+
describe('checking contains', () => {
38+
it('should contain part of the string passed', () => {
39+
const givenString = 'hello world';
3540

36-
expect(day2(givenString)).to.contain('world');
41+
expect(day2(givenString)).to.contain('world');
42+
});
3743
});
3844

39-
it('should throw an error when "error" is passed', () => {
40-
function wrappedFunction() {
41-
day2('error');
42-
}
45+
describe('checking errors', () => {
46+
it('should throw an error when "error" is passed', () => {
47+
function wrappedFunction() {
48+
day2('error');
49+
}
4350

44-
expect(wrappedFunction).to.throw('Cannot pass error');
51+
expect(wrappedFunction).to.throw('Cannot pass error');
52+
});
4553
});
4654
});

0 commit comments

Comments
 (0)