-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathCanisterConfigureMethodCallDialog.spec.ts
More file actions
63 lines (53 loc) · 1.9 KB
/
CanisterConfigureMethodCallDialog.spec.ts
File metadata and controls
63 lines (53 loc) · 1.9 KB
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
import { Principal } from '@icp-sdk/core/principal';
import { describe, expect, it, vi } from 'vitest';
import { StationService } from '~/services/station.service';
import { mount } from '~/test.utils';
import CanisterConfigureMethodCallDialog from './CanisterConfigureMethodCallDialog.vue';
vi.mock('~/services/station.service', () => {
const mock: Partial<StationService> = {
withStationId: vi.fn().mockReturnThis(),
changeExternalCanister: vi.fn().mockImplementation(() => Promise.reject()),
};
return {
StationService: vi.fn(() => mock),
};
});
describe('CanisterConfigureMethodCallDialog', () => {
it('renders default card open is true', () => {
const wrapper = mount(CanisterConfigureMethodCallDialog, {
props: {
open: true,
canisterId: Principal.fromText('r7inp-6aaaa-aaaaa-aaabq-cai'),
method: {
methodName: 'test',
validationTarget: { No: null },
requestPolicies: [],
},
attach: true, // disables teleport in VDialog
},
});
const dialog = wrapper.findComponent({ name: 'VDialog' });
expect(dialog.exists()).toBe(true);
const container = dialog.find('[data-test-id="canister-call-card"]');
expect(container).not.toBeNull();
wrapper.unmount();
});
it('renders with form and submit button', async () => {
const wrapper = mount(CanisterConfigureMethodCallDialog, {
props: {
open: true,
canisterId: Principal.fromText('r7inp-6aaaa-aaaaa-aaabq-cai'),
method: {
methodName: 'test',
validationTarget: { No: null },
requestPolicies: [],
},
attach: true, // disables teleport in VDialog
},
});
const form = wrapper.findComponent({ name: 'VForm' });
expect(form.exists()).toBe(true);
const submitBtn = wrapper.find('[data-test-id="submit-btn"]');
expect(submitBtn.exists()).toBe(true);
});
});