Skip to content

Commit

Permalink
Move normalizeIcons function to @jest/test-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoH2O1999 committed Jul 23, 2023
1 parent 7a8c95e commit acbdda3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
13 changes: 2 additions & 11 deletions e2e/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,6 @@ export const extractSummaries = (
.map(({start, end}) => extractSortedSummary(stdout.slice(start, end)));
};

export const normalizeIcons = (str: string) => {
if (!str) {
return str;
}

// Make sure to keep in sync with `jest-util/src/specialChars`
return str
.replace(new RegExp('\u00D7', 'gu'), '\u2715')
.replace(new RegExp('\u221A', 'gu'), '\u2713');
};

// Certain environments (like CITGM and GH Actions) do not come with mercurial installed
let hgIsInstalled: boolean | null = null;

Expand Down Expand Up @@ -369,3 +358,5 @@ export const testIfSlAndHg = (...args: Parameters<typeof test>) => {
test.skip(...args);
}
};

export {normalizeIcons} from '@jest/test-utils';
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import type {
TestCaseResult,
TestResult,
} from '@jest/test-result';
import {normalizeIcons} from '@jest/test-utils';
import type {Config} from '@jest/types';
import {normalizeIcons} from '../../../../e2e/Utils';
import BaseGitHubActionsReporter from '../GitHubActionsReporter';

afterEach(() => {
Expand Down
2 changes: 2 additions & 0 deletions packages/test-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export {
} from './ConditionalTest';

export {makeGlobalConfig, makeProjectConfig} from './config';

export {normalizeIcons} from './normalizeIcons';
17 changes: 17 additions & 0 deletions packages/test-utils/src/normalizeIcons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

export function normalizeIcons(str: string): string {
if (!str) {
return str;
}

// Make sure to keep in sync with `jest-util/src/specialChars`
return str
.replace(new RegExp('\u00D7', 'gu'), '\u2715')
.replace(new RegExp('\u221A', 'gu'), '\u2713');
}

0 comments on commit acbdda3

Please sign in to comment.