-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bundler): use paths from aurelia.json
- Loading branch information
1 parent
84952de
commit 625929c
Showing
5 changed files
with
107 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
const Bundler = require('../../../lib/build/bundler').Bundler; | ||
const PackageAnalyzer = require('../../mocks/package-analyzer'); | ||
const CLIOptionsMock = require('../../mocks/cli-options'); | ||
|
||
describe('the Bundler module', () => { | ||
let analyzer; | ||
let cliOptionsMock; | ||
|
||
beforeEach(() => { | ||
analyzer = new PackageAnalyzer(); | ||
cliOptionsMock = new CLIOptionsMock(); | ||
cliOptionsMock.attach(); | ||
}); | ||
|
||
it('uses paths.root from aurelia.json in the loaderConfig as baseUrl', () => { | ||
let project = { | ||
paths: { | ||
root: 'src' | ||
}, | ||
build: { loader: {} } | ||
}; | ||
let bundler = new Bundler(project, analyzer); | ||
expect(bundler.loaderConfig.baseUrl).toBe('src'); | ||
}); | ||
|
||
it('takes paths from aurelia.json and uses it in the loaderConfig', () => { | ||
let project = { | ||
paths: { | ||
root: 'src', | ||
foo: 'bar' | ||
}, | ||
build: { loader: {} } | ||
}; | ||
let bundler = new Bundler(project, analyzer); | ||
expect(bundler.loaderConfig.paths.root).toBe('src'); | ||
expect(bundler.loaderConfig.paths.foo).toBe('bar'); | ||
}); | ||
|
||
it('ensures that paths in aurelia.json are relative from the root path', () => { | ||
let project = { | ||
paths: { | ||
root: 'src', | ||
foo: 'src/bar' | ||
}, | ||
build: { loader: {} } | ||
}; | ||
let bundler = new Bundler(project, analyzer); | ||
expect(bundler.loaderConfig.paths.foo).toBe('bar'); | ||
}); | ||
|
||
afterEach(() => { | ||
cliOptionsMock.detach(); | ||
}); | ||
}); |
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,19 @@ | ||
'use strict'; | ||
|
||
let OriginalCLIOptions = require('../../lib/cli-options').CLIOptions; | ||
|
||
module.exports = class CLIOptionsMock { | ||
|
||
constructor() { | ||
this.originalFns = {}; | ||
} | ||
|
||
attach() { | ||
this.originalFns.getEnvironment = OriginalCLIOptions.prototype.getEnvironment; | ||
OriginalCLIOptions.getEnvironment = jasmine.createSpy('getEnvironment'); | ||
} | ||
|
||
detach() { | ||
OriginalCLIOptions.getEnvironment = this.originalFns.getEnvironment; | ||
} | ||
}; |
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,6 @@ | ||
'use strict'; | ||
|
||
module.exports = class PackageAnalyzer { | ||
constructor() { | ||
} | ||
}; |