-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.test.js
More file actions
58 lines (43 loc) · 1.21 KB
/
Copy pathexample.test.js
File metadata and controls
58 lines (43 loc) · 1.21 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
const getArea = require('./area.js')
test('more than 2 array elements', () => {
expect(getArea([2,3,4])).toBe(-1)
});
test('less than 2 array elements ', () => {
expect(getArea([4])).toBe(-1)
});
test('one array element is null', () => {
expect(getArea([2,null])).toBe(-1)
});
test('second array element is not a number', () => {
expect(getArea([2,'fdfd'])).toBe(-1)
});
test('first array element is not a number', () => {
expect(getArea(['fdfd',2])).toBe(-1)
});
test('correct area computation', () => {
expect(getArea([2,3])).toBe(6)
});
test('correct area computation with zeros', () => {
expect(getArea([0,3])).toBe(0)
});
test('one parameter is not an integer', () => {
expect(getArea([2.5,2])).toBe(-1)
});
test('one parameter is a string that is a number', () => {
expect(getArea(['1',2])).toBe(-1)
});
test('one parameter is undef', () => {
expect(getArea([0,])).toBe(-1)
});
test('parameter is an object', () => {
expect(getArea({a:1,b:2})).toBe(-1)
});
test('negative integers', () => {
expect(getArea([-2,6])).toBe(-1)
});
test('no pars', () => {
expect(getArea()).toBe(-1)
});
test('two pars instead of one', () => {
expect(getArea([2,3],5)).toBe(-1)
});