Skip to content

Commit 6ff4489

Browse files
committed
update util.ts
1 parent b446ab3 commit 6ff4489

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

cypress/helpers/util.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ const convertUtf8ToBase64 = (str: string): string => {
3939
*/
4040
export const createMermaidUrl = (
4141
diagramStr: string,
42-
options?: CypressMermaidConfig,
43-
api?: boolean
42+
options: CypressMermaidConfig = {},
43+
api: boolean = false
4444
): string => {
4545
const codeObject: CodeObject = {
4646
code: diagramStr,
47-
mermaid: options || {},
47+
mermaid: options,
4848
};
4949
const objStr: string = JSON.stringify(codeObject);
5050
const url = `http://localhost:9000/${api ? 'xss' : 'e2e'}.html?graph=${convertUtf8ToBase64(
@@ -68,14 +68,13 @@ export const createMermaidUrl = (
6868
*/
6969
export const openUrlAndVerifyRendering = (
7070
url: string,
71-
options?: CypressMermaidConfig,
71+
options: CypressMermaidConfig = {},
7272
validation?: any
7373
): void => {
7474
const useAppli: boolean = Cypress.env('useAppli');
75-
const name: string = ((options && options.name) || cy.state('runnable').fullTitle()).replace(
76-
/\s+/g,
77-
'-'
78-
);
75+
const name: string = (
76+
options && options.name ? options.name : cy.state('runnable').fullTitle()
77+
).replace(/\s+/g, '-');
7978

8079
if (useAppli) {
8180
cy.log(`Opening eyes ${Cypress.spec.name} --- ${name}`);
@@ -114,8 +113,8 @@ export const openUrlAndVerifyRendering = (
114113
*/
115114
export const imgSnapshotTest = (
116115
diagramStr: string,
117-
_options?: CypressMermaidConfig,
118-
api?: boolean,
116+
_options: CypressMermaidConfig = {},
117+
api: boolean = false,
119118
validation?: any
120119
): void => {
121120
cy.log(JSON.stringify(_options));
@@ -143,8 +142,8 @@ export const imgSnapshotTest = (
143142
*/
144143
export const urlSnapshotTest = (
145144
url: string,
146-
_options?: CypressMermaidConfig,
147-
_api?: boolean,
145+
_options: CypressMermaidConfig = {},
146+
_api: boolean = false,
148147
validation?: any
149148
): void => {
150149
const options: CypressMermaidConfig = Object.assign(_options);

0 commit comments

Comments
 (0)