This repository has been archived by the owner on May 1, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix own-package component directory handling in node resolution. (#941)
- Loading branch information
1 parent
42a13c0
commit 99fa55c
Showing
8 changed files
with
122 additions
and
17 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
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
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,96 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved. | ||
* This code may only be used under the BSD style license found at | ||
* http://polymer.github.io/LICENSE.txt | ||
* The complete set of authors may be found at | ||
* http://polymer.github.io/AUTHORS.txt | ||
* The complete set of contributors may be found at | ||
* http://polymer.github.io/CONTRIBUTORS.txt | ||
* Code distributed by Google as part of the polymer project is also | ||
* subject to an additional IP rights grant found at | ||
* http://polymer.github.io/PATENTS.txt | ||
*/ | ||
|
||
import {assert} from 'chai'; | ||
import * as path from 'path'; | ||
|
||
import {resolve} from '../../javascript/resolve-specifier-node'; | ||
|
||
const rootDir = path.resolve( | ||
__dirname, | ||
'..', | ||
'..', | ||
'..', | ||
'src', | ||
'test', | ||
'static', | ||
'javascript', | ||
'resolve-specifier-node'); | ||
|
||
const rootMain = path.join(rootDir, 'root.js'); | ||
const componentDir = path.join(rootDir, 'node_modules'); | ||
const shallowDepMain = path.join(componentDir, 'shallow', 'shallow.js'); | ||
const scopedDepMain = path.join(componentDir, '@scope', 'scoped', 'scoped.js'); | ||
|
||
const shallowRootComponentInfo = { | ||
packageName: 'root', | ||
rootDir, | ||
componentDir | ||
}; | ||
|
||
const scopedRootComponentInfo = { | ||
packageName: '@scope/root', | ||
rootDir, | ||
componentDir | ||
}; | ||
|
||
suite('resolve', async() => { | ||
|
||
test('non-component root to shallow dep', async() => { | ||
assert.equal( | ||
resolve('shallow', rootMain), './node_modules/shallow/shallow.js'); | ||
}); | ||
|
||
test('non-component root to scoped dep', async() => { | ||
assert.equal( | ||
resolve('@scope/scoped', rootMain), | ||
'./node_modules/@scope/scoped/scoped.js'); | ||
}); | ||
|
||
test('shallow dep to scoped dep', async() => { | ||
assert.equal( | ||
resolve('@scope/scoped', shallowDepMain, shallowRootComponentInfo), | ||
'../@scope/scoped/scoped.js'); | ||
}); | ||
|
||
test('scoped dep to shallow dep', async() => { | ||
assert.equal( | ||
resolve('shallow', scopedDepMain, shallowRootComponentInfo), | ||
'../../shallow/shallow.js'); | ||
}); | ||
|
||
test('component-root to shallow dep', async() => { | ||
assert.equal( | ||
resolve('shallow', rootMain, shallowRootComponentInfo), | ||
'../shallow/shallow.js'); | ||
}); | ||
|
||
test('component-root to scoped dep', async() => { | ||
assert.equal( | ||
resolve('@scope/scoped', rootMain, shallowRootComponentInfo), | ||
'../@scope/scoped/scoped.js'); | ||
}); | ||
|
||
test('scoped-component-root to shallow dep', async() => { | ||
assert.equal( | ||
resolve('shallow', rootMain, scopedRootComponentInfo), | ||
'../../shallow/shallow.js'); | ||
}); | ||
|
||
test('scoped-component-root to scoped dep', async() => { | ||
assert.equal( | ||
resolve('@scope/scoped', rootMain, scopedRootComponentInfo), | ||
'../scoped/scoped.js'); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
src/test/static/javascript/resolve-specifier-node/node_modules/@scope/scoped/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
5 changes: 5 additions & 0 deletions
5
src/test/static/javascript/resolve-specifier-node/node_modules/shallow/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
Empty file.