-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraindrops.test.js
More file actions
74 lines (60 loc) · 2.04 KB
/
raindrops.test.js
File metadata and controls
74 lines (60 loc) · 2.04 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const chai = require('chai');
const expect = chai.expect;
const raindropSpeak = require('./raindrops');
describe('RaindropSpeak', () => {
describe('Handle invalid inputs', () => {
it('return undefined for 0', () => {
expect(raindropSpeak(0)).to.equal(undefined);
});
it('return undefined for decimal numbers', () => {
expect(raindropSpeak(17.56)).to.equal(undefined);
});
it('return undefined for string inputs', () => {
expect(raindropSpeak('tunmise')).to.equal(undefined);
expect(raindropSpeak('1234')).to.equal(undefined);
expect(raindropSpeak('')).to.equal(undefined);
});
it('return undefined for array inputs', () => {
expect(raindropSpeak([25, 367, 10])).to.equal(undefined);
expect(raindropSpeak([123])).to.equal(undefined);
expect(raindropSpeak([])).to.equal(undefined);
});
it('return undefined for object inputs', () => {
expect(raindropSpeak({ a: 123, b: 345 })).to.equal(undefined);
expect(raindropSpeak({})).to.equal(undefined);
});
it('return undefined for function inputs', () => {
expect(raindropSpeak(() => { return 123 })).to.equal(undefined);
});
});
describe('Handle valid inputs', () => {
it('returns Pling for 6', () => {
// Factors that contain 3
expect(raindropSpeak(6)).to.equal('Pling');
});
it('returns Plang for 10', () => {
// Factors that contain 5
expect(raindropSpeak(10)).to.equal('Plang');
});
it('returns Plong for 28', () => {
// Factors that contain 7
expect(raindropSpeak(28)).to.equal('Plong');
});
it('returns 34 for 34', () => {
// Factors that don't contain 3,5 and 7.
expect(raindropSpeak(34)).to.equal(34);
});
it('returns PlingPlang for 30', () => {
// Factors that contain 3 and 5
expect(raindropSpeak(30)).to.equal('PlingPlang');
});
it('returns PlingPlong for 42', () => {
// Factors that contain 3 and 7
expect(raindropSpeak(42)).to.equal('PlingPlong');
});
it('returns PlangPlong for 70', () => {
// Factors that contain 5 and 7
expect(raindropSpeak(70)).to.equal('PlangPlong');
});
});
});