forked from emberjs/ember.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] utils blueprint for module unification
- Loading branch information
Showing
7 changed files
with
213 additions
and
0 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,5 +1,24 @@ | ||
'use strict'; | ||
|
||
const isModuleUnificationProject = require('../module-unification').isModuleUnificationProject; | ||
|
||
module.exports = { | ||
description: 'Generates a simple utility module/function.', | ||
|
||
fileMapTokens() { | ||
if (isModuleUnificationProject(this.project)) { | ||
return { | ||
__root__(options) { | ||
if (options.pod) { | ||
throw "Pods aren't supported within a module unification app"; | ||
} | ||
|
||
return 'src'; | ||
}, | ||
__testType__() { | ||
return ''; | ||
}, | ||
}; | ||
} | ||
}, | ||
}; |
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ const modifyPackages = blueprintHelpers.modifyPackages; | |
|
||
const chai = require('ember-cli-blueprint-test-helpers/chai'); | ||
const expect = chai.expect; | ||
const fs = require('fs-extra'); | ||
|
||
const generateFakePackageManifest = require('../helpers/generate-fake-package-manifest'); | ||
const fixture = require('../helpers/fixture'); | ||
|
@@ -56,6 +57,45 @@ describe('Blueprint: util-test', function() { | |
}); | ||
}); | ||
|
||
describe('in app - module uninification', function() { | ||
beforeEach(function() { | ||
return emberNew().then(() => fs.ensureDirSync('src')); | ||
}); | ||
|
||
it('util-test foo-bar', function() { | ||
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => { | ||
expect(_file('src/utils/foo-bar-test.js')).to.equal(fixture('util-test/default.js')); | ||
}); | ||
}); | ||
|
||
describe('with [email protected]', function() { | ||
beforeEach(function() { | ||
generateFakePackageManifest('ember-cli-qunit', '4.2.0'); | ||
}); | ||
|
||
it('util-test foo-bar', function() { | ||
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => { | ||
expect(_file('src/utils/foo-bar-test.js')).to.equal(fixture('util-test/rfc232.js')); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('with ember-cli-mocha', function() { | ||
beforeEach(function() { | ||
modifyPackages([ | ||
{ name: 'ember-cli-qunit', delete: true }, | ||
{ name: 'ember-cli-mocha', dev: true }, | ||
]); | ||
}); | ||
|
||
it('util-test foo-bar', function() { | ||
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => { | ||
expect(_file('src/utils/foo-bar-test.js')).to.equal(fixture('util-test/mocha.js')); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('in addon', function() { | ||
beforeEach(function() { | ||
return emberNew({ target: 'addon' }); | ||
|
@@ -67,4 +107,16 @@ describe('Blueprint: util-test', function() { | |
}); | ||
}); | ||
}); | ||
|
||
describe('in addon - module unification', function() { | ||
beforeEach(function() { | ||
return emberNew({ target: 'addon' }).then(() => fs.ensureDirSync('src')); | ||
}); | ||
|
||
it('util-test foo-bar', function() { | ||
return emberGenerateDestroy(['util-test', 'foo-bar'], _file => { | ||
expect(_file('src/utils/foo-bar-test.js')).to.equal(fixture('util-test/dummy.js')); | ||
}); | ||
}); | ||
}); | ||
}); |
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