-
-
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.
Merge pull request #578 from JeroenVinke/fix/paths-aureliajson
Fix/paths aureliajson
- Loading branch information
Showing
6 changed files
with
112 additions
and
6 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,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() { | ||
} | ||
}; |