Skip to content

Converts node tests to use mocha instead of qunit. #349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ module.exports = {

// node test files
{
globals: {
describe: true,
it: true,
beforeEach: true,
afterEach: true,
},
files: ['tests-node/**/*.js'],
rules: {
'node/no-unpublished-require': 'off'
}
},
}
]
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"start": "ember serve",
"test": "ember try:each",
"test:browser": "ember test --test-port=0",
"test:node": "qunit tests-node",
"test:node": "mocha tests-node/**/*-test.js",
"test:test-apps": "cd test-apps/new-addon && yarn test",
"prepare": "./scripts/link-them.sh"
},
Expand Down Expand Up @@ -87,6 +87,7 @@
"@ember/optional-features": "^0.7.0",
"babel-eslint": "^10.0.1",
"broccoli-asset-rev": "^3.0.0",
"chai": "^4.2.0",
"common-tags": "^1.8.0",
"ember-classy-page-object": "^0.5.0",
"ember-cli": "~3.4.3",
Expand Down Expand Up @@ -117,6 +118,7 @@
"eslint-plugin-ember": "^5.2.0",
"eslint-plugin-node": "^7.0.1",
"loader.js": "^4.7.0",
"mocha": "^6.0.2",
"qunit": "^2.6.2",
"qunit-dom": "^0.8.4"
},
Expand Down
11 changes: 4 additions & 7 deletions tests-node/unit/deploy/plugin-test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
'use strict';

const QUnit = require('qunit');
const assert = require('chai').assert;
const AddonDocsDeployPlugin = require('../../../lib/deploy/plugin');

const qModule = QUnit.module;
const test = QUnit.test;

qModule('`deploy` | plugin test', hooks => {
hooks.beforeEach(function() {
describe('`deploy` | plugin test', function() {
beforeEach(function() {
this.pluginInstance = new AddonDocsDeployPlugin();
});

test('_macroReplaceIndexContent', function(assert) {
it('_macroReplaceIndexContent', function() {
const contents = `
<!DOCTYPE html>
<html>
Expand Down
18 changes: 9 additions & 9 deletions tests-node/unit/navigation-index-generator/test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';

const QUnit = require('qunit'), test = QUnit.test;
const assert = require('chai').assert;
const NavigationIndexGenerator = require('../../../lib/broccoli/docs-compiler/navigation-index-generator');

let generator = new NavigationIndexGenerator();

QUnit.module('Unit | NavigationIndexGenerator', function(hooks) {
describe('Unit | NavigationIndexGenerator', function(hooks) {

test('the correct navigation is generated for a component', function(assert) {
it('the correct navigation is generated for a component', function() {
let modulesWithComponent = require('./examples/one-component.json');
let navigationIndex = generator.generate(modulesWithComponent);

Expand All @@ -25,7 +25,7 @@ QUnit.module('Unit | NavigationIndexGenerator', function(hooks) {
]);
});

test('it sorts modules by path', function(assert) {
it('it sorts modules by path', function() {
let modulesWithComponent = require('./examples/multiple-components.json');
let navigationIndex = generator.generate(modulesWithComponent);

Expand All @@ -48,7 +48,7 @@ QUnit.module('Unit | NavigationIndexGenerator', function(hooks) {
]);
});

test('the correct navigation is generated for a generic module with multiple classes', function(assert) {
it('the correct navigation is generated for a generic module with multiple classes', function() {
let modulesWithComponent = require('./examples/generic-module-multiple-classes.json');
let navigationIndex = generator.generate(modulesWithComponent);

Expand All @@ -66,7 +66,7 @@ QUnit.module('Unit | NavigationIndexGenerator', function(hooks) {
]);
});

test('it correctly handles modules with a single type', function(assert) {
it('it correctly handles modules with a single type', function() {
let modulesWithComponent = require('./examples/generic-module-one-class.json');
let navigationIndex = generator.generate(modulesWithComponent);

Expand All @@ -84,7 +84,7 @@ QUnit.module('Unit | NavigationIndexGenerator', function(hooks) {
]);
});

test('sanity check: it handles addon-docs', function(assert) {
it('sanity check: it handles addon-docs', function() {
let modules = require('./examples/addon-docs.json');
let navigationIndex = generator.generate(modules);

Expand Down Expand Up @@ -157,7 +157,7 @@ QUnit.module('Unit | NavigationIndexGenerator', function(hooks) {
]);
});

test('sanity check: it handles sandbox', function(assert) {
it('sanity check: it handles sandbox', function() {
let modules = require('./examples/sandbox.json');
let navigationIndex = generator.generate(modules);

Expand Down Expand Up @@ -228,7 +228,7 @@ QUnit.module('Unit | NavigationIndexGenerator', function(hooks) {
]);
});

test('correctly handle _resolvedTypeForModule for module names containing type itself', function(assert) {
it('correctly handle _resolvedTypeForModule for module names containing type itself', function() {
let testcases = [
[ 'ember-addon-helpers/unresolved-type', false ],
[ 'ember-addon-helpers/helpers', 'helpers' ],
Expand Down
18 changes: 9 additions & 9 deletions tests-node/unit/utils/compile-markdown-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

const QUnit = require('qunit'), test = QUnit.test;
const assert = require('chai').assert;
const stripIndent = require('common-tags').stripIndent;
const compileMarkdown = require('../../../lib/utils/compile-markdown');

QUnit.module('Unit | compile-markdown', function(hooks) {
test('compacting curly paragraphs', function(assert) {
describe('Unit | compile-markdown', function(hooks) {
it('compacting curly paragraphs', function() {
let input = stripIndent`
{{#foo-bar}}

Expand All @@ -20,7 +20,7 @@ QUnit.module('Unit | compile-markdown', function(hooks) {
assert.equal(result, expected);
});

test('compacting angle bracket paragraphs', function(assert) {
it('compacting angle bracket paragraphs', function() {
let input = stripIndent`
<FooBar>

Expand All @@ -38,7 +38,7 @@ QUnit.module('Unit | compile-markdown', function(hooks) {
assert.equal(result, expected);
});

test('compacting implicit code blocks', function(assert) {
it('compacting implicit code blocks', function() {
// Surrounding whitespace + 4-space indent = code block in MD
let input = stripIndent`
{{#foo-bar}}
Expand All @@ -56,7 +56,7 @@ QUnit.module('Unit | compile-markdown', function(hooks) {
assert.equal(result, expected);
});

test('classic components remain unescaped', function(assert) {
it('classic components remain unescaped', function() {
let input = stripIndent`
{{#foo-bar prop="value" otherProp='value'}}

Expand All @@ -71,7 +71,7 @@ QUnit.module('Unit | compile-markdown', function(hooks) {
assert.equal(result, expected);
});

test('angle bracket contextual components remain unescaped', function(assert) {
it('angle bracket contextual components remain unescaped', function() {
let input = stripIndent`
<foo.bar @prop={{value}}></foo.bar>
`;
Expand All @@ -84,7 +84,7 @@ QUnit.module('Unit | compile-markdown', function(hooks) {
assert.equal(result, expected);
});

test('using opening curlies inside backticks shouldn\'t compact paragraphs', function(assert) {
it('using opening curlies inside backticks shouldn\'t compact paragraphs', function() {
let input = stripIndent`
Foo bar is \`{{#my-component}}\`.

Expand All @@ -100,7 +100,7 @@ QUnit.module('Unit | compile-markdown', function(hooks) {
assert.equal(result, expected);
});

test('using opening angle brackets inside backticks shouldn\'t compact paragraphs', function(assert) {
it('using opening angle brackets inside backticks shouldn\'t compact paragraphs', function() {
let input = stripIndent`
Foo bar is \`<My component>\`.

Expand Down
23 changes: 10 additions & 13 deletions tests-node/unit/utils/update-demo-url-test.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
'use strict';

const QUnit = require('qunit');
const assert = require('chai').assert;
const fs = require('fs-extra');
const path = require('path');
const updateDemoUrl = require('../../../lib/utils/update-demo-url');

const qModule = QUnit.module;
const test = QUnit.test;

qModule('`updateDemoUrl` | fixture test', hooks => {
describe('`updateDemoUrl` | fixture test', function() {
const fixturesPath = path.join(__dirname, '../..', 'fixtures', 'update-demo-url');

let inputCopyPath, outputPath, setupFixtureDirectory;

hooks.beforeEach(() => {
beforeEach(function() {
setupFixtureDirectory = (dir) => {
inputCopyPath = path.join(fixturesPath, dir, 'input--temp.json');
outputPath = path.join(fixturesPath, dir, 'output.json');
fs.copySync(path.join(fixturesPath, dir, 'input.json'), inputCopyPath);
}
});

hooks.afterEach(() => {
afterEach(function() {
if (inputCopyPath) {
fs.unlinkSync(inputCopyPath);
inputCopyPath = '';
}
});

test('it leaves the `homepage` property if it already exists', assert => {
it('it leaves the `homepage` property if it already exists', function() {
setupFixtureDirectory('has-existing-homepage');

const result = updateDemoUrl(inputCopyPath);
Expand All @@ -40,7 +37,7 @@ qModule('`updateDemoUrl` | fixture test', hooks => {
);
});

test('it adds the `homepage` property based on git remote repository', assert => {
it('it adds the `homepage` property based on git remote repository', function() {
const dir = 'has-git-repository';
setupFixtureDirectory(dir);

Expand All @@ -55,7 +52,7 @@ qModule('`updateDemoUrl` | fixture test', hooks => {
);
});

test('it adds the `homepage` property based on package repository value', assert => {
it('it adds the `homepage` property based on package repository value', function() {
setupFixtureDirectory('has-package-repository');

const result = updateDemoUrl(inputCopyPath);
Expand All @@ -67,7 +64,7 @@ qModule('`updateDemoUrl` | fixture test', hooks => {
);
});

test('it adds the `homepage` property based on package repository url property', assert => {
it('it adds the `homepage` property based on package repository url property', function() {
setupFixtureDirectory('has-git-repository-object');

const result = updateDemoUrl(inputCopyPath);
Expand All @@ -79,7 +76,7 @@ qModule('`updateDemoUrl` | fixture test', hooks => {
);
});

test('it returns false when there is no repository to update', assert => {
it('it returns false when there is no repository to update', function() {
const dir = 'missing-repository';
setupFixtureDirectory(dir);

Expand All @@ -89,7 +86,7 @@ qModule('`updateDemoUrl` | fixture test', hooks => {
assert.notOk(result);
});

test('it returns false when the repository is not a git repo', assert => {
it('it returns false when the repository is not a git repo', function() {
const dir = 'non-git-repository';
setupFixtureDirectory(dir);

Expand Down
Loading