-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.spec.ts
40 lines (33 loc) · 1.21 KB
/
index.spec.ts
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
import { BiDirectionalMap } from './index';
function expectAppleBanana(map: BiDirectionalMap<string, string>) {
expect(map.hasKey('a')).toBe(true);
expect(map.hasKey('b')).toBe(true);
expect(map.hasValue('apple')).toBe(true);
expect(map.hasValue('banana')).toBe(true);
expect(map.hasKey('o')).toBe(false);
expect(map.hasValue('orange')).toBe(false);
}
describe('BiDirectionalMap', () => {
it('should create map with entry array', () => {
const map = new BiDirectionalMap<string, string>([['a', 'apple'], ['b', 'banana']]);
expectAppleBanana(map);
});
it('should create map with js object', () => {
const map = new BiDirectionalMap<string, string>({ a: 'apple', b: 'banana' });
expectAppleBanana(map);
});
it('should create map with es6 map', () => {
const map = new BiDirectionalMap<string, string>(new Map([['a', 'apple'], ['b', 'banana']]));
expectAppleBanana(map);
});
it('should create empty map', () => {
const map = new BiDirectionalMap<string, string>();
expect(map.size).toBe(0);
});
it('should set entries', () => {
const map = new BiDirectionalMap<string, string>();
map.set('a', 'apple');
map.set('b', 'banana');
expectAppleBanana(map);
});
});