-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppCard.test.tsx
76 lines (59 loc) 路 1.77 KB
/
AppCard.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
import { BlueBaseApp, createPlugin } from '@bluebase/core';
import { AppCard } from '../AppCard';
import Plugin from '../../../index';
import React from 'react';
import { mount } from 'enzyme';
import { waitForElement } from 'enzyme-async-helpers';
export const ThingsPlugin = createPlugin({
key: 'things',
name: 'thingsplugin',
version: '1.0.0',
});
export const SitesIconPlugin = createPlugin({
key: 'sites',
name: 'Sitesplugin',
version: '1.0.0',
icon: {
component: 'SitesAppIcon',
type: 'icon',
},
});
jest.doMock('../../Column', () => {
const ComponentToMock = () => <div />;
return ComponentToMock;
});
describe('AppCard', () => {
it('should return plugin defaultIcon ', async () => {
const wrapper = mount(
<BlueBaseApp plugins={[ThingsPlugin, Plugin]}>
<AppCard plugin={ThingsPlugin as any} size={20} />
</BlueBaseApp>
);
await waitForElement(wrapper, 'TouchableItem');
const onPress = (wrapper as any)
.find('TouchableItem')
.last()
.prop('onPress');
onPress();
expect(
(wrapper as any)
.find('LauncherDefaultIcon')
.last()
.prop('size')
).toBe(20);
});
it('should return plugin with icon', async () => {
const wrapper = mount(
<BlueBaseApp plugins={[SitesIconPlugin, Plugin]}>
<AppCard plugin={SitesIconPlugin as any} size={20} />
</BlueBaseApp>
);
await waitForElement(wrapper, 'TouchableItem');
expect(
(wrapper as any)
.find('PluginIcon')
.last()
.prop('size')
).toBe(20);
});
});