Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 9b79128

Browse files
committed
test: update tests for scroll lock
1 parent 7517ca5 commit 9b79128

File tree

8 files changed

+165
-8
lines changed

8 files changed

+165
-8
lines changed

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const testConfig = {
3939
},
4040
],
4141
],
42-
plugins: ['@vue/babel-plugin-jsx'],
42+
plugins: ['@vue/babel-plugin-jsx', '@babel/plugin-transform-runtime'],
4343
},
4444
},
4545
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,8 @@
122122
"vue-prism-editor": "^2.0.0-alpha.2",
123123
"vue-router": "^4.0.6",
124124
"vue3-perfect-scrollbar": "^1.5.5"
125+
},
126+
"devDependencies": {
127+
"@babel/plugin-transform-runtime": "^7.13.15"
125128
}
126129
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`should render properly 1`] = `
4+
<DocumentFragment>
5+
<transition-stub>
6+
<!---->
7+
</transition-stub>
8+
</DocumentFragment>
9+
`;

packages/c-scroll-lock/src/c-scroll-lock.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import { BodyScrollLockDirective } from './body-scoll-lock.directive'
2020
export const CScrollLock = defineComponent({
2121
name: 'CScrollLock',
2222
props: {
23-
enabled: Boolean as PropType<Boolean>,
23+
enabled: {
24+
type: Boolean as PropType<boolean>,
25+
default: false,
26+
},
2427
},
2528
setup(props, { slots, attrs }) {
2629
return () => {
@@ -31,10 +34,12 @@ export const CScrollLock = defineComponent({
3134
)
3235
return
3336
}
37+
3438
const scrollLockVNode = cloneVNode(firstChild, {
3539
...attrs,
3640
'data-chakra-scroll-lock': `${props.enabled}`,
3741
})
42+
3843
return withDirectives(scrollLockVNode, [
3944
[BodyScrollLockDirective, props.enabled],
4045
])
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`should block body 1`] = `
4+
<DocumentFragment>
5+
<div>
6+
<section>
7+
<c-scroll-lock>
8+
<p>
9+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qu officia deserunt mollit anim id est laborum.
10+
</p>
11+
</c-scroll-lock>
12+
</section>
13+
</div>
14+
</DocumentFragment>
15+
`;
16+
17+
exports[`should render properly 1`] = `
18+
<DocumentFragment>
19+
<div>
20+
<section>
21+
<c-scroll-lock>
22+
<p>
23+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qu officia deserunt mollit anim id est laborum.
24+
</p>
25+
</c-scroll-lock>
26+
</section>
27+
</div>
28+
</DocumentFragment>
29+
`;
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
11
import { render } from '@chakra-ui/vue-test-utils/src'
22
import { CScrollLock } from '../src'
33

4+
const renderComponent = (props?: {}) =>
5+
render({
6+
template: `
7+
<div>
8+
<section>
9+
<c-scroll-lock>
10+
<p>
11+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
12+
eiusmod tempor incididunt ut labore et dolore magna aliqua.
13+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
14+
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
15+
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
16+
Excepteur sint occaecat cupidatat non proident, sunt in culpa qu
17+
officia deserunt mollit anim id est laborum.
18+
</p>
19+
</c-scroll-lock>
20+
</section>
21+
</div>
22+
`,
23+
...props,
24+
})
25+
426
it('should render properly', () => {
5-
const { asFragment } = render(CScrollLock)
27+
const { asFragment } = renderComponent()
28+
expect(asFragment()).toMatchSnapshot()
29+
})
30+
31+
it('should block body', () => {
32+
const { asFragment } = renderComponent()
633
expect(asFragment()).toMatchSnapshot()
734
})

packages/utils/tests/dom.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,22 @@ it('`useDOMRef` should bind components to render function elements', async () =>
5858
return () =>
5959
h('div', [
6060
h(
61-
// @ts-expect-error
61+
// @ts-ignore
6262
'div',
6363
{
6464
'data-testid': 'divElement',
6565
ref: container,
6666
},
67-
() => 'Regular element'
67+
'Regular element'
6868
),
6969
h(
70-
// @ts-expect-error
70+
// @ts-ignore
7171
ExampleComponent,
7272
{
7373
'data-testid': 'buttonComponent',
7474
ref: component,
7575
},
76-
() => 'Click me'
76+
'Click me'
7777
),
7878
])
7979
},

yarn.lock

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@
147147
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.13.12.tgz#a8a5ccac19c200f9dd49624cac6e19d7be1236a1"
148148
integrity sha512-3eJJ841uKxeV8dcN/2yGEUy+RfgQspPEgQat85umsE1rotuquQ2AbIub4S6j7c50a2d+4myc+zSlnXeIHrOnhQ==
149149

150+
"@babel/compat-data@^7.13.11":
151+
version "7.14.0"
152+
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.14.0.tgz#a901128bce2ad02565df95e6ecbf195cf9465919"
153+
integrity sha512-vu9V3uMM/1o5Hl5OekMUowo3FqXLJSw+s+66nt0fSWVWTtmosdzn45JHOB3cPtZoe6CTBDzvSw0RdOY85Q37+Q==
154+
150155
"@babel/core@^7.1.0", "@babel/core@^7.12.9", "@babel/core@^7.13.10", "@babel/core@^7.7.5":
151156
version "7.13.14"
152157
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.13.14.tgz#8e46ebbaca460a63497c797e574038ab04ae6d06"
@@ -235,6 +240,20 @@
235240
resolve "^1.14.2"
236241
semver "^6.1.2"
237242

243+
"@babel/helper-define-polyfill-provider@^0.2.0":
244+
version "0.2.0"
245+
resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.2.0.tgz#a640051772045fedaaecc6f0c6c69f02bdd34bf1"
246+
integrity sha512-JT8tHuFjKBo8NnaUbblz7mIu1nnvUDiHVjXXkulZULyidvo/7P6TY7+YqpV37IfF+KUFxmlK04elKtGKXaiVgw==
247+
dependencies:
248+
"@babel/helper-compilation-targets" "^7.13.0"
249+
"@babel/helper-module-imports" "^7.12.13"
250+
"@babel/helper-plugin-utils" "^7.13.0"
251+
"@babel/traverse" "^7.13.0"
252+
debug "^4.1.1"
253+
lodash.debounce "^4.0.8"
254+
resolve "^1.14.2"
255+
semver "^6.1.2"
256+
238257
"@babel/helper-explode-assignable-expression@^7.12.13":
239258
version "7.13.0"
240259
resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.13.0.tgz#17b5c59ff473d9f956f40ef570cf3a76ca12657f"
@@ -821,6 +840,18 @@
821840
dependencies:
822841
"@babel/helper-plugin-utils" "^7.12.13"
823842

843+
"@babel/plugin-transform-runtime@^7.13.15":
844+
version "7.13.15"
845+
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.13.15.tgz#2eddf585dd066b84102517e10a577f24f76a9cd7"
846+
integrity sha512-d+ezl76gx6Jal08XngJUkXM4lFXK/5Ikl9Mh4HKDxSfGJXmZ9xG64XT2oivBzfxb/eQ62VfvoMkaCZUKJMVrBA==
847+
dependencies:
848+
"@babel/helper-module-imports" "^7.13.12"
849+
"@babel/helper-plugin-utils" "^7.13.0"
850+
babel-plugin-polyfill-corejs2 "^0.2.0"
851+
babel-plugin-polyfill-corejs3 "^0.2.0"
852+
babel-plugin-polyfill-regenerator "^0.2.0"
853+
semver "^6.3.0"
854+
824855
"@babel/plugin-transform-shorthand-properties@^7.12.13":
825856
version "7.12.13"
826857
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.12.13.tgz#db755732b70c539d504c6390d9ce90fe64aff7ad"
@@ -4002,6 +4033,15 @@ babel-plugin-polyfill-corejs2@^0.1.4:
40024033
"@babel/helper-define-polyfill-provider" "^0.1.5"
40034034
semver "^6.1.1"
40044035

4036+
babel-plugin-polyfill-corejs2@^0.2.0:
4037+
version "0.2.0"
4038+
resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.2.0.tgz#686775bf9a5aa757e10520903675e3889caeedc4"
4039+
integrity sha512-9bNwiR0dS881c5SHnzCmmGlMkJLl0OUZvxrxHo9w/iNoRuqaPjqlvBf4HrovXtQs/au5yKkpcdgfT1cC5PAZwg==
4040+
dependencies:
4041+
"@babel/compat-data" "^7.13.11"
4042+
"@babel/helper-define-polyfill-provider" "^0.2.0"
4043+
semver "^6.1.1"
4044+
40054045
babel-plugin-polyfill-corejs3@^0.1.3:
40064046
version "0.1.7"
40074047
resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.1.7.tgz#80449d9d6f2274912e05d9e182b54816904befd0"
@@ -4010,13 +4050,28 @@ babel-plugin-polyfill-corejs3@^0.1.3:
40104050
"@babel/helper-define-polyfill-provider" "^0.1.5"
40114051
core-js-compat "^3.8.1"
40124052

4053+
babel-plugin-polyfill-corejs3@^0.2.0:
4054+
version "0.2.0"
4055+
resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.2.0.tgz#f4b4bb7b19329827df36ff56f6e6d367026cb7a2"
4056+
integrity sha512-zZyi7p3BCUyzNxLx8KV61zTINkkV65zVkDAFNZmrTCRVhjo1jAS+YLvDJ9Jgd/w2tsAviCwFHReYfxO3Iql8Yg==
4057+
dependencies:
4058+
"@babel/helper-define-polyfill-provider" "^0.2.0"
4059+
core-js-compat "^3.9.1"
4060+
40134061
babel-plugin-polyfill-regenerator@^0.1.2:
40144062
version "0.1.6"
40154063
resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.1.6.tgz#0fe06a026fe0faa628ccc8ba3302da0a6ce02f3f"
40164064
integrity sha512-OUrYG9iKPKz8NxswXbRAdSwF0GhRdIEMTloQATJi4bDuFqrXaXcCUT/VGNrr8pBcjMh1RxZ7Xt9cytVJTJfvMg==
40174065
dependencies:
40184066
"@babel/helper-define-polyfill-provider" "^0.1.5"
40194067

4068+
babel-plugin-polyfill-regenerator@^0.2.0:
4069+
version "0.2.0"
4070+
resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.2.0.tgz#853f5f5716f4691d98c84f8069c7636ea8da7ab8"
4071+
integrity sha512-J7vKbCuD2Xi/eEHxquHN14bXAW9CXtecwuLrOIDJtcZzTaPzV1VdEfoUf9AzcRBMolKUQKM9/GVojeh0hFiqMg==
4072+
dependencies:
4073+
"@babel/helper-define-polyfill-provider" "^0.2.0"
4074+
40204075
babel-preset-current-node-syntax@^1.0.0:
40214076
version "1.0.1"
40224077
resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz#b4399239b89b2a011f9ddbe3e4f401fc40cff73b"
@@ -4203,6 +4258,17 @@ browserslist@^4.0.0, browserslist@^4.14.5, browserslist@^4.16.3:
42034258
escalade "^3.1.1"
42044259
node-releases "^1.1.70"
42054260

4261+
browserslist@^4.16.6:
4262+
version "4.16.6"
4263+
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.6.tgz#d7901277a5a88e554ed305b183ec9b0c08f66fa2"
4264+
integrity sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ==
4265+
dependencies:
4266+
caniuse-lite "^1.0.30001219"
4267+
colorette "^1.2.2"
4268+
electron-to-chromium "^1.3.723"
4269+
escalade "^3.1.1"
4270+
node-releases "^1.1.71"
4271+
42064272
42074273
version "0.2.6"
42084274
resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8"
@@ -4441,6 +4507,11 @@ caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001181:
44414507
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001207.tgz#364d47d35a3007e528f69adb6fecb07c2bb2cc50"
44424508
integrity sha512-UPQZdmAsyp2qfCTiMU/zqGSWOYaY9F9LL61V8f+8MrubsaDGpaHD9HRV/EWZGULZn0Hxu48SKzI5DgFwTvHuYw==
44434509

4510+
caniuse-lite@^1.0.30001219:
4511+
version "1.0.30001221"
4512+
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001221.tgz#b916721ddf59066cfbe96c5c9a77cf7ae5c52e65"
4513+
integrity sha512-b9TOZfND3uGSLjMOrLh8XxSQ41x8mX+9MLJYDM4AAHLfaZHttrLNPrScWjVnBITRZbY5sPpCt7X85n7VSLZ+/g==
4514+
44444515
capital-case@^1.0.4:
44454516
version "1.0.4"
44464517
resolved "https://registry.yarnpkg.com/capital-case/-/capital-case-1.0.4.tgz#9d130292353c9249f6b00fa5852bee38a717e669"
@@ -5092,6 +5163,14 @@ core-js-compat@^3.8.1, core-js-compat@^3.9.0:
50925163
browserslist "^4.16.3"
50935164
semver "7.0.0"
50945165

5166+
core-js-compat@^3.9.1:
5167+
version "3.11.2"
5168+
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.11.2.tgz#5048e367851cfd2c6c0cb81310757b4da296e385"
5169+
integrity sha512-gYhNwu7AJjecNtRrIfyoBabQ3ZG+llfPmg9BifIX8yxIpDyfNLRM73zIjINSm6z3dMdI1nwNC9C7uiy4pIC6cw==
5170+
dependencies:
5171+
browserslist "^4.16.6"
5172+
semver "7.0.0"
5173+
50955174
core-js-pure@^3.0.0:
50965175
version "3.10.1"
50975176
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.10.1.tgz#28642697dfcf02e0fd9f4d9891bd03a22df28ecf"
@@ -5855,6 +5934,11 @@ electron-to-chromium@^1.3.649:
58555934
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.709.tgz#d7be0b5686a2fdfe8bad898faa3a428d04d8f656"
58565935
integrity sha512-LolItk2/ikSGQ7SN8UkuKVNMBZp3RG7Itgaxj1npsHRzQobj9JjMneZOZfLhtwlYBe5fCJ75k+cVCiDFUs23oA==
58575936

5937+
electron-to-chromium@^1.3.723:
5938+
version "1.3.726"
5939+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.726.tgz#6d3c577e5f5a48904ba891464740896c05e3bdb1"
5940+
integrity sha512-dw7WmrSu/JwtACiBzth8cuKf62NKL1xVJuNvyOg0jvruN/n4NLtGYoTzciQquCPNaS2eR+BT5GrxHbslfc/w1w==
5941+
58585942
emittery@^0.7.1:
58595943
version "0.7.2"
58605944
resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.7.2.tgz#25595908e13af0f5674ab419396e2fb394cdfa82"
@@ -9866,7 +9950,7 @@ node-notifier@^8.0.0:
98669950
uuid "^8.3.0"
98679951
which "^2.0.2"
98689952

9869-
node-releases@^1.1.70:
9953+
node-releases@^1.1.70, node-releases@^1.1.71:
98709954
version "1.1.71"
98719955
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.71.tgz#cb1334b179896b1c89ecfdd4b725fb7bbdfc7dbb"
98729956
integrity sha512-zR6HoT6LrLCRBwukmrVbHv0EpEQjksO6GmFcZQQuCAy139BEsoVKPYnf3jongYW83fAa1torLGYwxxky/p28sg==

0 commit comments

Comments
 (0)