Skip to content

Commit

Permalink
Remove test styles. Allow only ember-qunit (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkszepp authored May 31, 2024
1 parent 0cf6ef4 commit 9196f81
Showing 1 changed file with 24 additions and 87 deletions.
111 changes: 24 additions & 87 deletions ember-can/blueprints/ability-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,96 +8,33 @@ module.exports = {

shouldTransformTypeScript: true,

_getTestStyle: function () {
if ('ember-cli-mocha' in this.project.addonPackages) {
return 'mocha';
} else if ('ember-cli-qunit' in this.project.addonPackages) {
return 'qunit';
}
},

locals: function (options) {
var name = options.entity.name;

var testStyle = this._getTestStyle();
if (!testStyle) {
this.ui.writeLine("Couldn't determine test style - using QUnit");
testStyle = 'qunit';
}

var imports, test;
if (testStyle === 'qunit') {
imports =
"import { module, test } from 'qunit';" +
EOL +
"import { setupTest } from 'ember-qunit';";
test =
"module('Unit | Ability | " +
name +
"', function(hooks) {" +
EOL +
' setupTest(hooks);' +
EOL +
EOL +
" test('it exists', function(assert) {" +
EOL +
" const ability = this.owner.lookup('ability:" +
name +
"');" +
EOL +
' assert.ok(ability);' +
EOL +
' });' +
EOL +
'});';
} else if (testStyle === 'mocha') {
imports =
'/* jshint expr:true */' +
EOL +
"import { expect } from 'chai';" +
EOL +
'import {' +
EOL +
' describeModule,' +
EOL +
' it' +
EOL +
"} from 'ember-mocha';";
test =
'describeModule(' +
EOL +
" 'ability:" +
name +
"'," +
EOL +
" '" +
name +
" Ability'," +
EOL +
' {' +
EOL +
' // Specify the other units that are required for this test.' +
EOL +
" // needs: ['service:foo']" +
EOL +
' },' +
EOL +
' function() {' +
EOL +
' // Replace this with your real tests.' +
EOL +
" it('exists', function() {" +
EOL +
' const ability = this.subject();' +
EOL +
' expect(ability).to.be.ok;' +
EOL +
' });' +
EOL +
' }' +
EOL +
');';
}
var imports =
"import { module, test } from 'qunit';" +
EOL +
"import { setupTest } from 'ember-qunit';";

var test =
"module('Unit | Ability | " +
name +
"', function(hooks) {" +
EOL +
' setupTest(hooks);' +
EOL +
EOL +
" test('it exists', function(assert) {" +
EOL +
" const ability = this.owner.lookup('ability:" +
name +
"');" +
EOL +
' assert.ok(ability);' +
EOL +
' });' +
EOL +
'});';

return {
imports: imports,
Expand Down

0 comments on commit 9196f81

Please sign in to comment.