quasar 2.15.3 → 2.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/AppFullscreen.json +1 -1
- package/dist/icon-set/bootstrap-icons.umd.prod.js +1 -1
- package/dist/icon-set/eva-icons.umd.prod.js +1 -1
- package/dist/icon-set/fontawesome-v5-pro.umd.prod.js +1 -1
- package/dist/icon-set/fontawesome-v5.umd.prod.js +1 -1
- package/dist/icon-set/fontawesome-v6-pro.umd.prod.js +1 -1
- package/dist/icon-set/fontawesome-v6.umd.prod.js +1 -1
- package/dist/icon-set/ionicons-v4.umd.prod.js +1 -1
- package/dist/icon-set/line-awesome.umd.prod.js +1 -1
- package/dist/icon-set/material-icons-outlined.umd.prod.js +1 -1
- package/dist/icon-set/material-icons-round.umd.prod.js +1 -1
- package/dist/icon-set/material-icons-sharp.umd.prod.js +1 -1
- package/dist/icon-set/material-icons.umd.prod.js +1 -1
- package/dist/icon-set/material-symbols-outlined.umd.prod.js +1 -1
- package/dist/icon-set/material-symbols-rounded.umd.prod.js +1 -1
- package/dist/icon-set/material-symbols-sharp.umd.prod.js +1 -1
- package/dist/icon-set/mdi-v3.umd.prod.js +1 -1
- package/dist/icon-set/mdi-v4.umd.prod.js +1 -1
- package/dist/icon-set/mdi-v5.umd.prod.js +1 -1
- package/dist/icon-set/mdi-v6.umd.prod.js +1 -1
- package/dist/icon-set/mdi-v7.umd.prod.js +1 -1
- package/dist/icon-set/svg-bootstrap-icons.umd.prod.js +1 -1
- package/dist/icon-set/svg-eva-icons.umd.prod.js +1 -1
- package/dist/icon-set/svg-fontawesome-v5.umd.prod.js +1 -1
- package/dist/icon-set/svg-fontawesome-v6.umd.prod.js +1 -1
- package/dist/icon-set/svg-ionicons-v4.umd.prod.js +1 -1
- package/dist/icon-set/svg-ionicons-v5.umd.prod.js +1 -1
- package/dist/icon-set/svg-ionicons-v6.umd.prod.js +1 -1
- package/dist/icon-set/svg-line-awesome.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-icons-outlined.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-icons-round.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-icons-sharp.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-icons.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-symbols-outlined.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-symbols-rounded.umd.prod.js +1 -1
- package/dist/icon-set/svg-material-symbols-sharp.umd.prod.js +1 -1
- package/dist/icon-set/svg-mdi-v6.umd.prod.js +1 -1
- package/dist/icon-set/svg-mdi-v7.umd.prod.js +1 -1
- package/dist/icon-set/svg-themify.umd.prod.js +1 -1
- package/dist/icon-set/themify.umd.prod.js +1 -1
- package/dist/lang/ar-TN.umd.prod.js +1 -1
- package/dist/lang/ar.umd.prod.js +1 -1
- package/dist/lang/az-Latn.umd.prod.js +1 -1
- package/dist/lang/bg.umd.prod.js +1 -1
- package/dist/lang/bn.umd.prod.js +1 -1
- package/dist/lang/ca.umd.prod.js +1 -1
- package/dist/lang/cs.umd.prod.js +1 -1
- package/dist/lang/da.umd.prod.js +1 -1
- package/dist/lang/de-CH.umd.prod.js +1 -1
- package/dist/lang/de-DE.umd.prod.js +1 -1
- package/dist/lang/de.umd.prod.js +1 -1
- package/dist/lang/el.umd.prod.js +1 -1
- package/dist/lang/en-GB.umd.prod.js +1 -1
- package/dist/lang/en-US.umd.prod.js +1 -1
- package/dist/lang/eo.umd.prod.js +1 -1
- package/dist/lang/es.umd.prod.js +1 -1
- package/dist/lang/et.umd.prod.js +1 -1
- package/dist/lang/eu.umd.prod.js +1 -1
- package/dist/lang/fa-IR.umd.prod.js +1 -1
- package/dist/lang/fa.umd.prod.js +1 -1
- package/dist/lang/fi.umd.prod.js +1 -1
- package/dist/lang/fr.umd.prod.js +1 -1
- package/dist/lang/gn.umd.prod.js +1 -1
- package/dist/lang/he.umd.prod.js +1 -1
- package/dist/lang/hi.umd.prod.js +1 -1
- package/dist/lang/hr.umd.prod.js +1 -1
- package/dist/lang/hu.umd.prod.js +1 -1
- package/dist/lang/id.umd.prod.js +1 -1
- package/dist/lang/is.umd.prod.js +1 -1
- package/dist/lang/it.umd.prod.js +1 -1
- package/dist/lang/ja.umd.prod.js +1 -1
- package/dist/lang/kk.umd.prod.js +1 -1
- package/dist/lang/km.umd.prod.js +1 -1
- package/dist/lang/ko-KR.umd.prod.js +1 -1
- package/dist/lang/kur-CKB.umd.prod.js +1 -1
- package/dist/lang/lt.umd.prod.js +1 -1
- package/dist/lang/lu.umd.prod.js +1 -1
- package/dist/lang/lv.umd.prod.js +1 -1
- package/dist/lang/mk.umd.prod.js +1 -1
- package/dist/lang/ml.umd.prod.js +1 -1
- package/dist/lang/mm.umd.prod.js +1 -1
- package/dist/lang/ms-MY.umd.prod.js +1 -1
- package/dist/lang/ms.umd.prod.js +1 -1
- package/dist/lang/my.umd.prod.js +1 -1
- package/dist/lang/nb-NO.umd.prod.js +1 -1
- package/dist/lang/nl.umd.prod.js +1 -1
- package/dist/lang/pl.umd.prod.js +1 -1
- package/dist/lang/pt-BR.umd.prod.js +1 -1
- package/dist/lang/pt.umd.prod.js +1 -1
- package/dist/lang/ro.umd.prod.js +1 -1
- package/dist/lang/ru.umd.prod.js +1 -1
- package/dist/lang/sk.umd.prod.js +1 -1
- package/dist/lang/sl.umd.prod.js +1 -1
- package/dist/lang/sm.umd.prod.js +1 -1
- package/dist/lang/sr-CYR.umd.prod.js +1 -1
- package/dist/lang/sr.umd.prod.js +1 -1
- package/dist/lang/sv.umd.prod.js +1 -1
- package/dist/lang/ta.umd.prod.js +1 -1
- package/dist/lang/th.umd.prod.js +1 -1
- package/dist/lang/tl.umd.prod.js +1 -1
- package/dist/lang/tr.umd.prod.js +1 -1
- package/dist/lang/ug.umd.prod.js +1 -1
- package/dist/lang/uk.umd.prod.js +1 -1
- package/dist/lang/uz-Cyrl.umd.prod.js +1 -1
- package/dist/lang/uz-Latn.umd.prod.js +1 -1
- package/dist/lang/vi.umd.prod.js +1 -1
- package/dist/lang/zh-CN.umd.prod.js +1 -1
- package/dist/lang/zh-TW.umd.prod.js +1 -1
- package/dist/quasar.cjs.prod.js +3 -3
- package/dist/quasar.esm.js +8 -7
- package/dist/quasar.esm.prod.js +3 -3
- package/dist/quasar.sass +1 -1
- package/dist/quasar.umd.js +8 -7
- package/dist/quasar.umd.prod.js +3 -3
- package/dist/web-types/web-types.json +1 -1
- package/package.json +3 -3
- package/src/components/toolbar/QToolbar.test.js +45 -0
- package/src/components/toolbar/QToolbarTitle.test.js +45 -0
- package/src/composables/use-interval/use-interval.test.js +173 -0
- package/src/composables/use-render-cache/use-render-cache.js +2 -2
- package/src/composables/use-render-cache/use-render-cache.test.js +73 -0
- package/src/composables/use-split-attrs/use-split-attrs.test.js +55 -0
- package/src/composables/use-tick/use-tick.test.js +118 -0
- package/src/composables/use-timeout/use-timeout.test.js +169 -0
- package/src/plugins/addressbar/AddressbarColor.test.js +53 -0
- package/src/plugins/app-fullscreen/AppFullscreen.json +3 -1
- package/src/plugins/app-fullscreen/AppFullscreen.test.js +206 -0
- package/src/plugins/app-fullscreen/test/mock-fullscreen.js +43 -0
- package/src/plugins/app-visibility/AppVisibility.test.js +45 -0
- package/src/plugins/dark/Dark.test.js +158 -0
- package/src/plugins/platform/Platform.js +2 -1
- package/src/plugins/private.body/Body.test.js +28 -0
- package/src/plugins/private.history/History.test.js +38 -0
- package/src/plugins/screen/Screen.test.js +453 -0
- package/src/utils/css-var/get-css-var.test.js +12 -0
- package/src/utils/css-var/set-css-var.test.js +18 -0
- package/src/utils/dom/dom.test.js +222 -0
- package/src/utils/private.render/render.test.js +187 -0
- package/src/utils/private.selection/selection.test.js +40 -0
- package/src/utils/private.vm/vm.test.js +175 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, test, expect } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
|
|
4
|
+
import Body from './Body.js'
|
|
5
|
+
|
|
6
|
+
const mountPlugin = () => mount({ template: '<div />' })
|
|
7
|
+
|
|
8
|
+
describe('[Body API]', () => {
|
|
9
|
+
describe('[Functions]', () => {
|
|
10
|
+
describe('[(function)install]', () => {
|
|
11
|
+
test('should be defined correctly', () => {
|
|
12
|
+
expect(Body).toBeTypeOf('object')
|
|
13
|
+
|
|
14
|
+
expect(
|
|
15
|
+
Body.install
|
|
16
|
+
).toBeTypeOf('function')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('sets body classes', () => {
|
|
20
|
+
mountPlugin()
|
|
21
|
+
|
|
22
|
+
expect(
|
|
23
|
+
document.body.getAttribute('class')
|
|
24
|
+
).toBe('desktop touch body--light')
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, test, expect } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import History from './History.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Can't really fully test it since it handles
|
|
7
|
+
* Capacitor and Cordova platforms
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
describe('[History API]', () => {
|
|
11
|
+
describe('[Variables]', () => {
|
|
12
|
+
describe('[(variable)__history]', () => {
|
|
13
|
+
test('is defined correctly', () => {
|
|
14
|
+
expect(Array.isArray(History.__history)).toBe(true)
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
describe('[(variable)add]', () => {
|
|
19
|
+
test('is defined correctly', () => {
|
|
20
|
+
expect(History.add).toBeTypeOf('function')
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
describe('[(variable)remove]', () => {
|
|
25
|
+
test('is defined correctly', () => {
|
|
26
|
+
expect(History.remove).toBeTypeOf('function')
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
describe('[Functions]', () => {
|
|
32
|
+
describe('[(function)install]', () => {
|
|
33
|
+
test('is defined correctly', () => {
|
|
34
|
+
expect(History.install).toBeTypeOf('function')
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import { describe, test, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
|
|
4
|
+
import Screen from './Screen.js'
|
|
5
|
+
|
|
6
|
+
const mountPlugin = () => mount({ template: '<div />' })
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
vi.useFakeTimers()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
vi.clearAllTimers()
|
|
14
|
+
vi.restoreAllMocks()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
function setWidth (width) {
|
|
18
|
+
window.innerWidth = width
|
|
19
|
+
window.dispatchEvent(new Event('resize'))
|
|
20
|
+
vi.runAllTimers()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function setHeight (height) {
|
|
24
|
+
window.innerHeight = height
|
|
25
|
+
window.dispatchEvent(new Event('resize'))
|
|
26
|
+
vi.runAllTimers()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe('[Screen API]', () => {
|
|
30
|
+
describe('[Injection]', () => {
|
|
31
|
+
test('is injected into $q', () => {
|
|
32
|
+
const wrapper = mountPlugin()
|
|
33
|
+
expect(Screen).toBe(wrapper.vm.$q.screen)
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
describe('[Props]', () => {
|
|
38
|
+
describe('[(prop)width]', () => {
|
|
39
|
+
test('is correct type', () => {
|
|
40
|
+
mountPlugin()
|
|
41
|
+
expect(Screen.width).toBeTypeOf('number')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('is reactive', () => {
|
|
45
|
+
mountPlugin()
|
|
46
|
+
expect(Screen.width).not.toBe(100)
|
|
47
|
+
setWidth(100)
|
|
48
|
+
vi.runAllTimers()
|
|
49
|
+
expect(Screen.width).toBe(100)
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
describe('[(prop)height]', () => {
|
|
54
|
+
test('is correct type', () => {
|
|
55
|
+
mountPlugin()
|
|
56
|
+
expect(Screen.height).toBeTypeOf('number')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('is reactive', () => {
|
|
60
|
+
mountPlugin()
|
|
61
|
+
expect(Screen.height).not.toBe(100)
|
|
62
|
+
setHeight(100)
|
|
63
|
+
expect(Screen.height).toBe(100)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
describe('[(prop)name]', () => {
|
|
68
|
+
test('is correct type', () => {
|
|
69
|
+
mountPlugin()
|
|
70
|
+
expect([ 'xs', 'sm', 'md', 'lg', 'xl' ]).toContain(Screen.name)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('is reactive', () => {
|
|
74
|
+
mountPlugin()
|
|
75
|
+
|
|
76
|
+
setWidth(500)
|
|
77
|
+
expect(Screen.name).toBe('xs')
|
|
78
|
+
|
|
79
|
+
setWidth(800)
|
|
80
|
+
expect(Screen.name).toBe('sm')
|
|
81
|
+
|
|
82
|
+
setWidth(1200)
|
|
83
|
+
expect(Screen.name).toBe('md')
|
|
84
|
+
|
|
85
|
+
setWidth(1600)
|
|
86
|
+
expect(Screen.name).toBe('lg')
|
|
87
|
+
|
|
88
|
+
setWidth(2000)
|
|
89
|
+
expect(Screen.name).toBe('xl')
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
describe('[(prop)sizes]', () => {
|
|
94
|
+
test('is correct type', () => {
|
|
95
|
+
mountPlugin()
|
|
96
|
+
expect(Screen.sizes).toStrictEqual({
|
|
97
|
+
sm: expect.any(Number),
|
|
98
|
+
md: expect.any(Number),
|
|
99
|
+
lg: expect.any(Number),
|
|
100
|
+
xl: expect.any(Number)
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
describe('[(prop)lt]', () => {
|
|
106
|
+
test('is correct type', () => {
|
|
107
|
+
mountPlugin()
|
|
108
|
+
expect(Screen.lt).toStrictEqual({
|
|
109
|
+
sm: expect.any(Boolean),
|
|
110
|
+
md: expect.any(Boolean),
|
|
111
|
+
lg: expect.any(Boolean),
|
|
112
|
+
xl: expect.any(Boolean)
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
test('is reactive', () => {
|
|
117
|
+
mountPlugin()
|
|
118
|
+
|
|
119
|
+
setWidth(500) // xs
|
|
120
|
+
expect(Screen.lt).toStrictEqual({
|
|
121
|
+
sm: true,
|
|
122
|
+
md: true,
|
|
123
|
+
lg: true,
|
|
124
|
+
xl: true
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
setWidth(800) // sm
|
|
128
|
+
expect(Screen.lt).toStrictEqual({
|
|
129
|
+
sm: false,
|
|
130
|
+
md: true,
|
|
131
|
+
lg: true,
|
|
132
|
+
xl: true
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
setWidth(1200) // md
|
|
136
|
+
expect(Screen.lt).toStrictEqual({
|
|
137
|
+
sm: false,
|
|
138
|
+
md: false,
|
|
139
|
+
lg: true,
|
|
140
|
+
xl: true
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
setWidth(1600) // lg
|
|
144
|
+
expect(Screen.lt).toStrictEqual({
|
|
145
|
+
sm: false,
|
|
146
|
+
md: false,
|
|
147
|
+
lg: false,
|
|
148
|
+
xl: true
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
setWidth(2000) // xl
|
|
152
|
+
expect(Screen.lt).toStrictEqual({
|
|
153
|
+
sm: false,
|
|
154
|
+
md: false,
|
|
155
|
+
lg: false,
|
|
156
|
+
xl: false
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
describe('[(prop)gt]', () => {
|
|
162
|
+
test('is correct type', () => {
|
|
163
|
+
mountPlugin()
|
|
164
|
+
expect(Screen.gt).toStrictEqual({
|
|
165
|
+
xs: expect.any(Boolean),
|
|
166
|
+
sm: expect.any(Boolean),
|
|
167
|
+
md: expect.any(Boolean),
|
|
168
|
+
lg: expect.any(Boolean)
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
test('is reactive', () => {
|
|
173
|
+
mountPlugin()
|
|
174
|
+
|
|
175
|
+
setWidth(500) // xs
|
|
176
|
+
expect(Screen.gt).toStrictEqual({
|
|
177
|
+
xs: false,
|
|
178
|
+
sm: false,
|
|
179
|
+
md: false,
|
|
180
|
+
lg: false
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
setWidth(800) // sm
|
|
184
|
+
expect(Screen.gt).toStrictEqual({
|
|
185
|
+
xs: true,
|
|
186
|
+
sm: false,
|
|
187
|
+
md: false,
|
|
188
|
+
lg: false
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
setWidth(1200) // md
|
|
192
|
+
expect(Screen.gt).toStrictEqual({
|
|
193
|
+
xs: true,
|
|
194
|
+
sm: true,
|
|
195
|
+
md: false,
|
|
196
|
+
lg: false
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
setWidth(1600) // lg
|
|
200
|
+
expect(Screen.gt).toStrictEqual({
|
|
201
|
+
xs: true,
|
|
202
|
+
sm: true,
|
|
203
|
+
md: true,
|
|
204
|
+
lg: false
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
setWidth(2000) // xl
|
|
208
|
+
expect(Screen.gt).toStrictEqual({
|
|
209
|
+
xs: true,
|
|
210
|
+
sm: true,
|
|
211
|
+
md: true,
|
|
212
|
+
lg: true
|
|
213
|
+
})
|
|
214
|
+
})
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
describe('[(prop)xs]', () => {
|
|
218
|
+
test('is correct type', () => {
|
|
219
|
+
mountPlugin()
|
|
220
|
+
expect(Screen.xs).toBeTypeOf('boolean')
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
test('is reactive', () => {
|
|
224
|
+
mountPlugin()
|
|
225
|
+
|
|
226
|
+
setWidth(500) // xs
|
|
227
|
+
expect(Screen.xs).toBe(true)
|
|
228
|
+
|
|
229
|
+
setWidth(800) // sm
|
|
230
|
+
expect(Screen.xs).toBe(false)
|
|
231
|
+
})
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
describe('[(prop)sm]', () => {
|
|
235
|
+
test('is correct type', () => {
|
|
236
|
+
mountPlugin()
|
|
237
|
+
expect(Screen.sm).toBeTypeOf('boolean')
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
test('is reactive', () => {
|
|
241
|
+
mountPlugin()
|
|
242
|
+
|
|
243
|
+
setWidth(500) // xs
|
|
244
|
+
expect(Screen.sm).toBe(false)
|
|
245
|
+
|
|
246
|
+
setWidth(800) // sm
|
|
247
|
+
expect(Screen.sm).toBe(true)
|
|
248
|
+
})
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
describe('[(prop)md]', () => {
|
|
252
|
+
test('is correct type', () => {
|
|
253
|
+
mountPlugin()
|
|
254
|
+
expect(Screen.md).toBeTypeOf('boolean')
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
test('is reactive', () => {
|
|
258
|
+
mountPlugin()
|
|
259
|
+
|
|
260
|
+
setWidth(800) // sm
|
|
261
|
+
expect(Screen.md).toBe(false)
|
|
262
|
+
|
|
263
|
+
setWidth(1200) // md
|
|
264
|
+
expect(Screen.md).toBe(true)
|
|
265
|
+
})
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
describe('[(prop)lg]', () => {
|
|
269
|
+
test('is correct type', () => {
|
|
270
|
+
mountPlugin()
|
|
271
|
+
expect(Screen.lg).toBeTypeOf('boolean')
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
test('is reactive', () => {
|
|
275
|
+
mountPlugin()
|
|
276
|
+
|
|
277
|
+
setWidth(1200) // md
|
|
278
|
+
expect(Screen.lg).toBe(false)
|
|
279
|
+
|
|
280
|
+
setWidth(1600) // lg
|
|
281
|
+
expect(Screen.lg).toBe(true)
|
|
282
|
+
})
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
describe('[(prop)xl]', () => {
|
|
286
|
+
test('is correct type', () => {
|
|
287
|
+
mountPlugin()
|
|
288
|
+
expect(Screen.xl).toBeTypeOf('boolean')
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
test('is reactive', () => {
|
|
292
|
+
mountPlugin()
|
|
293
|
+
|
|
294
|
+
setWidth(1600) // lg
|
|
295
|
+
expect(Screen.xl).toBe(false)
|
|
296
|
+
|
|
297
|
+
setWidth(2000) // xl
|
|
298
|
+
expect(Screen.xl).toBe(true)
|
|
299
|
+
})
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
describe('[Methods]', () => {
|
|
304
|
+
describe('[(method)setSizes]', () => {
|
|
305
|
+
test('should be callable', () => {
|
|
306
|
+
mountPlugin()
|
|
307
|
+
|
|
308
|
+
const newSizes = {
|
|
309
|
+
sm: 10,
|
|
310
|
+
md: 15,
|
|
311
|
+
lg: 20,
|
|
312
|
+
xl: 25
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
expect(
|
|
316
|
+
Screen.setSizes(newSizes)
|
|
317
|
+
).toBeUndefined()
|
|
318
|
+
|
|
319
|
+
expect(
|
|
320
|
+
Screen.sizes
|
|
321
|
+
).toStrictEqual(newSizes)
|
|
322
|
+
|
|
323
|
+
setWidth(5)
|
|
324
|
+
expect(Screen).toMatchObject({
|
|
325
|
+
name: 'xs',
|
|
326
|
+
xs: true,
|
|
327
|
+
sm: false,
|
|
328
|
+
md: false,
|
|
329
|
+
lg: false,
|
|
330
|
+
xl: false,
|
|
331
|
+
lt: {
|
|
332
|
+
sm: true,
|
|
333
|
+
md: true,
|
|
334
|
+
lg: true,
|
|
335
|
+
xl: true
|
|
336
|
+
},
|
|
337
|
+
gt: {
|
|
338
|
+
xs: false,
|
|
339
|
+
sm: false,
|
|
340
|
+
md: false,
|
|
341
|
+
lg: false
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
setWidth(11)
|
|
346
|
+
expect(Screen).toMatchObject({
|
|
347
|
+
name: 'sm',
|
|
348
|
+
xs: false,
|
|
349
|
+
sm: true,
|
|
350
|
+
md: false,
|
|
351
|
+
lg: false,
|
|
352
|
+
xl: false,
|
|
353
|
+
lt: {
|
|
354
|
+
sm: false,
|
|
355
|
+
md: true,
|
|
356
|
+
lg: true,
|
|
357
|
+
xl: true
|
|
358
|
+
},
|
|
359
|
+
gt: {
|
|
360
|
+
xs: true,
|
|
361
|
+
sm: false,
|
|
362
|
+
md: false,
|
|
363
|
+
lg: false
|
|
364
|
+
}
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
setWidth(16)
|
|
368
|
+
expect(Screen).toMatchObject({
|
|
369
|
+
name: 'md',
|
|
370
|
+
xs: false,
|
|
371
|
+
sm: false,
|
|
372
|
+
md: true,
|
|
373
|
+
lg: false,
|
|
374
|
+
xl: false,
|
|
375
|
+
lt: {
|
|
376
|
+
sm: false,
|
|
377
|
+
md: false,
|
|
378
|
+
lg: true,
|
|
379
|
+
xl: true
|
|
380
|
+
},
|
|
381
|
+
gt: {
|
|
382
|
+
xs: true,
|
|
383
|
+
sm: true,
|
|
384
|
+
md: false,
|
|
385
|
+
lg: false
|
|
386
|
+
}
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
setWidth(21)
|
|
390
|
+
expect(Screen).toMatchObject({
|
|
391
|
+
name: 'lg',
|
|
392
|
+
xs: false,
|
|
393
|
+
sm: false,
|
|
394
|
+
md: false,
|
|
395
|
+
lg: true,
|
|
396
|
+
xl: false,
|
|
397
|
+
lt: {
|
|
398
|
+
sm: false,
|
|
399
|
+
md: false,
|
|
400
|
+
lg: false,
|
|
401
|
+
xl: true
|
|
402
|
+
},
|
|
403
|
+
gt: {
|
|
404
|
+
xs: true,
|
|
405
|
+
sm: true,
|
|
406
|
+
md: true,
|
|
407
|
+
lg: false
|
|
408
|
+
}
|
|
409
|
+
})
|
|
410
|
+
|
|
411
|
+
setWidth(26)
|
|
412
|
+
expect(Screen).toMatchObject({
|
|
413
|
+
name: 'xl',
|
|
414
|
+
xs: false,
|
|
415
|
+
sm: false,
|
|
416
|
+
md: false,
|
|
417
|
+
lg: false,
|
|
418
|
+
xl: true,
|
|
419
|
+
lt: {
|
|
420
|
+
sm: false,
|
|
421
|
+
md: false,
|
|
422
|
+
lg: false,
|
|
423
|
+
xl: false
|
|
424
|
+
},
|
|
425
|
+
gt: {
|
|
426
|
+
xs: true,
|
|
427
|
+
sm: true,
|
|
428
|
+
md: true,
|
|
429
|
+
lg: true
|
|
430
|
+
}
|
|
431
|
+
})
|
|
432
|
+
})
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
describe('[(method)setDebounce]', () => {
|
|
436
|
+
test('should be callable', () => {
|
|
437
|
+
mountPlugin()
|
|
438
|
+
expect(
|
|
439
|
+
Screen.setDebounce(1000)
|
|
440
|
+
).toBeUndefined()
|
|
441
|
+
|
|
442
|
+
window.innerWidth = 100
|
|
443
|
+
window.dispatchEvent(new Event('resize'))
|
|
444
|
+
|
|
445
|
+
expect(Screen.width).not.toBe(100)
|
|
446
|
+
vi.advanceTimersByTime(999)
|
|
447
|
+
expect(Screen.width).not.toBe(100)
|
|
448
|
+
vi.advanceTimersByTime(1)
|
|
449
|
+
expect(Screen.width).toBe(100)
|
|
450
|
+
})
|
|
451
|
+
})
|
|
452
|
+
})
|
|
453
|
+
})
|
|
@@ -27,6 +27,18 @@ describe('[getCssVar API]', () => {
|
|
|
27
27
|
|
|
28
28
|
el.remove()
|
|
29
29
|
})
|
|
30
|
+
|
|
31
|
+
test('should throw if propName is not a string', () => {
|
|
32
|
+
expect(() => {
|
|
33
|
+
getCssVar(5)
|
|
34
|
+
}).toThrow(TypeError)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test('should throw if element is not a DOM element', () => {
|
|
38
|
+
expect(() => {
|
|
39
|
+
getCssVar('prop', {})
|
|
40
|
+
}).toThrow(TypeError)
|
|
41
|
+
})
|
|
30
42
|
})
|
|
31
43
|
})
|
|
32
44
|
})
|
|
@@ -31,6 +31,24 @@ describe('[setCssVar API]', () => {
|
|
|
31
31
|
|
|
32
32
|
el.remove()
|
|
33
33
|
})
|
|
34
|
+
|
|
35
|
+
test('should throw if propName is not a string', () => {
|
|
36
|
+
expect(() => {
|
|
37
|
+
setCssVar(5, 'awesome')
|
|
38
|
+
}).toThrow(TypeError)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test('should throw if value is not a string', () => {
|
|
42
|
+
expect(() => {
|
|
43
|
+
setCssVar('prop', 5)
|
|
44
|
+
}).toThrow(TypeError)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('should throw if element is not a DOM element', () => {
|
|
48
|
+
expect(() => {
|
|
49
|
+
setCssVar('prop', 'awesome', {})
|
|
50
|
+
}).toThrow(TypeError)
|
|
51
|
+
})
|
|
34
52
|
})
|
|
35
53
|
})
|
|
36
54
|
})
|