@@ -39,12 +39,12 @@ const convertUtf8ToBase64 = (str: string): string => {
39
39
*/
40
40
export const createMermaidUrl = (
41
41
diagramStr : string ,
42
- options ? : CypressMermaidConfig ,
43
- api ? : boolean
42
+ options : CypressMermaidConfig = { } ,
43
+ api : boolean = false
44
44
) : string => {
45
45
const codeObject : CodeObject = {
46
46
code : diagramStr ,
47
- mermaid : options || { } ,
47
+ mermaid : options ,
48
48
} ;
49
49
const objStr : string = JSON . stringify ( codeObject ) ;
50
50
const url = `http://localhost:9000/${ api ? 'xss' : 'e2e' } .html?graph=${ convertUtf8ToBase64 (
@@ -68,14 +68,13 @@ export const createMermaidUrl = (
68
68
*/
69
69
export const openUrlAndVerifyRendering = (
70
70
url : string ,
71
- options ? : CypressMermaidConfig ,
71
+ options : CypressMermaidConfig = { } ,
72
72
validation ?: any
73
73
) : void => {
74
74
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, '-' ) ;
79
78
80
79
if ( useAppli ) {
81
80
cy . log ( `Opening eyes ${ Cypress . spec . name } --- ${ name } ` ) ;
@@ -114,18 +113,21 @@ export const openUrlAndVerifyRendering = (
114
113
*/
115
114
export const imgSnapshotTest = (
116
115
diagramStr : string ,
117
- _options ? : CypressMermaidConfig ,
118
- api ? : boolean ,
116
+ _options : CypressMermaidConfig = { } ,
117
+ api : boolean = false ,
119
118
validation ?: any
120
119
) : void => {
121
120
cy . log ( JSON . stringify ( _options ) ) ;
122
121
const options : CypressMermaidConfig = {
123
- ...( _options || { } ) ,
124
- fontFamily : _options ? .fontFamily || 'courier' ,
125
- fontSize : _options ? .fontSize || 16 ,
122
+ ..._options ,
123
+ fontFamily : _options && _options . fontFamily ? _options . fontFamily : 'courier' ,
124
+ fontSize : _options && _options . fontSize ? _options . fontSize : 16 ,
126
125
sequence : {
127
126
actorFontFamily : 'courier' ,
128
- noteFontFamily : _options ?. sequence ?. noteFontFamily || 'courier' ,
127
+ noteFontFamily :
128
+ _options && _options . sequence && _options . sequence . noteFontFamily
129
+ ? _options ?. sequence ?. noteFontFamily
130
+ : 'courier' ,
129
131
messageFontFamily : 'courier' ,
130
132
} ,
131
133
} ;
@@ -143,8 +145,8 @@ export const imgSnapshotTest = (
143
145
*/
144
146
export const urlSnapshotTest = (
145
147
url : string ,
146
- _options ? : CypressMermaidConfig ,
147
- _api ? : boolean ,
148
+ _options : CypressMermaidConfig = { } ,
149
+ _api : boolean = false ,
148
150
validation ?: any
149
151
) : void => {
150
152
const options : CypressMermaidConfig = Object . assign ( _options ) ;
0 commit comments