-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.es6
46 lines (40 loc) · 1.09 KB
/
test.es6
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
import assert from 'assert';
import { select, selectOne } from './';
describe('fp-select', () => {
const HTML = `
<ul data-foo="bar" class="fruits">
<li class="fruit">apple</li>
<li class="fruit">orange</li>
<li class="fruit">plum</li>
</ul>
`;
let fixture;
beforeEach(() => {
fixture = document.createElement('div');
fixture.innerHTML=HTML;
document.body.appendChild(fixture);
});
it('#select', () => {
assert.equal(select('.fruits').length, 1);
assert.equal(select('.fruits')[0].dataset.foo, 'bar');
assert.equal(select(fixture, '.fruits').length,1);
assert.equal(select(fixture, '.fruits')[0].dataset.foo, 'bar');
assert.equal(select(fixture)('.fruits').length,1);
try {
select(null);
assert.ok(false);
} catch (e) {
assert.ok(true);
}
});
it('#selectOne', () => {
assert.equal(selectOne('.fruits').dataset.foo, 'bar');
assert.equal(selectOne(fixture, '.fruits').dataset.foo, 'bar');
try {
selectOne(null);
assert.ok(false);
} catch (e) {
assert.ok(true);
}
});
});