Skip to content

Commit af655bb

Browse files
authored
Merge pull request #44 from unity-template:Genluo/issue43
test: 💍 针对Utils中的dom添加测试用例,提升测试覆盖度 (#43)
2 parents feaafdc + 76d6e49 commit af655bb

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

__test__/dom/lock.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { dom } from '../../src/index';
2+
3+
const { pageLock, unLockPage } = dom;
4+
5+
const recyclerview = document.createElement('div');
6+
recyclerview.setAttribute('id', 'recyclerview');
7+
8+
describe('test lock page', () => {
9+
afterAll(() => {
10+
document.body.innerHTML = '';
11+
});
12+
it('should lock page', () => {
13+
expect.assertions(2);
14+
pageLock();
15+
expect(document.body.style.height).toEqual('100%');
16+
expect(document.body.style.overflow).toEqual('hidden');
17+
});
18+
19+
it('should lock page in recyclerview', () => {
20+
document.body.appendChild(recyclerview);
21+
expect.assertions(2);
22+
pageLock();
23+
expect(recyclerview.style.height).toEqual('100%');
24+
expect(recyclerview.style.overflow).toEqual('hidden');
25+
});
26+
});
27+
28+
29+
describe('test unlock page', () => {
30+
afterAll(() => {
31+
document.body.innerHTML = '';
32+
});
33+
it('should unlock page', () => {
34+
expect.assertions(2);
35+
pageLock();
36+
expect(document.body.style.height).toEqual('100%');
37+
unLockPage();
38+
expect(document.body.style.height).toEqual('auto');
39+
});
40+
41+
42+
it('should unlock page in recyclerview', () => {
43+
document.body.appendChild(recyclerview);
44+
expect.assertions(2);
45+
pageLock();
46+
expect(recyclerview.style.height).toEqual('100%');
47+
unLockPage();
48+
expect(recyclerview.style.height).toEqual('auto');
49+
});
50+
});

0 commit comments

Comments
 (0)