Skip to content

Commit 215ed10

Browse files
committed
Make test more precise
1 parent 99f3845 commit 215ed10

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/interpolations/interpolations.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,27 @@ import { format } from 'prettier';
44
import { plugin } from './../../src/index';
55

66
describe('Interpolations', () => {
7+
const backupProcessEnv: Record<string, string | undefined> = process.env;
8+
9+
afterEach(() => {
10+
process.env = { ...backupProcessEnv };
11+
});
12+
713
test('should handle Neutral interpolations', () => {
814
const expected: string = readFileSync(resolve(__dirname, 'formatted_none.pug'), 'utf8');
915
const code: string = readFileSync(resolve(__dirname, 'unformatted_none.pug'), 'utf8');
1016
const actual: string = format(code, { parser: 'pug', plugins: [plugin] });
1117

1218
expect(actual).toBe(expected);
1319
});
20+
1421
test('should handle Angular interpolations', () => {
1522
const expected: string = readFileSync(resolve(__dirname, 'formatted_angular.pug'), 'utf8');
1623
const code: string = readFileSync(resolve(__dirname, 'unformatted_angular.pug'), 'utf8');
24+
25+
// process.env should be ignored
26+
process.env.npm_package_dependencies_vue = 'some version';
27+
1728
const actual: string = format(code, {
1829
parser: 'pug',
1930
plugins: [plugin],
@@ -23,9 +34,14 @@ describe('Interpolations', () => {
2334

2435
expect(actual).toBe(expected);
2536
});
37+
2638
test('should handle Vue interpolations', () => {
2739
const expected: string = readFileSync(resolve(__dirname, 'formatted_vue.pug'), 'utf8');
2840
const code: string = readFileSync(resolve(__dirname, 'unformatted_vue.pug'), 'utf8');
41+
42+
// process.env should be ignored
43+
process.env.npm_package_devDependencies_svelte = 'some version';
44+
2945
const actual: string = format(code, {
3046
parser: 'pug',
3147
plugins: [plugin],

0 commit comments

Comments
 (0)