Skip to content

Commit 63a3cab

Browse files
Vite plugin - assert full expected output in placement test
1 parent b303b0d commit 63a3cab

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

packages/devextreme/build/vite-plugin-devextreme.test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ function transform(code: string, plugin: unknown): string {
1919
return result!.code!;
2020
}
2121

22+
function normalize(code: string): string {
23+
return code.replace(/\s+/g, ' ').trim();
24+
}
25+
2226
describe('moveFieldInitializersToConstructor', () => {
2327
test('inserts field initializer after super() in derived class', () => {
2428
const input = `
@@ -140,9 +144,18 @@ describe('moveFieldInitializersToConstructor', () => {
140144
}
141145
}
142146
`;
147+
const expected = `
148+
class Derived extends Base {
149+
constructor(x) {
150+
super();
151+
this.cached = 'init';
152+
this.doSetup();
153+
this.x = x;
154+
}
155+
}
156+
`;
143157
const out = transform(input, moveFieldInitializersToConstructor);
144-
expect(out).toMatch(/super\(\);\s*this\.cached\s*=\s*'init';\s*this\.doSetup\(\);\s*this\.x\s*=\s*x/);
145-
expect(out).not.toMatch(/this\.x\s*=\s*x;\s*this\.cached\s*=\s*'init'/);
158+
expect(normalize(out)).toBe(normalize(expected));
146159
});
147160
});
148161

0 commit comments

Comments
 (0)