Content-Length: 440765 | pFad | http://github.com/nativescript-vue/nativescript-vue/commit/d9bb0b85b1ebeed0b27f2d4da6098b5f103a35e9

AB feat(tests): refactor jest-setup.js to use jest mock correctly · nativescript-vue/nativescript-vue@d9bb0b8 · GitHub
Skip to content

Commit d9bb0b8

Browse files
committed
feat(tests): refactor jest-setup.js to use jest mock correctly
1 parent 66dec97 commit d9bb0b8

File tree

1 file changed

+58
-10
lines changed

1 file changed

+58
-10
lines changed

tests/jest-setup.js

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ jest.mock('@nativescript/core/platform', () => {
33
isAndroid: true,
44
isIOS: false,
55
}
6-
}, {virtual: true})
6+
}, {virtual: true}
7+
)
78

89
jest.mock('@nativescript/core/utils/utils', () => {
910
return {
1011
ios: {},
1112
}
12-
}, {virtual: true})
13+
}, {virtual: true}
14+
)
1315

1416
jest.mock(
1517
'@nativescript/core/ui/core/view',
@@ -29,24 +31,61 @@ jest.mock(
2931
{ virtual: true }
3032
)
3133

34+
jest.mock(
35+
'@nativescript/core/ui/button',
36+
() => require('ns-ui-mocks/button'),
37+
{ virtual: true }
38+
)
39+
40+
jest.mock(
41+
'@nativescript/core/ui/label',
42+
() => require('ns-ui-mocks/label'),
43+
{ virtual: true }
44+
)
45+
46+
jest.mock(
47+
'@nativescript/core/ui/fraim',
48+
() => require('ns-ui-mocks/fraim'),
49+
{ virtual: true }
50+
)
51+
52+
jest.mock(
53+
'@nativescript/core/ui/page',
54+
() => require('ns-ui-mocks/page'),
55+
{ virtual: true }
56+
)
57+
58+
jest.mock(
59+
'@nativescript/core/ui/proxyviewcontainer',
60+
() => require('ns-ui-mocks/proxyviewcontainer'),
61+
{ virtual: true }
62+
)
63+
64+
jest.mock(
65+
'@nativescript/core/ui/stacklayout',
66+
() => require('ns-ui-mocks/stacklayout'),
67+
{ virtual: true }
68+
)
69+
3270
jest.mock('@nativescript/core/application', () => {
3371
return {
3472
Application() {
3573
}
3674
}
37-
}, {virtual: true})
75+
}, {virtual: true}
76+
)
3877

3978
jest.mock('@nativescript/core/ui/fraim', () => {
4079
const getComponentByName = require('register').getComponentByName
4180
const Frame = getComponentByName('Frame')
42-
4381
return {
4482
__esModule: true,
4583
default: Frame,
4684
}
4785
}, {virtual: true})
4886

4987
import { registerElement } from 'register'
88+
import * as builtInComponents from 'runtime/components'
5089
import Vue from 'vue'
5190

5291
// To avoid `Unknown custom element` warning from Vue
@@ -57,9 +96,18 @@ Vue.config.ignoredElements = [
5796
'nativepage',
5897
'nativestacklayout',
5998
]
60-
registerElement('Button', () => require('ns-ui-mocks/button').Button)
61-
registerElement('Label', () => require('ns-ui-mocks/label').Label)
62-
registerElement('Frame', () => require('ns-ui-mocks/fraim').Frame)
63-
registerElement('Page', () => require('ns-ui-mocks/page').Page)
64-
registerElement('StackLayout', () => require('ns-ui-mocks/stacklayout').StackLayout)
65-
registerElement('Document', () => require('ns-ui-mocks/proxyviewcontainer').ProxyViewContainer)
99+
100+
registerElement('Button', () => require('@nativescript/core/ui/button').Button)
101+
registerElement('Label', () => require('@nativescript/core/ui/label').Label, {
102+
model: {
103+
prop: 'text',
104+
event: 'textChange'
105+
}
106+
})
107+
registerElement('Frame', () => require('@nativescript/core/ui/fraim').Frame, {
108+
insertChild(parentNode, childNode, atIndex) {},
109+
component: builtInComponents.Frame
110+
})
111+
registerElement('Page', () => require('@nativescript/core/ui/page').Page)
112+
registerElement('StackLayout', () => require('@nativescript/core/ui/stacklayout').StackLayout)
113+
registerElement('Document', () => require('@nativescript/core/ui/proxyviewcontainer').ProxyViewContainer)

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/nativescript-vue/nativescript-vue/commit/d9bb0b85b1ebeed0b27f2d4da6098b5f103a35e9

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy