Skip to content

Commit

Permalink
update util.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Yokozuna59 committed Nov 9, 2023
1 parent b446ab3 commit 436e30c
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions cypress/helpers/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ const convertUtf8ToBase64 = (str: string): string => {
*/
export const createMermaidUrl = (
diagramStr: string,
options?: CypressMermaidConfig,
api?: boolean
options: CypressMermaidConfig = {},
api: boolean = false
): string => {
const codeObject: CodeObject = {
code: diagramStr,
mermaid: options || {},
mermaid: options,
};
const objStr: string = JSON.stringify(codeObject);
const url = `http://localhost:9000/${api ? 'xss' : 'e2e'}.html?graph=${convertUtf8ToBase64(
Expand All @@ -68,14 +68,11 @@ export const createMermaidUrl = (
*/
export const openUrlAndVerifyRendering = (
url: string,
options?: CypressMermaidConfig,
options: CypressMermaidConfig = {},
validation?: any
): void => {
const useAppli: boolean = Cypress.env('useAppli');
const name: string = ((options && options.name) || cy.state('runnable').fullTitle()).replace(
/\s+/g,
'-'
);
const name: string = (options?.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');

if (useAppli) {
cy.log(`Opening eyes ${Cypress.spec.name} --- ${name}`);
Expand Down Expand Up @@ -114,8 +111,8 @@ export const openUrlAndVerifyRendering = (
*/
export const imgSnapshotTest = (
diagramStr: string,
_options?: CypressMermaidConfig,
api?: boolean,
_options: CypressMermaidConfig = {},
api: boolean = false,
validation?: any
): void => {
cy.log(JSON.stringify(_options));
Expand Down Expand Up @@ -143,8 +140,8 @@ export const imgSnapshotTest = (
*/
export const urlSnapshotTest = (
url: string,
_options?: CypressMermaidConfig,
_api?: boolean,
_options: CypressMermaidConfig = {},
_api: boolean = false,
validation?: any
): void => {
const options: CypressMermaidConfig = Object.assign(_options);
Expand Down

0 comments on commit 436e30c

Please sign in to comment.