Total Complexity | 10 |
Complexity/F | 2.5 |
Lines of Code | 46 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | /** |
||
5 | import Plugin from '../../../src/plugin/js/index' |
||
6 | import {clickNode} from '../../../src/plugin/js/utilities' |
||
7 | import {getElem} from './helpers' |
||
8 | import {createLocalVue} from 'vue-test-utils' |
||
9 | |||
10 | export function setupVmWithLocalVue() { |
||
11 | let LocalVue = createLocalVue() |
||
12 | LocalVue.config.productionTip = false |
||
13 | LocalVue.use(Plugin) |
||
14 | |||
15 | let node = document.createElement("div") |
||
16 | node.id = 'app' |
||
17 | document.querySelector('body').appendChild(node) |
||
18 | |||
19 | return (new LocalVue({ |
||
20 | methods: { |
||
21 | triggerAlert(){ |
||
22 | return this.$dialog.alert('Simple Alert') |
||
23 | }, |
||
24 | triggerConfirm(){ |
||
25 | return this.$dialog.confirm('Please confirm') |
||
26 | }, |
||
27 | clickDialogBtn |
||
28 | } |
||
29 | })).$mount(node) |
||
30 | } |
||
31 | |||
32 | function clickDialogBtn(dgBtn = 'ok', idx = null) { |
||
33 | let selector = (dgBtn === 'ok') ? '.dg-btn--ok' : '.dg-btn--cancel' |
||
34 | let node, nodes = getElem(selector, true) |
||
35 | |||
36 | if (nodes.length > 0) { |
||
37 | if (idx === null) { |
||
38 | // click the last |
||
39 | clickNode(nodes[nodes.length - 1]) |
||
40 | } else if (idx === true) { |
||
41 | // click all |
||
42 | for (let i = 0; i < nodes.length; i++) { |
||
43 | clickNode(nodes[i]) |
||
44 | } |
||
45 | } else if (node = nodes[parseInt(idx)]) { |
||
46 | // click at index |
||
47 | clickNode(node) |
||
48 | } |
||
49 | } |
||
50 | } |
||
51 |