Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 7fd196e

Browse files
committed
test: add unit tests that correct alias is added depending if @nativescript/core is at the root of node_modules
1 parent 061b270 commit 7fd196e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

templates/webpack.config.spec.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as proxyquire from 'proxyquire';
22
import * as nsWebpackIndex from '../index';
33
import { join } from 'path';
4-
import { skipPartiallyEmittedExpressions } from 'typescript';
54
// With noCallThru enabled, `proxyquire` will not fall back to requiring the real module to populate properties that are not mocked.
65
// This allows us to mock packages that are not available in node_modules.
76
// In case you want to enable fallback for a specific object, just add `'@noCallThru': false`.
@@ -359,6 +358,27 @@ describe('webpack.config.js', () => {
359358
expect(config.output.sourceMapFilename).toEqual(join("..", newSourceMapFolder, "[file].map"));
360359
});
361360
});
361+
362+
describe(`alias for webpack.${type}.js (${platform})`, () => {
363+
it('should add alias when @nativescript/core is at the root of node_modules', () => {
364+
nativeScriptDevWebpack.hasRootLevelScopedModules = () => true;
365+
const input = getInput({ platform });
366+
const config = webpackConfig(input);
367+
expect(config.resolve.alias['tns-core-modules']).toBe('@nativescript/core');
368+
if (type === 'angular') {
369+
expect(config.resolve.alias['nativescript-angular']).toBe('@nativescript/angular');
370+
}
371+
});
372+
it('shouldn\'t add alias when @nativescript/core is not at the root of node_modules', () => {
373+
nativeScriptDevWebpack.hasRootLevelScopedModules = () => false;
374+
const input = getInput({ platform });
375+
const config = webpackConfig(input);
376+
expect(config.resolve.alias['tns-core-modules']).toBeUndefined();
377+
if (type === 'angular') {
378+
expect(config.resolve.alias['nativescript-angular']).toBeUndefined();
379+
}
380+
});
381+
});
362382
});
363383
});
364384
});

0 commit comments

Comments
 (0)