mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00

* feat: file replacement handling for TS and pure file copy replacements * test: add tests for replacements & refactor a bit Co-authored-by: Igor Randjelovic <rigor789@gmail.com>
50 lines
1.0 KiB
TypeScript
50 lines
1.0 KiB
TypeScript
import Config from 'webpack-chain';
|
|
import { resolve } from 'path';
|
|
|
|
import { additionalCopyRules } from '../../src/helpers/copyRules';
|
|
import { default as angular } from '../../src/configuration/angular';
|
|
import { init } from '../../src';
|
|
|
|
jest.mock(
|
|
'@ngtools/webpack',
|
|
() => {
|
|
class AngularCompilerPlugin {}
|
|
|
|
return {
|
|
AngularCompilerPlugin,
|
|
};
|
|
},
|
|
{ virtual: true }
|
|
);
|
|
|
|
describe('angular configuration', () => {
|
|
const platforms = ['ios', 'android'];
|
|
let fsExistsSyncSpy: jest.SpiedFunction<any>;
|
|
|
|
beforeAll(() => {
|
|
const fs = require('fs');
|
|
const original = fs.existsSync;
|
|
fsExistsSyncSpy = jest.spyOn(fs, 'existsSync');
|
|
|
|
fsExistsSyncSpy.mockImplementation((path) => {
|
|
if (path === '__jest__/tsconfig.json') {
|
|
return true;
|
|
}
|
|
return original.call(fs, path);
|
|
});
|
|
});
|
|
|
|
afterAll(() => {
|
|
fsExistsSyncSpy.mockRestore();
|
|
});
|
|
|
|
for (let platform of platforms) {
|
|
it(`for ${platform}`, () => {
|
|
init({
|
|
[platform]: true,
|
|
});
|
|
expect(angular(new Config()).toString()).toMatchSnapshot();
|
|
});
|
|
}
|
|
});
|