-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(rsbuild-plugin-angular): test devkit for different ng versions
- Loading branch information
Showing
6 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/rsbuild-plugin-angular/src/lib/plugin/utils/devkit-import-ng-16.unit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { describe, expect } from 'vitest'; | ||
|
||
vi.mock('@angular/compiler-cli', async () => { | ||
const actual = await vi.importActual('@angular/compiler-cli'); | ||
return { | ||
...actual, | ||
VERSION: { | ||
major: 16, | ||
minor: 4, | ||
patch: 2, | ||
}, | ||
}; | ||
}); | ||
|
||
describe('devkit importing an angular version >=16 & <18', async () => { | ||
// @TODO fins a way to mock require calls instead of testing the error | ||
it('should return the exports', async () => { | ||
expect(import('./devkit.ts')).rejects.toThrow( | ||
'@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js' | ||
); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
packages/rsbuild-plugin-angular/src/lib/plugin/utils/devkit-import-ng-next.unit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { describe, expect } from 'vitest'; | ||
|
||
vi.mock('@angular/compiler-cli', async () => { | ||
const actual = await vi.importActual('@angular/compiler-cli'); | ||
return { | ||
...actual, | ||
VERSION: { | ||
major: 19, | ||
minor: 4, | ||
patch: 2, | ||
}, | ||
}; | ||
}); | ||
|
||
describe('devkit importing an angular version >=19', async () => { | ||
it('should return the exports', async () => { | ||
expect(import('./devkit.ts')).resolves.toStrictEqual( | ||
expect.objectContaining({ | ||
JavaScriptTransformer: expect.any(Function), | ||
SourceFileCache: expect.any(Function), | ||
angularMajor: 19, | ||
angularMinor: 4, | ||
angularPatch: 2, | ||
createJitResourceTransformer: expect.any(Function), | ||
}) | ||
); | ||
}); | ||
}); |
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
packages/rsbuild-plugin-angular/src/lib/plugin/utils/devkit-import-ng15.unit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { describe, expect } from 'vitest'; | ||
|
||
vi.mock('@angular/compiler-cli', async () => { | ||
const actual = await vi.importActual('@angular/compiler-cli'); | ||
return { | ||
...actual, | ||
VERSION: { | ||
major: 15, | ||
minor: 4, | ||
patch: 2, | ||
}, | ||
}; | ||
}); | ||
|
||
describe('devkit importing an angular version >=15 & <16', async () => { | ||
// @TODO fins a way to mock require calls instead of testing the error | ||
it('should return the exports', async () => { | ||
expect(import('./devkit.ts')).rejects.toThrow( | ||
'@angular-devkit/build-angular/src/builders/browser-esbuild/compiler-plugin.js' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters