-
Notifications
You must be signed in to change notification settings - Fork 0
/
Column.test.tsx
103 lines (76 loc) 路 1.98 KB
/
Column.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// jest.mock("Dimensions");
import { BlueBaseApp, createPlugin } from '@bluebase/core';
import BluebasePluginResponsiveGrid from "@bluebase/plugin-responsive-grid"
import { Column } from '../../Column';
import Plugin from '../../../index';
import React from 'react';
import { mount } from 'enzyme';
import { waitForElement } from 'enzyme-async-helpers';
export const ThingsPlugin: any = createPlugin({
key: 'things',
name: 'thingsplugin',
version: '1.0.0',
icon: {
component: 'SitesAppIcon',
type: 'icon',
},
});
export const SitesIconPlugin: any = createPlugin({
key: 'sites',
name: 'Sitesplugin',
version: '1.0.0',
icon: {
component: 'SitesAppIcon',
type: 'icon',
},
});
describe('AppGrid', () => {
it('should return Column with size 20', async () => {
const Function: any = () => 'View';
const wrapper = mount(
<BlueBaseApp plugins={[BluebasePluginResponsiveGrid, ThingsPlugin, Plugin, SitesIconPlugin]}>
<Column>
{(_size: any) => {
return (<Function />);
}}
</Column>
</BlueBaseApp>
);
await waitForElement(wrapper, Column);
const instance: any = wrapper
.find('ColumnComponent')
.last()
.instance();
instance.onLayout({ nativeEvent: { layout: { width: 20 } } });
expect(
(wrapper as any)
.find('ColumnComponent')
.first()
.prop('children')
).toBeDefined();
});
it('should return plugin with size 0 ', async () => {
const Function: any = () => 'View';
const wrapper = mount(
<BlueBaseApp plugins={[BluebasePluginResponsiveGrid, ThingsPlugin, Plugin, SitesIconPlugin]}>
<Column>
{(_size: any) => {
return (<Function />);
}}
</Column>
</BlueBaseApp>
);
await waitForElement(wrapper, Column);
const instance: any = wrapper
.find('ColumnComponent')
.last()
.instance();
instance.onLayout({ nativeEvent: { layout: { width: 0 } } });
expect(
(wrapper as any)
.find('ColumnComponent')
.first()
.prop('children')
).toBeDefined();
});
});