-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
702 additions
and
743 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,6 +1,125 @@ | ||
|
||
/* eslint-env node */ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const stripIndent = require('common-tags').stripIndent; | ||
|
||
module.exports = { | ||
name: 'ember-mocha' | ||
name: 'ember-mocha', | ||
|
||
init() { | ||
this._super.init && this._super.init.apply(this, arguments); | ||
|
||
this.setTestGenerator(); | ||
}, | ||
|
||
postBuild() { | ||
this.checkPackages(); | ||
}, | ||
|
||
checkPackages() { | ||
var packages = Object.keys(this.project.addonPackages); | ||
if (packages.indexOf('ember-cli-qunit') !== -1) { | ||
console.warn('\nIt looks like you are using "ember-cli-qunit" which can cause issues with "ember-cli-mocha", please remove this package.\n'); | ||
process.exit(1); | ||
} | ||
if (packages.indexOf('ember-cli-htmlbars-inline-precompile') === -1) { | ||
console.warn('\nIt looks like you\'re not on ember-cli 1.13, which includes ember-cli-htmlbars-inline-precompile by default. Please run: ember install ember-cli-htmlbars-inline-precompile.\n'); | ||
process.exit(1); | ||
} | ||
}, | ||
|
||
included() { | ||
this._super.included.apply(this, arguments); | ||
|
||
this.import('vendor/mocha/mocha.js', { type: 'test' }); | ||
this.import('vendor/mocha/mocha.css', { type: 'test' }); | ||
this.import('vendor/ember-mocha/mocha-configuration.js', { type: 'test' }); | ||
this.import('vendor/ember-mocha/ember-mocha-adapter.js', { type: 'test' }); | ||
this.import('vendor/ember-mocha/test-loader.js', { type: 'test' }); | ||
|
||
let addonOptions = this.targetOptions(); | ||
let explicitlyDisabledStyles = addonOptions.disableContainerStyles === true; | ||
if (!explicitlyDisabledStyles) { | ||
this.import('vendor/ember-mocha/test-container-styles.css', { type: 'test' }); | ||
} | ||
}, | ||
|
||
targetOptions() { | ||
if (!this._targetOptions) { | ||
// 1. check this.parent.options['ember-mocha'] | ||
let targetOptions = this.parent.options && this.parent.options['ember-mocha']; | ||
// 2. check this.app.options['ember-mocha'] | ||
targetOptions = targetOptions || (this.app && this.app.options && this.app.options['ember-mocha']); | ||
// 3. check this.parent.options['ember-cli-mocha'] | ||
targetOptions = targetOptions || (this.parent.options && this.parent.options['ember-cli-mocha']); | ||
// 4. check this.app.options['ember-cli-mocha'] | ||
targetOptions = targetOptions || (this.app && this.app.options && this.app.options['ember-cli-mocha']); | ||
this._targetOptions = targetOptions || {}; | ||
} | ||
|
||
return this._targetOptions; | ||
}, | ||
|
||
contentFor(type) { | ||
// Skip if insertContentForTestBody === false. | ||
if (type === 'test-body' && !(this.targetOptions().insertContentForTestBody === false)) { | ||
return stripIndent` | ||
<div id="mocha"></div> | ||
<div id="mocha-fixture"></div> | ||
<div id="ember-testing-container"> | ||
<div id="ember-testing"></div> | ||
</div> | ||
`; | ||
} | ||
}, | ||
|
||
treeForVendor(tree) { | ||
const MergeTrees = require('broccoli-merge-trees'); | ||
const Funnel = require('broccoli-funnel'); | ||
let mochaPath = path.dirname(require.resolve('mocha')); | ||
|
||
let mochaTree = new Funnel(this.treeGenerator(mochaPath), { | ||
destDir: 'mocha', | ||
annotation: 'ember-mocha#treeForVendor', | ||
}); | ||
|
||
return new MergeTrees([mochaTree, tree]); | ||
}, | ||
|
||
treeForAddonTestSupport(tree) { | ||
// intentionally not calling _super here | ||
// so that can have our `import`'s be | ||
// import { ... } from 'ember-mocha'; | ||
|
||
return this.preprocessJs(tree, '/', this.name, { | ||
registry: this.registry, | ||
}); | ||
}, | ||
|
||
setTestGenerator() { | ||
this.project.generateTestFile = function(moduleName, tests) { | ||
var output = `describe('${moduleName}', function() {\n`; | ||
|
||
tests.forEach(function(test) { | ||
output += ` it('${test.name}', function() {\n`; | ||
if (test.passed) { | ||
output += | ||
" // precompiled test passed\n"; | ||
} else { | ||
output += | ||
" // precompiled test failed\n" + | ||
` var error = new chai.AssertionError('${test.errorMessage}');\n` + | ||
" error.stack = undefined;\n" + | ||
" throw error;\n"; | ||
} | ||
output += " });\n"; | ||
}); | ||
|
||
output += "});\n"; | ||
|
||
return output; | ||
}; | ||
}, | ||
}; |
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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
import { describe, it, beforeEach, afterEach } from 'mocha'; | ||
import { expect } from 'chai'; | ||
import startApp from '../helpers/start-app'; | ||
import destroyApp from '../helpers/destroy-app'; | ||
|
||
describe.skip('basic acceptance test', function() { | ||
this.timeout(5000); | ||
|
||
let application; | ||
|
||
beforeEach(function() { | ||
application = startApp(); | ||
}); | ||
|
||
afterEach(function() { | ||
destroyApp(application); | ||
}); | ||
|
||
it('can visit subroutes', function() { | ||
visit('/'); | ||
|
||
andThen(function() { | ||
expect(find('h2').text()).to.be.empty; | ||
}); | ||
|
||
visit('/foo'); | ||
|
||
andThen(function() { | ||
expect(find('h2').text()).to.be.equal('this is an acceptance test'); | ||
}); | ||
}); | ||
}); |
24 changes: 5 additions & 19 deletions
24
tests/setup-acceptance-test-test.js → .../acceptance/setup-acceptance-test-test.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
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ const Router = EmberRouter.extend({ | |
}); | ||
|
||
Router.map(function() { | ||
this.route('foo'); | ||
}); | ||
|
||
export default Router; |
Empty file.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
<h2>this is an acceptance test</h2> |
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 @@ | ||
<h2></h2> |
File renamed without changes.
Oops, something went wrong.