File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ export class Extension implements StringifyExtension {
121121 }
122122}
123123
124- function formatAsJSLiteral ( value : string ) {
124+ export function formatAsJSLiteral ( value : string ) {
125125 return `"${ value . replace ( / " / g, '\\"' ) } "`
126126}
127127
Original file line number Diff line number Diff line change @@ -7,7 +7,12 @@ import {
77 type Step ,
88 type UserFlow ,
99} from "@puppeteer/replay"
10- import { Extension , RecorderPlugin , stringifySelector } from "."
10+ import {
11+ Extension ,
12+ formatAsJSLiteral ,
13+ RecorderPlugin ,
14+ stringifySelector ,
15+ } from "."
1116import flow from "./fixtures/Example.json"
1217
1318const extension = new Extension ( )
@@ -176,6 +181,20 @@ describe("Extension", () => {
176181 } )
177182} )
178183
184+ describe ( "formatAsJSLiteral" , ( ) => {
185+ test ( "space" , ( ) => {
186+ expect ( formatAsJSLiteral ( " " ) ) . toBe ( '" "' )
187+ } )
188+
189+ test ( "single quote" , ( ) => {
190+ expect ( formatAsJSLiteral ( "'" ) ) . toBe ( '"\'"' )
191+ } )
192+
193+ test ( "double quote" , ( ) => {
194+ expect ( formatAsJSLiteral ( '"' ) ) . toBe ( '"\\""' )
195+ } )
196+ } )
197+
179198describe ( "stringifySelector" , ( ) => {
180199 test ( "aria" , ( ) => {
181200 expect ( stringifySelector ( "aria/Test" ) ) . toBe ( 'screen.getByText("Test")' )
You can’t perform that action at this time.
0 commit comments