-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathallergies.spec.js
65 lines (53 loc) · 2.09 KB
/
allergies.spec.js
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
import { Allergies } from './allergies';
describe('Allergies', () => {
test('no allergies at all', () => {
const allergies = new Allergies(0);
expect(allergies.list()).toEqual([]);
});
test('allergies to eggs', () => {
const allergies = new Allergies(1);
expect(allergies.list()).toEqual(['eggs']);
});
test('allergies to peanuts', () => {
const allergies = new Allergies(2);
expect(allergies.list()).toEqual(['peanuts']);
});
test('allergies to strawberries', () => {
const allergies = new Allergies(8);
expect(allergies.list()).toEqual(['strawberries']);
});
test('allergies to eggs and peanuts', () => {
const allergies = new Allergies(3);
expect(allergies.list()).toEqual(['eggs', 'peanuts']);
});
test('allergies to more than eggs but not peanuts', () => {
const allergies = new Allergies(5);
expect(allergies.list()).toEqual(['eggs', 'shellfish']);
});
test('allergic to lots of stuff', () => {
const allergies = new Allergies(248);
expect(allergies.list()).toEqual(['strawberries', 'tomatoes', 'chocolate', 'pollen', 'cats']);
});
test('allergic to everything', () => {
const allergies = new Allergies(255);
expect(allergies.list()).toEqual(['eggs', 'peanuts', 'shellfish', 'strawberries', 'tomatoes', 'chocolate', 'pollen', 'cats']);
});
test('no allergic means not allergic', () => {
const allergies = new Allergies(0);
expect(allergies.allergicTo('peanuts')).toEqual(false);
expect(allergies.allergicTo('cats')).toEqual(false);
expect(allergies.allergicTo('strawberries')).toEqual(false);
});
test('allergic to eggs', () => {
const allergies = new Allergies(1);
expect(allergies.allergicTo('eggs')).toEqual(true);
});
test('allergic to eggs and other things', () => {
const allergies = new Allergies(5);
expect(allergies.allergicTo('eggs')).toEqual(true);
});
test('ignore non allergen score parts', () => {
const allergies = new Allergies(509);
expect(allergies.list()).toEqual(['eggs', 'shellfish', 'strawberries', 'tomatoes', 'chocolate', 'pollen', 'cats']);
});
});