chore: do not string replace with self in test (#14588)

This commit is contained in:
Simen Bekkhus 2023-10-02 11:10:28 +02:00 committed by GitHub
parent 5aeee2efc5
commit 85278ee979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 10 deletions

View File

@ -76,16 +76,14 @@ jest
jest.mock(
'test_preprocessor',
() => {
const escapeStrings = (str: string) => str.replace(/'/, "'");
const transformer: Transformer = {
getCacheKey: jest.fn(() => 'ab'),
process: (content, filename, config) => ({
code: (require('dedent') as typeof import('dedent').default)`
const TRANSFORMED = {
filename: '${escapeStrings(filename)}',
script: '${escapeStrings(content)}',
config: '${escapeStrings(JSON.stringify(config))}',
filename: '${filename}',
script: '${content}',
config: '${JSON.stringify(config)}',
};
`,
}),
@ -99,17 +97,15 @@ jest.mock(
jest.mock(
'test_async_preprocessor',
() => {
const escapeStrings = (str: string) => str.replace(/'/, "'");
const transformer: AsyncTransformer = {
getCacheKeyAsync: jest.fn(() => Promise.resolve('ab')),
processAsync: (content, filename, config) =>
Promise.resolve({
code: (require('dedent') as typeof import('dedent').default)`
const TRANSFORMED = {
filename: '${escapeStrings(filename)}',
script: '${escapeStrings(content)}',
config: '${escapeStrings(JSON.stringify(config))}',
filename: '${filename}',
script: '${content}',
config: '${JSON.stringify(config)}',
};
`,
}),