-
Notifications
You must be signed in to change notification settings - Fork 321
Expand file tree
/
Copy pathq04.spec.js
More file actions
26 lines (21 loc) · 756 Bytes
/
q04.spec.js
File metadata and controls
26 lines (21 loc) · 756 Bytes
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
import { expect } from 'chai';
import { findIndex, Listy } from './q04';
describe('ch10-q04: find index in listy', function () {
const listy = new Listy([2, 4, 5, 6, 19, 20, 50, 100]);
const result = findIndex(listy, 80);
it('Item between the existing items range but doesn\'t exist in listy', function () {
expect(result).to.be.eql(-1);
});
const result1 = findIndex(listy, 120);
it('Item bigger then any element in listy', function () {
expect(result1).to.be.eql(-1);
});
const result2 = findIndex(listy, 50);
it('Item 50 exists in listy', function () {
expect(result2).to.be.eql(6);
});
const result3 = findIndex(listy, 19);
it('Item 19 exists in listy', function () {
expect(result3).to.be.eql(4);
});
});