Skip to content

Commit

Permalink
Remove blueprints for Mocha < 0.12. (#5225)
Browse files Browse the repository at this point in the history
* Remove blueprints for Mocha < 0.12.

ember-cli-mocha@0.12.0 was released quite some time ago (on 2016-11-23),
and by all accounts has been well adopted. Supporting both mocha test
blueprints indefinitely is untenable, and now seems like as good a time
as any to drop the blueprints for the older syntax.

Note: this does *not* remove support for anything, it merely makes it
slightly less convienient to create new test files for
adapter/model/serializer/transform objects when your application is
using Mocha < 0.12.

* Update to the latest ember-cli-version-checker.

This is unblocked by removing the need to "Fake" the version checker in
the blueprint test suite (the way ember-cli-blueprint-test-helpers fakes
out ember-cli-version-checker@1 no longer works with
ember-cli-version-checker@2).
  • Loading branch information
rwjblue authored and bmac committed Oct 12, 2017
1 parent 2a3a47a commit 5b336b5
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 206 deletions.

This file was deleted.

26 changes: 12 additions & 14 deletions blueprints/adapter-test/mocha-files/tests/unit/__path__/__test__.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { expect } from 'chai';
import { describeModule, it } from 'ember-mocha';
import { describe, it } from 'mocha';
import { setupTest } from 'ember-mocha';

describeModule(
'adapter:<%= dasherizedModuleName %>',
'<%= friendlyTestDescription %>',
{
describe('<%= friendlyTestDescription %>', function() {
setupTest('adapter:<%= dasherizedModuleName %>', {
// Specify the other units that are required for this test.
// needs: ['serializer:foo']
},
function() {
// Replace this with your real tests.
it('exists', function() {
let adapter = this.subject();
expect(adapter).to.be.ok;
});
}
);
});

// Replace this with your real tests.
it('exists', function() {
let adapter = this.subject();
expect(adapter).to.be.ok;
});
});

This file was deleted.

28 changes: 13 additions & 15 deletions blueprints/model-test/mocha-files/tests/unit/__path__/__test__.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { expect } from 'chai';
import { describeModel, it } from 'ember-mocha';
import { describe, it } from 'mocha';
import { setupModelTest } from 'ember-mocha';

describeModel(
'<%= dasherizedModuleName %>',
'<%= friendlyDescription %>',
{
describe('<%= friendlyDescription %>', function() {
setupModelTest('<%= dasherizedModuleName %>', {
// Specify the other units that are required for this test.
<%= typeof needs !== 'undefined' ? needs : '' %>
},
function() {
// Replace this with your real tests.
it('exists', function() {
let model = this.subject();
// var store = this.store();
expect(model).to.be.ok;
});
}
);
});

// Replace this with your real tests.
it('exists', function() {
let model = this.subject();
// var store = this.store();
expect(model).to.be.ok;
});
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import { expect } from 'chai';
import { describeModel, it } from 'ember-mocha';
import { describe, it } from 'mocha';
import { setupModelTest } from 'ember-mocha';

describeModel(
'<%= dasherizedModuleName %>',
'<%= friendlyTestDescription %>',
{
describe('<%= friendlyTestDescription %>', function() {
setupModelTest('<%= dasherizedModuleName %>', {
// Specify the other units that are required for this test.
needs: ['serializer:<%= dasherizedModuleName %>']
},
function() {
// Replace this with your real tests.
it('serializes records', function() {
let record = this.subject();
});

let serializedRecord = record.serialize();
// Replace this with your real tests.
it('serializes records', function() {
let record = this.subject();

expect(serializedRecord).to.be.ok;
});
}
);
let serializedRecord = record.serialize();

expect(serializedRecord).to.be.ok;
});
});
8 changes: 1 addition & 7 deletions blueprints/test-framework-detector.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var fs = require('fs');
var path = require('path');
var VersionChecker = require('ember-cli-version-checker');

module.exports = function(blueprint) {
blueprint.supportsAddon = function() {
Expand All @@ -14,12 +13,7 @@ module.exports = function(blueprint) {
if ('ember-cli-qunit' in dependencies) {
type = 'qunit';
} else if ('ember-cli-mocha' in dependencies) {
var checker = new VersionChecker({ project: this.project });
if (fs.existsSync(this.path + '/mocha-0.12-files') && checker.for('ember-cli-mocha', 'npm').satisfies('>=0.12.0')) {
type = 'mocha-0.12';
} else {
type = 'mocha';
}
type = 'mocha';
} else {
this.ui.writeLine('Couldn\'t determine test style - using QUnit');
type = 'qunit';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { expect } from 'chai';
import { describeModule, it } from 'ember-mocha';
import { describe, it } from 'mocha';
import { setupTest } from 'ember-mocha';

describeModule(
'transform:<%= dasherizedModuleName %>',
'<%= friendlyTestDescription %>',
{
describe('<%= friendlyTestDescription %>', function() {
setupTest('transform:<%= dasherizedModuleName %>', {
// Specify the other units that are required for this test.
// needs: ['transform:foo']
},
function() {
// Replace this with your real tests.
it('exists', function() {
let transform = this.subject();
expect(transform).to.be.ok;
});
}
);
});

// Replace this with your real tests.
it('exists', function() {
let transform = this.subject();
expect(transform).to.be.ok;
});
});
17 changes: 0 additions & 17 deletions node-tests/blueprints/adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,6 @@ describe('Acceptance: generate and destroy adapter blueprints', function() {
}));
});

it('adapter-test for mocha', function() {
var args = ['adapter-test', 'foo'];

return emberNew()
.then(() => modifyPackages([
{name: 'ember-cli-qunit', delete: true},
{name: 'ember-cli-mocha', dev: true}
]))
.then(() => generateFakePackageManifest('ember-cli-mocha', '0.11.0'))
.then(() => emberGenerateDestroy(args, _file => {
expect(_file('tests/unit/adapters/foo-test.js'))
.to.contain('import { describeModule, it } from \'ember-mocha\';')
.to.contain('describeModule(\n \'adapter:foo\',')
.to.contain('expect(adapter).to.be.ok;');
}));
});

it('adapter-test for mocha v0.12+', function() {
var args = ['adapter-test', 'foo'];

Expand Down
17 changes: 0 additions & 17 deletions node-tests/blueprints/model-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,6 @@ describe('Acceptance: generate and destroy model blueprints', function() {
}));
});

it('model-test for mocha', function() {
var args = ['model-test', 'foo'];

return emberNew()
.then(() => modifyPackages([
{name: 'ember-cli-qunit', delete: true},
{name: 'ember-cli-mocha', dev: true}
]))
.then(() => generateFakePackageManifest('ember-cli-mocha', '0.11.0'))
.then(() => emberGenerateDestroy(args, _file => {
expect(_file('tests/unit/models/foo-test.js'))
.to.contain('import { describeModel, it } from \'ember-mocha\';')
.to.contain('describeModel(\n \'foo\',')
.to.contain('expect(model).to.be.ok;');
}));
});

it('model-test for mocha v0.12+', function() {
var args = ['model-test', 'foo'];

Expand Down
21 changes: 1 addition & 20 deletions node-tests/blueprints/serializer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,7 @@ describe('Acceptance: generate and destroy serializer blueprints', function() {
}));
});

it('serializer-test for mocha', function() {
var args = ['serializer-test', 'foo'];

return emberNew()
.then(() => modifyPackages([
{name: 'ember-cli-qunit', delete: true},
{name: 'ember-cli-mocha', dev: true}
]))
.then(() => generateFakePackageManifest('ember-cli-mocha', '0.11.0'))
.then(() => emberGenerateDestroy(args, _file => {
expect(_file('tests/unit/serializers/foo-test.js'))
.to.contain('import { describeModel, it } from \'ember-mocha\';')
.to.contain('describeModel(\n \'foo\',')
.to.contain('Unit | Serializer | foo')
.to.contain('needs: [\'serializer:foo\']')
.to.contain('expect(serializedRecord).to.be.ok;');
}));
});

it('serializer-test for mocha v0.12+', function() {
it('serializer-test for mocha v0.12+', function() {
var args = ['serializer-test', 'foo'];

return emberNew()
Expand Down
17 changes: 0 additions & 17 deletions node-tests/blueprints/transform-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,6 @@ describe('Acceptance: generate and destroy transform blueprints', function() {
}));
});

it('transform-test for mocha', function() {
var args = ['transform-test', 'foo'];

return emberNew()
.then(() => modifyPackages([
{name: 'ember-cli-qunit', delete: true},
{name: 'ember-cli-mocha', dev: true}
]))
.then(() => generateFakePackageManifest('ember-cli-mocha', '0.11.0'))
.then(() => emberGenerateDestroy(args, _file => {
expect(_file('tests/unit/transforms/foo-test.js'))
.to.contain('import { describeModule, it } from \'ember-mocha\';')
.to.contain('describeModule(\n \'transform:foo\',')
.to.contain('expect(transform).to.be.ok;');
}));
});

it('transform-test for mocha v0.12+', function() {
var args = ['transform-test', 'foo'];

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"ember-cli-path-utils": "^1.0.0",
"ember-cli-string-utils": "^1.0.0",
"ember-cli-test-info": "^1.0.0",
"ember-cli-version-checker": "^1.1.4",
"ember-cli-version-checker": "^2.1.0",
"ember-inflector": "^2.0.0",
"ember-runtime-enumerable-includes-polyfill": "^2.0.0",
"exists-sync": "0.0.3",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,7 @@ ember-cli-version-checker@^1.0.2, ember-cli-version-checker@^1.1.4, ember-cli-ve
dependencies:
semver "^5.3.0"

ember-cli-version-checker@^2.0.0:
ember-cli-version-checker@^2.0.0, ember-cli-version-checker@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/ember-cli-version-checker/-/ember-cli-version-checker-2.1.0.tgz#fc79a56032f3717cf844ada7cbdec1a06fedb604"
dependencies:
Expand Down

0 comments on commit 5b336b5

Please sign in to comment.