1fb726d48Sopenharmony_ci/*
2fb726d48Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
3fb726d48Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fb726d48Sopenharmony_ci * you may not use this file except in compliance with the License.
5fb726d48Sopenharmony_ci * You may obtain a copy of the License at
6fb726d48Sopenharmony_ci *
7fb726d48Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fb726d48Sopenharmony_ci *
9fb726d48Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fb726d48Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fb726d48Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fb726d48Sopenharmony_ci * See the License for the specific language governing permissions and
13fb726d48Sopenharmony_ci * limitations under the License.
14fb726d48Sopenharmony_ci */
15fb726d48Sopenharmony_ciimport {PageNation} from '../../../../src/base-ui/chart/pagenation/PageNation';
16fb726d48Sopenharmony_ciimport {PaginationBox} from '../../../../src/base-ui/chart/pagenation/PaginationBox';
17fb726d48Sopenharmony_ci
18fb726d48Sopenharmony_ci// @ts-ignore
19fb726d48Sopenharmony_ciwindow.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({
20fb726d48Sopenharmony_ci    disconnect: jest.fn(),
21fb726d48Sopenharmony_ci    observe: jest.fn(),
22fb726d48Sopenharmony_ci    unobserve: jest.fn(),
23fb726d48Sopenharmony_ci}));
24fb726d48Sopenharmony_ci
25fb726d48Sopenharmony_cidescribe('PageNation Test', () => {
26fb726d48Sopenharmony_ci    it('pageNationTest01', function () {
27fb726d48Sopenharmony_ci        document.body.innerHTML = `
28fb726d48Sopenharmony_ci        <pagination-box id="pagination-info"></pagination-box> `;
29fb726d48Sopenharmony_ci        let pageInfo = document.getElementById('pagination-info') as PaginationBox;
30fb726d48Sopenharmony_ci        let pageNation = new PageNation(pageInfo, {
31fb726d48Sopenharmony_ci            current: 1,
32fb726d48Sopenharmony_ci            totalpage: 9,
33fb726d48Sopenharmony_ci            pageSize: 50,
34fb726d48Sopenharmony_ci            change(num: number) {},
35fb726d48Sopenharmony_ci        });
36fb726d48Sopenharmony_ci        expect(pageNation).not.toBeUndefined();
37fb726d48Sopenharmony_ci    });
38fb726d48Sopenharmony_ci
39fb726d48Sopenharmony_ci    it('pageNationTest01', function () {
40fb726d48Sopenharmony_ci        document.body.innerHTML = `
41fb726d48Sopenharmony_ci        <pagination-box id="pagination-info"></pagination-box> `;
42fb726d48Sopenharmony_ci        let pageInfo = document.getElementById('pagination-info') as PaginationBox;
43fb726d48Sopenharmony_ci        let pageNation = new PageNation(pageInfo, {
44fb726d48Sopenharmony_ci            current: 1,
45fb726d48Sopenharmony_ci            totalpage: 200,
46fb726d48Sopenharmony_ci            pageSize: 50,
47fb726d48Sopenharmony_ci            change(num: number) {},
48fb726d48Sopenharmony_ci        });
49fb726d48Sopenharmony_ci        expect(pageNation.pageInfo.current).toEqual(1);
50fb726d48Sopenharmony_ci    });
51fb726d48Sopenharmony_ci
52fb726d48Sopenharmony_ci    it('pageNationTest02', function () {
53fb726d48Sopenharmony_ci        document.body.innerHTML = `
54fb726d48Sopenharmony_ci        <pagination-box id="pagination-info"></pagination-box> `;
55fb726d48Sopenharmony_ci        let pageInfo = document.getElementById('pagination-info') as PaginationBox;
56fb726d48Sopenharmony_ci        let pageNation = new PageNation(pageInfo, {
57fb726d48Sopenharmony_ci            current: 1,
58fb726d48Sopenharmony_ci            totalpage: 1000,
59fb726d48Sopenharmony_ci            pageSize: 10,
60fb726d48Sopenharmony_ci            change(num: number) {},
61fb726d48Sopenharmony_ci        });
62fb726d48Sopenharmony_ci        expect(pageNation.pageInfo.pageSize).toEqual(10);
63fb726d48Sopenharmony_ci    });
64fb726d48Sopenharmony_ci
65fb726d48Sopenharmony_ci    it('pageNationTest03', function () {
66fb726d48Sopenharmony_ci        document.body.innerHTML = `
67fb726d48Sopenharmony_ci        <pagination-box id="pagination-info"></pagination-box> `;
68fb726d48Sopenharmony_ci        let pageInfo = document.getElementById('pagination-info') as PaginationBox;
69fb726d48Sopenharmony_ci        let pageNation = new PageNation(pageInfo, {
70fb726d48Sopenharmony_ci            current: 5,
71fb726d48Sopenharmony_ci            totalpage: 1000,
72fb726d48Sopenharmony_ci            pageSize: 10,
73fb726d48Sopenharmony_ci            change(num: number) {},
74fb726d48Sopenharmony_ci        });
75fb726d48Sopenharmony_ci        expect(pageNation).not.toBeUndefined();
76fb726d48Sopenharmony_ci    });
77fb726d48Sopenharmony_ci
78fb726d48Sopenharmony_ci    it('pageNationTest04', function () {
79fb726d48Sopenharmony_ci        document.body.innerHTML = `
80fb726d48Sopenharmony_ci        <pagination-box id="pagination-info"></pagination-box> `;
81fb726d48Sopenharmony_ci        let pageInfo = document.getElementById('pagination-info') as PaginationBox;
82fb726d48Sopenharmony_ci        let pageNation = new PageNation(pageInfo, {
83fb726d48Sopenharmony_ci            current: 149,
84fb726d48Sopenharmony_ci            totalpage: 150,
85fb726d48Sopenharmony_ci            pageSize: 10,
86fb726d48Sopenharmony_ci            change(num: number) {},
87fb726d48Sopenharmony_ci        });
88fb726d48Sopenharmony_ci        expect(pageNation.pageInfo.totalpage).toEqual(150);
89fb726d48Sopenharmony_ci    });
90fb726d48Sopenharmony_ci
91fb726d48Sopenharmony_ci    it('pageNationTest05', function () {
92fb726d48Sopenharmony_ci        document.body.innerHTML = `
93fb726d48Sopenharmony_ci        <pagination-box id="pagination-info"></pagination-box> `;
94fb726d48Sopenharmony_ci        let pageInfo = document.getElementById('pagination-info') as PaginationBox;
95fb726d48Sopenharmony_ci        let pageNation = new PageNation(pageInfo, {
96fb726d48Sopenharmony_ci            current: 11,
97fb726d48Sopenharmony_ci            totalpage: 15,
98fb726d48Sopenharmony_ci            pageSize: 10,
99fb726d48Sopenharmony_ci            change(num: number) {},
100fb726d48Sopenharmony_ci        });
101fb726d48Sopenharmony_ci        expect(pageNation.pageInfo.total).toEqual(100);
102fb726d48Sopenharmony_ci    });
103fb726d48Sopenharmony_ci
104fb726d48Sopenharmony_ci    it('pageNationTest06', function () {
105fb726d48Sopenharmony_ci        document.body.innerHTML = `
106fb726d48Sopenharmony_ci        <pagination-box id="pagination-info"></pagination-box> `;
107fb726d48Sopenharmony_ci        let pageInfo = document.getElementById('pagination-info') as PaginationBox;
108fb726d48Sopenharmony_ci        let pageNation = new PageNation(pageInfo, {
109fb726d48Sopenharmony_ci            current: 1,
110fb726d48Sopenharmony_ci            totalpage: 150,
111fb726d48Sopenharmony_ci            pageSize: 10,
112fb726d48Sopenharmony_ci            change(num: number) {},
113fb726d48Sopenharmony_ci        });
114fb726d48Sopenharmony_ci        let mouseMoveEvent: MouseEvent = new MouseEvent('click', <MouseEventInit>{ movementX: 1, movementY: 2 });
115fb726d48Sopenharmony_ci        pageNation.element.dispatchEvent(mouseMoveEvent);
116fb726d48Sopenharmony_ci    });
117fb726d48Sopenharmony_ci})
118