Skip to content

Commit 30a6ca0

Browse files
actions-userrenovate[bot]
authored andcommitted
chore: update config files
1 parent ef2cecb commit 30a6ca0

File tree

4 files changed

+76
-55
lines changed

4 files changed

+76
-55
lines changed

src/add-click-event.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
export default (diagram, options = {}) =>
2-
diagram.replace(/^(\s*click\s+[^\s]+\s*)$/gm, `$1 mermaidClick_${options.id}`)
2+
diagram.replace(
3+
/^(\s*click\s+[^\s]+\s*)$/gm,
4+
`$1 mermaidClick_${options.id}`,
5+
);

src/add-click-event.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { endent } from '@dword-design/functions'
2-
import tester from '@dword-design/tester'
1+
import { endent } from '@dword-design/functions';
2+
import tester from '@dword-design/tester';
33

4-
import self from './add-click-event.js'
4+
import self from './add-click-event.js';
55

66
export default tester(
77
{
@@ -32,4 +32,4 @@ export default tester(
3232
expect(self(test.subject, { id: '<id>' })).toEqual(test.result),
3333
},
3434
],
35-
)
35+
);

src/index.spec.js

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { endent, filter } from '@dword-design/functions'
2-
import tester from '@dword-design/tester'
3-
import testerPluginComponent from '@dword-design/tester-plugin-component'
4-
import { expect } from '@playwright/test'
5-
import { createRequire } from 'module'
6-
import { chromium } from 'playwright'
1+
import { endent, filter } from '@dword-design/functions';
2+
import tester from '@dword-design/tester';
3+
import testerPluginComponent from '@dword-design/tester-plugin-component';
4+
import { expect } from '@playwright/test';
5+
import { createRequire } from 'module';
6+
import { chromium } from 'playwright';
77

8-
const resolver = createRequire(import.meta.url)
8+
const resolver = createRequire(import.meta.url);
99

1010
export default tester(
1111
{
@@ -41,12 +41,13 @@ export default tester(
4141
</script>
4242
`,
4343
async test() {
44-
await this.page.goto('http://localhost:3000')
45-
await this.page.waitForSelector('.foo svg')
46-
await this.page.click('button')
44+
await this.page.goto('http://localhost:3000');
45+
await this.page.waitForSelector('.foo svg');
46+
await this.page.click('button');
47+
4748
expect(await this.page.screenshot('.foo svg')).toMatchImageSnapshot(
4849
this,
49-
)
50+
);
5051
},
5152
},
5253
click: {
@@ -90,28 +91,32 @@ export default tester(
9091
</script>
9192
`,
9293
async test() {
93-
const callbackPrefix = 'mermaidClick_'
94-
await this.page.goto('http://localhost:3000')
94+
const callbackPrefix = 'mermaidClick_';
95+
await this.page.goto('http://localhost:3000');
96+
9597
await this.page.waitForSelector(
9698
'.diagram a[*|href="https://google.com"] .node[id^=flowchart-A-]',
97-
)
99+
);
100+
98101
expect(
99102
(
100103
this.page.evaluate(() => Object.keys(window))
101104
|> await
102105
|> filter(key => key.startsWith(callbackPrefix))
103106
).length,
104-
).toEqual(1)
105-
await this.page.click('.diagram .node[id^=flowchart-B-]')
106-
await this.page.waitForSelector('.diagram.clicked')
107-
await this.page.click('.hide-button')
107+
).toEqual(1);
108+
109+
await this.page.click('.diagram .node[id^=flowchart-B-]');
110+
await this.page.waitForSelector('.diagram.clicked');
111+
await this.page.click('.hide-button');
112+
108113
expect(
109114
(
110115
this.page.evaluate(() => Object.keys(window))
111116
|> await
112117
|> filter(key => key.startsWith(callbackPrefix))
113118
).length,
114-
).toEqual(0)
119+
).toEqual(0);
115120
},
116121
},
117122
/* 'click: multiple diagrams': {
@@ -206,10 +211,11 @@ export default tester(
206211
</script>
207212
`,
208213
async test() {
209-
await this.page.goto('http://localhost:3000')
214+
await this.page.goto('http://localhost:3000');
215+
210216
await expect(this.page.locator('.foo')).toHaveText(
211217
'UnknownDiagramError: No diagram type detected matching given configuration for text: foo',
212-
)
218+
);
213219
},
214220
},
215221
options: {
@@ -233,10 +239,11 @@ export default tester(
233239
</script>
234240
`,
235241
async test() {
236-
await this.page.goto('http://localhost:3000')
242+
await this.page.goto('http://localhost:3000');
243+
237244
expect(
238245
await this.page.locator('.foo svg').screenshot(),
239-
).toMatchImageSnapshot(this)
246+
).toMatchImageSnapshot(this);
240247
},
241248
},
242249
works: {
@@ -260,23 +267,24 @@ export default tester(
260267
</script>
261268
`,
262269
async test() {
263-
await this.page.goto('http://localhost:3000')
270+
await this.page.goto('http://localhost:3000');
271+
264272
expect(
265273
await this.page.locator('.foo svg').screenshot(),
266-
).toMatchImageSnapshot(this)
274+
).toMatchImageSnapshot(this);
267275
},
268276
},
269277
},
270278
[
271279
testerPluginComponent({ componentPath: resolver.resolve('./index.vue') }),
272280
{
273281
async after() {
274-
await this.browser.close()
282+
await this.browser.close();
275283
},
276284
async before() {
277-
this.browser = await chromium.launch()
278-
this.page = await this.browser.newPage()
285+
this.browser = await chromium.launch();
286+
this.page = await this.browser.newPage();
279287
},
280288
},
281289
],
282-
)
290+
);

src/index.vue

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,42 @@
33
</template>
44

55
<script>
6-
import mermaid from 'mermaid'
7-
import { nanoid } from 'nanoid'
6+
import mermaid from 'mermaid';
7+
import { nanoid } from 'nanoid';
88
9-
import addClickEvent from './add-click-event.js'
9+
import addClickEvent from './add-click-event.js';
1010
1111
export default {
1212
beforeUnmount() {
1313
if (typeof window === 'undefined') {
14-
return
14+
return;
1515
}
16-
delete window[`mermaidClick_${this.id}`]
16+
17+
delete window[`mermaidClick_${this.id}`];
1718
},
1819
computed: {
1920
allData() {
20-
return [this.finalValue, this.id]
21+
return [this.finalValue, this.id];
2122
},
2223
finalValue() {
23-
return addClickEvent(this.value, { id: this.id })
24+
return addClickEvent(this.value, { id: this.id });
2425
},
2526
},
2627
data: () => ({ id: undefined }),
2728
emits: ['node-click', 'parse-error', 'rendered'],
2829
mounted() {
2930
if (typeof window === 'undefined') {
30-
return
31+
return;
3132
}
33+
3234
mermaid.initialize({
3335
securityLevel: 'loose',
3436
startOnLoad: false,
3537
theme: 'default',
3638
...this.options,
37-
})
38-
this.id = nanoid()
39+
});
40+
41+
this.id = nanoid();
3942
},
4043
name: 'VueMermaidString',
4144
props: {
@@ -47,39 +50,46 @@ export default {
4750
flush: 'post',
4851
async handler() {
4952
if (typeof window === 'undefined') {
50-
return
53+
return;
5154
}
55+
5256
if (!this.finalValue) {
53-
return
57+
return;
5458
}
59+
5560
if (!this.id) {
56-
return
61+
return;
5762
}
58-
this.$el.removeAttribute('data-processed')
59-
mermaid.parseError = error => this.$emit('parse-error', error)
63+
64+
this.$el.removeAttribute('data-processed');
65+
mermaid.parseError = error => this.$emit('parse-error', error);
66+
6067
await mermaid.run({
6168
nodes: [this.$el],
6269
postRenderCallback: () => this.$emit('rendered'),
63-
})
70+
});
6471
},
6572
immediate: true,
6673
},
6774
id: {
6875
handler(id, previousId) {
6976
if (typeof window === 'undefined') {
70-
return
77+
return;
7178
}
79+
7280
if (previousId) {
73-
delete window[`mermaidClick_${previousId}`]
81+
delete window[`mermaidClick_${previousId}`];
7482
}
83+
7584
if (!this.id) {
76-
return
85+
return;
7786
}
87+
7888
window[`mermaidClick_${this.id}`] = nodeId =>
79-
this.$emit('node-click', nodeId)
89+
this.$emit('node-click', nodeId);
8090
},
8191
immediate: true,
8292
},
8393
},
84-
}
94+
};
8595
</script>

0 commit comments

Comments
 (0)