This repository was archived by the owner on Feb 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.test.js
More file actions
50 lines (42 loc) · 1.33 KB
/
index.test.js
File metadata and controls
50 lines (42 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const traps = require('./index');
const expect = require('expect');
describe('Introductory traps', function () {
describe('getName', function () {
it('should return name', function () {
const name = traps.getName();
expect(name).toBe('John');
});
});
describe('getSequence', function () {
it('should return sequence of numbers', function () {
const sequence = traps.getSequence(3);
expect(sequence).toEqual([1, 2, 3]);
});
});
describe('getAdults', function () {
it('should return people older than 18 years separated by comma', function () {
const people = [
{firstName: 'John', surname: 'Smith', age: 30},
{firstName: 'Peter', surname: 'Pan', age: 12},
{firstName: 'Adriane', surname: 'Miller', age: 65}
];
const adults = traps.getAdults(people);
expect(adults).toBe('John Smith, Adriane Miller');
});
});
describe('fetchData', function () {
it('handle error properly', function (done) {
traps.fetchData('nonsense', function (err) {
expect(err).toBeA(Error);
done();
})
});
it('fetches data successfully', function (done) {
traps.fetchData(2, function (err, data) {
expect(data).toBeA('object');
expect(data).toInclude({title: 'king'});
done(err);
})
});
});
});