-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.ts
More file actions
28 lines (22 loc) · 719 Bytes
/
test.ts
File metadata and controls
28 lines (22 loc) · 719 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
27
28
import { expect } from 'chai';
import autocomplete from './index';
describe('autocomplete-string', () => {
it('returns an object', () => {
const res = autocomplete('', []);
expect(res).to.be.a('object');
expect(res).to.contain.keys('suggestion', 'suggestionIndex', 'completion');
});
it('returns the first matching suggestion with index', () => {
const { suggestion, suggestionIndex } = autocomplete('foo', [
'hello',
'foobar',
'foobaz'
]);
expect(suggestion).to.equal('foobar');
expect(suggestionIndex).to.equal(1);
});
it('returns completion string', () => {
const { completion } = autocomplete('foo', ['hello', 'foobar', 'foobaz']);
expect(completion).to.equal('bar');
});
});