Skip to content

Commit

Permalink
test(preset): add test cases for getHostPkgAlias util
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Mar 27, 2020
1 parent f61e226 commit c054f5d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "normal"
}
22 changes: 22 additions & 0 deletions packages/preset-dumi/src/utils/getHostPkgAlias.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import path from 'path';
import getHostPkgAlias from './getHostPkgAlias';

describe('getHostPkgAlias', () => {
it('get normal pkg alias', () => {
const pkgPath = path.join(__dirname, 'fixtures/alias-normal');
const { name: pkgName } = require(path.join(pkgPath, 'package.json'));

expect(getHostPkgAlias({ cwd: pkgPath })).toEqual([[pkgName, pkgPath]]);
});

it('get lerna pkg alias', () => {
const alias = getHostPkgAlias({ cwd: path.join(__dirname, '../../../../') });

expect(alias.map(([name]) => name)).toEqual([
'@umijs/create-dumi-app',
'@umijs/create-dumi-lib',
'dumi',
'@umijs/preset-dumi',
]);
});
});

0 comments on commit c054f5d

Please sign in to comment.