diff --git a/.eslintrc b/.eslintrc
index 527935d0f4d..f0599148a75 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -11,23 +11,19 @@
{"Ember":true,
"jQuery":true,
"$":true,
+ "QUnit":true,
"RSVP":true,
"Discourse":true,
"Em":true,
"Handlebars":true,
"I18n":true,
"bootbox":true,
- "module":true,
"moduleFor":true,
"moduleForComponent":true,
"Pretender":true,
"sandbox":true,
"controllerFor":true,
"test":true,
- "ok":true,
- "not":true,
- "expect":true,
- "equal":true,
"visit":true,
"andThen":true,
"click":true,
@@ -48,12 +44,8 @@
"find":true,
"sinon":true,
"moment":true,
- "start":true,
"_":true,
"alert":true,
- "containsInstance":true,
- "deepEqual":true,
- "notEqual":true,
"define":true,
"require":true,
"requirejs":true,
diff --git a/app/assets/javascripts/discourse/routes/invites-show.js.es6 b/app/assets/javascripts/discourse/routes/invites-show.js.es6
index 9acc266ced8..10d85152580 100644
--- a/app/assets/javascripts/discourse/routes/invites-show.js.es6
+++ b/app/assets/javascripts/discourse/routes/invites-show.js.es6
@@ -8,6 +8,8 @@ export default Discourse.Route.extend({
model(params) {
if (PreloadStore.get("invite_info")) {
return PreloadStore.getAndRemove("invite_info").then(json => _.merge(params, json));
+ } else {
+ return {};
}
}
});
diff --git a/app/assets/javascripts/discourse/widgets/link.js.es6 b/app/assets/javascripts/discourse/widgets/link.js.es6
index 9e33999957d..4f6beef6bf2 100644
--- a/app/assets/javascripts/discourse/widgets/link.js.es6
+++ b/app/assets/javascripts/discourse/widgets/link.js.es6
@@ -11,12 +11,12 @@ export default createWidget('link', {
const route = attrs.route;
if (route) {
const router = this.register.lookup('router:main');
- if (router && router.router) {
+ if (router && router._routerMicrolib) {
const params = [route];
if (attrs.model) {
params.push(attrs.model);
}
- return Discourse.getURL(router.router.generate.apply(router.router, params));
+ return Discourse.getURL(router._routerMicrolib.generate.apply(router._routerMicrolib, params));
}
} else {
return Discourse.getURL(attrs.href);
diff --git a/app/assets/javascripts/wizard/router.js.es6 b/app/assets/javascripts/wizard/router.js.es6
index ebc83ec380c..15abc15ff03 100644
--- a/app/assets/javascripts/wizard/router.js.es6
+++ b/app/assets/javascripts/wizard/router.js.es6
@@ -1,7 +1,7 @@
import getUrl from 'discourse-common/lib/get-url';
const Router = Ember.Router.extend({
- rootURL: getUrl('/wizard'),
+ rootURL: getUrl('/wizard/'),
location: Ember.testing ? 'none': 'history'
});
diff --git a/app/assets/javascripts/wizard/test/acceptance/wizard-test.js.es6 b/app/assets/javascripts/wizard/test/acceptance/wizard-test.js.es6
index fb95fa7abff..ca42183bb67 100644
--- a/app/assets/javascripts/wizard/test/acceptance/wizard-test.js.es6
+++ b/app/assets/javascripts/wizard/test/acceptance/wizard-test.js.es6
@@ -6,7 +6,7 @@ module("Acceptance: wizard", {
wizard = startApp();
},
- teardown() {
+ afterEach() {
Ember.run(wizard, 'destroy');
}
});
diff --git a/app/assets/javascripts/wizard/test/components/invite-list-test.js.es6 b/app/assets/javascripts/wizard/test/components/invite-list-test.js.es6
index 8e515c01c6d..cdfe0fbe159 100644
--- a/app/assets/javascripts/wizard/test/components/invite-list-test.js.es6
+++ b/app/assets/javascripts/wizard/test/components/invite-list-test.js.es6
@@ -4,7 +4,7 @@ moduleForComponent('invite-list', { integration: true });
componentTest('can add users', {
template: `{{invite-list field=field}}`,
- setup() {
+ beforeEach() {
this.set('field', {});
},
diff --git a/app/assets/javascripts/wizard/test/helpers/component-test.js.es6 b/app/assets/javascripts/wizard/test/helpers/component-test.js.es6
index 0cc731b1ea0..21541d3413a 100644
--- a/app/assets/javascripts/wizard/test/helpers/component-test.js.es6
+++ b/app/assets/javascripts/wizard/test/helpers/component-test.js.es6
@@ -7,8 +7,8 @@ export function componentTest(name, opts) {
test(name, function(assert) {
initializer.initialize(this.registry);
- if (opts.setup) {
- opts.setup.call(this);
+ if (opts.beforeEach) {
+ opts.beforeEach.call(this);
}
andThen(() => this.render(opts.template));
diff --git a/app/assets/javascripts/wizard/test/test_helper.js b/app/assets/javascripts/wizard/test/test_helper.js
index 46042a0e725..0731b301f8c 100644
--- a/app/assets/javascripts/wizard/test/test_helper.js
+++ b/app/assets/javascripts/wizard/test/test_helper.js
@@ -33,6 +33,7 @@ if (window.Logster) {
} else {
window.Logster = { enabled: false };
}
+Ember.Test.adapter = window.QUnitAdapter.create();
var createPretendServer = require('wizard/test/wizard-pretender', null, null, false).default;
@@ -45,6 +46,7 @@ QUnit.testDone(function() {
server.shutdown();
});
+
var _testApp = require('wizard/test/helpers/start-app').default();
var _buildResolver = require('discourse-common/resolver').buildResolver;
window.setResolver(_buildResolver('wizard').create({ namespace: _testApp }));
diff --git a/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6 b/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6
index 427687886ab..cbf078c279a 100644
--- a/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6
+++ b/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6
@@ -6,7 +6,7 @@ function findTextarea() {
return find(".d-editor-input")[0];
}
-test('details button', () => {
+test('details button', (assert) => {
visit("/");
click('#create-topic');
@@ -14,7 +14,7 @@ test('details button', () => {
click('.popup-menu .fa-caret-right');
andThen(() => {
- equal(
+ assert.equal(
find(".d-editor-input").val(),
`[details=${I18n.t("composer.details_title")}]${I18n.t("composer.details_text")}[/details]`,
'it should contain the right output'
@@ -33,15 +33,15 @@ test('details button', () => {
click('.popup-menu .fa-caret-right');
andThen(() => {
- equal(
+ assert.equal(
find(".d-editor-input").val(),
`[details=${I18n.t("composer.details_title")}]This is my title[/details]`,
'it should contain the right selected output'
);
const textarea = findTextarea();
- equal(textarea.selectionStart, 17, 'it should start highlighting at the right position');
- equal(textarea.selectionEnd, 33, 'it should end highlighting at the right position');
+ assert.equal(textarea.selectionStart, 17, 'it should start highlighting at the right position');
+ assert.equal(textarea.selectionEnd, 33, 'it should end highlighting at the right position');
});
fillIn('.d-editor-input', "Before some text in between After");
@@ -56,15 +56,15 @@ test('details button', () => {
click('.popup-menu .fa-caret-right');
andThen(() => {
- equal(
+ assert.equal(
find(".d-editor-input").val(),
`Before [details=${I18n.t("composer.details_title")}]some text in between[/details] After`,
'it should contain the right output'
);
const textarea = findTextarea();
- equal(textarea.selectionStart, 24, 'it should start highlighting at the right position');
- equal(textarea.selectionEnd, 44, 'it should end highlighting at the right position');
+ assert.equal(textarea.selectionStart, 24, 'it should start highlighting at the right position');
+ assert.equal(textarea.selectionEnd, 44, 'it should end highlighting at the right position');
});
fillIn('.d-editor-input', "Before\nsome text in between\nAfter");
@@ -79,14 +79,14 @@ test('details button', () => {
click('.popup-menu .fa-caret-right');
andThen(() => {
- equal(
+ assert.equal(
find(".d-editor-input").val(),
`Before\n[details=${I18n.t("composer.details_title")}]some text in between[/details]\nAfter`,
'it should contain the right output'
);
const textarea = findTextarea();
- equal(textarea.selectionStart, 24, 'it should start highlighting at the right position');
- equal(textarea.selectionEnd, 44, 'it should end highlighting at the right position');
+ assert.equal(textarea.selectionStart, 24, 'it should start highlighting at the right position');
+ assert.equal(textarea.selectionEnd, 44, 'it should end highlighting at the right position');
});
});
diff --git a/plugins/discourse-details/test/javascripts/lib/details-cooked-test.js.es6 b/plugins/discourse-details/test/javascripts/lib/details-cooked-test.js.es6
index f020474e6cb..cd490665335 100644
--- a/plugins/discourse-details/test/javascripts/lib/details-cooked-test.js.es6
+++ b/plugins/discourse-details/test/javascripts/lib/details-cooked-test.js.es6
@@ -13,11 +13,11 @@ const defaultOpts = buildOptions({
getURL: url => url
});
-function cooked(input, expected, text) {
- equal(new PrettyText(defaultOpts).cook(input), expected.replace(/\/>/g, ">"), text);
-};
-test("details", () => {
+test("details", assert => {
+ const cooked = (input, expected, text) => {
+ assert.equal(new PrettyText(defaultOpts).cook(input), expected.replace(/\/>/g, ">"), text);
+ };
cooked(` coucouInfo
coucouInfo
\n\n
0voters
0voters
0voters
\nChoose up to 3 options
\nVotes are public.
\n0voters
\nVotes are public.
\nthis is a category hashtag #bug
"); + assert.equal(find('.d-editor-preview:visible').html().trim(), "this is a category hashtag #bug
"); }); click('#reply-control .btn.create'); andThen(() => { - equal(find('.topic-post:last .cooked p').html().trim(), "this is a category hashtag #bug"); + assert.equal(find('.topic-post:last .cooked p').html().trim(), "this is a category hashtag #bug"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/composer-test.js.es6 b/test/javascripts/acceptance/composer-test.js.es6 index fe086a68058..b155418b78e 100644 --- a/test/javascripts/acceptance/composer-test.js.es6 +++ b/test/javascripts/acceptance/composer-test.js.es6 @@ -7,44 +7,44 @@ acceptance("Composer", { } }); -test("Tests the Composer controls", () => { +QUnit.test("Tests the Composer controls", assert => { visit("/"); andThen(() => { - ok(exists('#create-topic'), 'the create button is visible'); + assert.ok(exists('#create-topic'), 'the create button is visible'); }); click('#create-topic'); andThen(() => { - ok(exists('.d-editor-input'), 'the composer input is visible'); - ok(exists('.title-input .popup-tip.bad.hide'), 'title errors are hidden by default'); - ok(exists('.d-editor-textarea-wrapper .popup-tip.bad.hide'), 'body errors are hidden by default'); + assert.ok(exists('.d-editor-input'), 'the composer input is visible'); + assert.ok(exists('.title-input .popup-tip.bad.hide'), 'title errors are hidden by default'); + assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.bad.hide'), 'body errors are hidden by default'); }); click('a.toggle-preview'); andThen(() => { - ok(!exists('.d-editor-preview:visible'), "clicking the toggle hides the preview"); + assert.ok(!exists('.d-editor-preview:visible'), "clicking the toggle hides the preview"); }); click('a.toggle-preview'); andThen(() => { - ok(exists('.d-editor-preview:visible'), "clicking the toggle shows the preview again"); + assert.ok(exists('.d-editor-preview:visible'), "clicking the toggle shows the preview again"); }); click('#reply-control button.create'); andThen(() => { - ok(!exists('.title-input .popup-tip.bad.hide'), 'it shows the empty title error'); - ok(!exists('.d-editor-wrapper .popup-tip.bad.hide'), 'it shows the empty body error'); + assert.ok(!exists('.title-input .popup-tip.bad.hide'), 'it shows the empty title error'); + assert.ok(!exists('.d-editor-wrapper .popup-tip.bad.hide'), 'it shows the empty body error'); }); fillIn('#reply-title', "this is my new topic title"); andThen(() => { - ok(exists('.title-input .popup-tip.good'), 'the title is now good'); + assert.ok(exists('.title-input .popup-tip.good'), 'the title is now good'); }); fillIn('.d-editor-input', "this is the *content* of a post"); andThen(() => { - equal(find('.d-editor-preview').html().trim(), "this is the content of a post
", "it previews content"); - ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good'); + assert.equal(find('.d-editor-preview').html().trim(), "this is the content of a post
", "it previews content"); + assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good'); }); andThen(() => { @@ -64,89 +64,89 @@ test("Tests the Composer controls", () => { andThen(() => { const example = I18n.t(`composer.bold_text`); - equal(find('#reply-control .d-editor-input').val().trim(), + assert.equal(find('#reply-control .d-editor-input').val().trim(), `this is the *content* of a post**${example}**`, "it supports keyboard shortcuts"); }); click('#reply-control a.cancel'); andThen(() => { - ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog'); + assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog'); }); click('.modal-footer a:eq(1)'); andThen(() => { - ok(!exists('.bootbox.modal'), 'the confirmation can be cancelled'); + assert.ok(!exists('.bootbox.modal'), 'the confirmation can be cancelled'); }); }); -test("Create a topic with server side errors", () => { +QUnit.test("Create a topic with server side errors", assert => { visit("/"); click('#create-topic'); fillIn('#reply-title', "this title triggers an error"); fillIn('.d-editor-input', "this is the *content* of a post"); click('#reply-control button.create'); andThen(() => { - ok(exists('.bootbox.modal'), 'it pops up an error message'); + assert.ok(exists('.bootbox.modal'), 'it pops up an error message'); }); click('.bootbox.modal a.btn-primary'); andThen(() => { - ok(!exists('.bootbox.modal'), 'it dismisses the error'); - ok(exists('.d-editor-input'), 'the composer input is visible'); + assert.ok(!exists('.bootbox.modal'), 'it dismisses the error'); + assert.ok(exists('.d-editor-input'), 'the composer input is visible'); }); }); -test("Create a Topic", () => { +QUnit.test("Create a Topic", assert => { visit("/"); click('#create-topic'); fillIn('#reply-title', "Internationalization Localization"); fillIn('.d-editor-input', "this is the *content* of a new topic post"); click('#reply-control button.create'); andThen(() => { - equal(currentURL(), "/t/internationalization-localization/280", "it transitions to the newly created topic URL"); + assert.equal(currentURL(), "/t/internationalization-localization/280", "it transitions to the newly created topic URL"); }); }); -test("Create an enqueued Topic", () => { +QUnit.test("Create an enqueued Topic", assert => { visit("/"); click('#create-topic'); fillIn('#reply-title', "Internationalization Localization"); fillIn('.d-editor-input', "enqueue this content please"); click('#reply-control button.create'); andThen(() => { - ok(visible('#discourse-modal'), 'it pops up a modal'); - equal(currentURL(), "/", "it doesn't change routes"); + assert.ok(visible('#discourse-modal'), 'it pops up a modal'); + assert.equal(currentURL(), "/", "it doesn't change routes"); }); click('.modal-footer button'); andThen(() => { - ok(invisible('#discourse-modal'), 'the modal can be dismissed'); + assert.ok(invisible('#discourse-modal'), 'the modal can be dismissed'); }); }); -test("Create a Reply", () => { +QUnit.test("Create a Reply", assert => { visit("/t/internationalization-localization/280"); andThen(() => { - ok(!exists('article[data-post-id=12345]'), 'the post is not in the DOM'); + assert.ok(!exists('article[data-post-id=12345]'), 'the post is not in the DOM'); }); click('#topic-footer-buttons .btn.create'); andThen(() => { - ok(exists('.d-editor-input'), 'the composer input is visible'); - ok(!exists('#reply-title'), 'there is no title since this is a reply'); + assert.ok(exists('.d-editor-input'), 'the composer input is visible'); + assert.ok(!exists('#reply-title'), 'there is no title since this is a reply'); }); fillIn('.d-editor-input', 'this is the content of my reply'); click('#reply-control button.create'); andThen(() => { - equal(find('.cooked:last p').text(), 'this is the content of my reply'); + assert.equal(find('.cooked:last p').text(), 'this is the content of my reply'); }); }); -test("Posting on a different topic", (assert) => { +QUnit.test("Posting on a different topic", (assert) => { visit("/t/internationalization-localization/280"); click('#topic-footer-buttons .btn.create'); fillIn('.d-editor-input', 'this is the content for a different topic'); @@ -167,106 +167,106 @@ test("Posting on a different topic", (assert) => { }); -test("Create an enqueued Reply", () => { +QUnit.test("Create an enqueued Reply", assert => { visit("/t/internationalization-localization/280"); click('#topic-footer-buttons .btn.create'); andThen(() => { - ok(exists('.d-editor-input'), 'the composer input is visible'); - ok(!exists('#reply-title'), 'there is no title since this is a reply'); + assert.ok(exists('.d-editor-input'), 'the composer input is visible'); + assert.ok(!exists('#reply-title'), 'there is no title since this is a reply'); }); fillIn('.d-editor-input', 'enqueue this content please'); click('#reply-control button.create'); andThen(() => { - ok(find('.cooked:last p').text() !== 'enqueue this content please', "it doesn't insert the post"); + assert.ok(find('.cooked:last p').text() !== 'enqueue this content please', "it doesn't insert the post"); }); andThen(() => { - ok(visible('#discourse-modal'), 'it pops up a modal'); + assert.ok(visible('#discourse-modal'), 'it pops up a modal'); }); click('.modal-footer button'); andThen(() => { - ok(invisible('#discourse-modal'), 'the modal can be dismissed'); + assert.ok(invisible('#discourse-modal'), 'the modal can be dismissed'); }); }); -test("Edit the first post", () => { +QUnit.test("Edit the first post", assert => { visit("/t/internationalization-localization/280"); - ok(!exists('.topic-post:eq(0) .post-info.edits'), 'it has no edits icon at first'); + assert.ok(!exists('.topic-post:eq(0) .post-info.edits'), 'it has no edits icon at first'); click('.topic-post:eq(0) button.show-more-actions'); click('.topic-post:eq(0) button.edit'); andThen(() => { - equal(find('.d-editor-input').val().indexOf('Any plans to support'), 0, 'it populates the input with the post text'); + assert.equal(find('.d-editor-input').val().indexOf('Any plans to support'), 0, 'it populates the input with the post text'); }); fillIn('.d-editor-input', "This is the new text for the post"); fillIn('#reply-title', "This is the new text for the title"); click('#reply-control button.create'); andThen(() => { - ok(!exists('.d-editor-input'), 'it closes the composer'); - ok(exists('.topic-post:eq(0) .post-info.edits'), 'it has the edits icon'); - ok(find('#topic-title h1').text().indexOf('This is the new text for the title') !== -1, 'it shows the new title'); - ok(find('.topic-post:eq(0) .cooked').text().indexOf('This is the new text for the post') !== -1, 'it updates the post'); + assert.ok(!exists('.d-editor-input'), 'it closes the composer'); + assert.ok(exists('.topic-post:eq(0) .post-info.edits'), 'it has the edits icon'); + assert.ok(find('#topic-title h1').text().indexOf('This is the new text for the title') !== -1, 'it shows the new title'); + assert.ok(find('.topic-post:eq(0) .cooked').text().indexOf('This is the new text for the post') !== -1, 'it updates the post'); }); }); -test("Composer can switch between edits", () => { +QUnit.test("Composer can switch between edits", assert => { visit("/t/this-is-a-test-topic/9"); click('.topic-post:eq(0) button.edit'); andThen(() => { - equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text'); + assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text'); }); click('.topic-post:eq(1) button.edit'); andThen(() => { - equal(find('.d-editor-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text'); + assert.equal(find('.d-editor-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text'); }); }); -test("Composer with dirty edit can toggle to another edit", () => { +QUnit.test("Composer with dirty edit can toggle to another edit", assert => { visit("/t/this-is-a-test-topic/9"); click('.topic-post:eq(0) button.edit'); fillIn('.d-editor-input', 'This is a dirty reply'); click('.topic-post:eq(1) button.edit'); andThen(() => { - ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog'); + assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog'); }); click('.modal-footer a:eq(0)'); andThen(() => { - equal(find('.d-editor-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text'); + assert.equal(find('.d-editor-input').val().indexOf('This is the second post.'), 0, 'it populates the input with the post text'); }); }); -test("Composer can toggle between edit and reply", () => { +QUnit.test("Composer can toggle between edit and reply", assert => { visit("/t/this-is-a-test-topic/9"); click('.topic-post:eq(0) button.edit'); andThen(() => { - equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text'); + assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text'); }); click('.topic-post:eq(0) button.reply'); andThen(() => { - equal(find('.d-editor-input').val(), "", 'it clears the input'); + assert.equal(find('.d-editor-input').val(), "", 'it clears the input'); }); click('.topic-post:eq(0) button.edit'); andThen(() => { - equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text'); + assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text'); }); }); -test("Composer can toggle between reply and createTopic", () => { +QUnit.test("Composer can toggle between reply and createTopic", assert => { visit("/t/this-is-a-test-topic/9"); click('.topic-post:eq(0) button.reply'); click('button.options'); click('.popup-menu .fa-eye-slash'); andThen(() => { - ok( + assert.ok( find('.composer-fields .whisper').text().indexOf(I18n.t("composer.whisper")) > 0, 'it sets the post type to whisper' ); @@ -274,12 +274,12 @@ test("Composer can toggle between reply and createTopic", () => { visit("/"); andThen(() => { - ok(exists('#create-topic'), 'the create topic button is visible'); + assert.ok(exists('#create-topic'), 'the create topic button is visible'); }); click('#create-topic'); andThen(() => { - ok( + assert.ok( find('.composer-fields .whisper').text().indexOf(I18n.t("composer.whisper")) === -1, "it should reset the state of the composer's model" ); @@ -288,7 +288,7 @@ test("Composer can toggle between reply and createTopic", () => { click('button.options'); click('.popup-menu .fa-eye-slash'); andThen(() => { - ok( + assert.ok( find('.composer-fields .whisper').text().indexOf(I18n.t("composer.unlist")) > 0, 'it sets the topic to unlisted' ); @@ -298,29 +298,29 @@ test("Composer can toggle between reply and createTopic", () => { click('.topic-post:eq(0) button.reply'); andThen(() => { - ok( + assert.ok( find('.composer-fields .whisper').text().indexOf(I18n.t("composer.unlist")) === -1, "it should reset the state of the composer's model" ); }); }); -test("Composer with dirty reply can toggle to edit", () => { +QUnit.test("Composer with dirty reply can toggle to edit", assert => { visit("/t/this-is-a-test-topic/9"); click('.topic-post:eq(0) button.reply'); fillIn('.d-editor-input', 'This is a dirty reply'); click('.topic-post:eq(0) button.edit'); andThen(() => { - ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog'); + assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog'); }); click('.modal-footer a:eq(0)'); andThen(() => { - equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text'); + assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text'); }); }); -test("Composer draft with dirty reply can toggle to edit", () => { +QUnit.test("Composer draft with dirty reply can toggle to edit", assert => { visit("/t/this-is-a-test-topic/9"); click('.topic-post:eq(0) button.reply'); @@ -328,10 +328,10 @@ test("Composer draft with dirty reply can toggle to edit", () => { click('.toggler'); click('.topic-post:eq(0) button.edit'); andThen(() => { - ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog'); + assert.ok(exists('.bootbox.modal'), 'it pops up a confirmation dialog'); }); click('.modal-footer a:eq(0)'); andThen(() => { - equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text'); + assert.equal(find('.d-editor-input').val().indexOf('This is the first post.'), 0, 'it populates the input with the post text'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/composer-topic-links-test.js.es6 b/test/javascripts/acceptance/composer-topic-links-test.js.es6 index 3876fcc5cc8..515e01f111b 100644 --- a/test/javascripts/acceptance/composer-topic-links-test.js.es6 +++ b/test/javascripts/acceptance/composer-topic-links-test.js.es6 @@ -9,58 +9,58 @@ acceptance("Composer topic featured links", { }); -test("onebox with title", () => { +QUnit.test("onebox with title", assert => { visit("/"); click('#create-topic'); fillIn('#reply-title', "http://www.example.com/has-title.html"); andThen(() => { - ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it"); - ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good'); - equal(find('.title-input input').val(), "An interesting article", "title is from the oneboxed article"); + assert.ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it"); + assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good'); + assert.equal(find('.title-input input').val(), "An interesting article", "title is from the oneboxed article"); }); }); -test("onebox result doesn't include a title", () => { +QUnit.test("onebox result doesn't include a title", assert => { visit("/"); click('#create-topic'); fillIn('#reply-title', 'http://www.example.com/no-title.html'); andThen(() => { - ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it"); - ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good'); - equal(find('.title-input input').val(), "http://www.example.com/no-title.html", "title is unchanged"); + assert.ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it"); + assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good'); + assert.equal(find('.title-input input').val(), "http://www.example.com/no-title.html", "title is unchanged"); }); }); -test("no onebox result", () => { +QUnit.test("no onebox result", assert => { visit("/"); click('#create-topic'); fillIn('#reply-title', "http://www.example.com/nope-onebox.html"); andThen(() => { - ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it"); - ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'link is pasted into body'); - equal(find('.title-input input').val(), "http://www.example.com/nope-onebox.html", "title is unchanged"); + assert.ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it"); + assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'link is pasted into body'); + assert.equal(find('.title-input input').val(), "http://www.example.com/nope-onebox.html", "title is unchanged"); }); }); -test("ignore internal links", () => { +QUnit.test("ignore internal links", assert => { visit("/"); click('#create-topic'); const title = "http://" + window.location.hostname + "/internal-page.html"; fillIn('#reply-title', title); andThen(() => { - equal(find('.d-editor-preview').html().trim().indexOf('onebox'), -1, "onebox preview doesn't show"); - equal(find('.d-editor-input').val().length, 0, "link isn't put into the post"); - equal(find('.title-input input').val(), title, "title is unchanged"); + assert.equal(find('.d-editor-preview').html().trim().indexOf('onebox'), -1, "onebox preview doesn't show"); + assert.equal(find('.d-editor-input').val().length, 0, "link isn't put into the post"); + assert.equal(find('.title-input input').val(), title, "title is unchanged"); }); }); -test("link is longer than max title length", () => { +QUnit.test("link is longer than max title length", assert => { visit("/"); click('#create-topic'); fillIn('#reply-title', "http://www.example.com/has-title-and-a-url-that-is-more-than-80-characters-because-thats-good-for-seo-i-guess.html"); andThen(() => { - ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it"); - ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good'); - equal(find('.title-input input').val(), "An interesting article", "title is from the oneboxed article"); + assert.ok(find('.d-editor-preview').html().trim().indexOf('onebox') > 0, "it pastes the link into the body and previews it"); + assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good'); + assert.equal(find('.title-input input').val(), "An interesting article", "title is from the oneboxed article"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/create-account-user-fields-test.js.es6 b/test/javascripts/acceptance/create-account-user-fields-test.js.es6 index 0b6fec4da4e..cb7a2fe5c56 100644 --- a/test/javascripts/acceptance/create-account-user-fields-test.js.es6 +++ b/test/javascripts/acceptance/create-account-user-fields-test.js.es6 @@ -8,14 +8,14 @@ acceptance("Create Account - User Fields", { } }); -test("create account with user fields", () => { +QUnit.test("create account with user fields", assert => { visit("/"); click("header .sign-up-button"); andThen(() => { - ok(exists('.create-account'), "it shows the create account modal"); - ok(exists('.user-field'), "it has at least one user field"); - ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first'); + assert.ok(exists('.create-account'), "it shows the create account modal"); + assert.ok(exists('.user-field'), "it has at least one user field"); + assert.ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first'); }); fillIn('#new-account-name', 'Dr. Good Tuna'); @@ -24,24 +24,24 @@ test("create account with user fields", () => { fillIn('#new-account-username', 'goodtuna'); andThen(() => { - ok(exists('#username-validation.good'), 'the username validation is good'); - ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled due to lack of user fields'); + assert.ok(exists('#username-validation.good'), 'the username validation is good'); + assert.ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled due to lack of user fields'); }); fillIn(".user-field input[type=text]:first", "Barky"); andThen(() => { - ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled because field is not checked'); + assert.ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled because field is not checked'); }); click(".user-field input[type=checkbox]"); andThen(() => { - not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled because field is not checked'); + assert.not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled because field is not checked'); }); click(".user-field input[type=checkbox]"); andThen(() => { - ok(exists('.modal-footer .btn-primary:disabled'), 'unclicking the checkbox disables the submit'); + assert.ok(exists('.modal-footer .btn-primary:disabled'), 'unclicking the checkbox disables the submit'); }); }); diff --git a/test/javascripts/acceptance/custom-html-set-test.js.es6 b/test/javascripts/acceptance/custom-html-set-test.js.es6 index 3ae0bd63737..6b2508ebf7f 100644 --- a/test/javascripts/acceptance/custom-html-set-test.js.es6 +++ b/test/javascripts/acceptance/custom-html-set-test.js.es6 @@ -4,14 +4,14 @@ import PreloadStore from 'preload-store'; acceptance("CustomHTML set"); -test("has no custom HTML in the top", assert => { +QUnit.test("has no custom HTML in the top", assert => { visit("/static/faq"); andThen(() => { assert.ok(!exists('span.custom-html-test'), 'it has no markup'); }); }); -test("renders set HTML", assert => { +QUnit.test("renders set HTML", assert => { setCustomHTML('top', 'HTML'); visit("/static/faq"); @@ -20,11 +20,11 @@ test("renders set HTML", assert => { }); }); -test("renders preloaded HTML", assert => { +QUnit.test("renders preloaded HTML", assert => { PreloadStore.store('customHTML', {top: " "}); visit("/static/faq"); andThen(() => { assert.equal(find('span.cookie').text(), 'monster', 'it inserted the markup'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/custom-html-template-test.js.es6 b/test/javascripts/acceptance/custom-html-template-test.js.es6 index d125236ebbc..bb0d77c8794 100644 --- a/test/javascripts/acceptance/custom-html-template-test.js.es6 +++ b/test/javascripts/acceptance/custom-html-template-test.js.es6 @@ -1,16 +1,16 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("CustomHTML template", { - setup() { + beforeEach() { Ember.TEMPLATES['top'] = Ember.HTMLBars.compile(`TOP`); }, - teardown() { + afterEach() { delete Ember.TEMPLATES['top']; } }); -test("renders custom template", assert => { +QUnit.test("renders custom template", assert => { visit("/static/faq"); andThen(() => { assert.equal(find('span.top-span').text(), 'TOP', 'it inserted the template'); diff --git a/test/javascripts/acceptance/emoji-test.js.es6 b/test/javascripts/acceptance/emoji-test.js.es6 index dfcd95fb753..23fc2aa8046 100644 --- a/test/javascripts/acceptance/emoji-test.js.es6 +++ b/test/javascripts/acceptance/emoji-test.js.es6 @@ -2,32 +2,32 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Emoji", { loggedIn: true }); -test("emoji is cooked properly", () => { +QUnit.test("emoji is cooked properly", assert => { visit("/t/internationalization-localization/280"); click('#topic-footer-buttons .btn.create'); fillIn('.d-editor-input', "this is an emoji :blonde_woman:"); andThen(() => { - equal(find('.d-editor-preview:visible').html().trim(), "this is an emoji
"); + assert.equal(find('.d-editor-preview:visible').html().trim(), "this is an emoji
"); }); click('#reply-control .btn.create'); andThen(() => { - equal(find('.topic-post:last .cooked p').html().trim(), "this is an emoji "); + assert.equal(find('.topic-post:last .cooked p').html().trim(), "this is an emoji "); }); }); -test("skin toned emoji is cooked properly", () => { +QUnit.test("skin toned emoji is cooked properly", assert => { visit("/t/internationalization-localization/280"); click('#topic-footer-buttons .btn.create'); fillIn('.d-editor-input', "this is an emoji :blonde_woman:t5:"); andThen(() => { - equal(find('.d-editor-preview:visible').html().trim(), "this is an emoji
"); + assert.equal(find('.d-editor-preview:visible').html().trim(), "this is an emoji
"); }); click('#reply-control .btn.create'); andThen(() => { - equal(find('.topic-post:last .cooked p').html().trim(), "this is an emoji "); + assert.equal(find('.topic-post:last .cooked p').html().trim(), "this is an emoji "); }); }); diff --git a/test/javascripts/acceptance/group-edit-test.js.es6 b/test/javascripts/acceptance/group-edit-test.js.es6 index 023d9c95f45..676ee7a2fc1 100644 --- a/test/javascripts/acceptance/group-edit-test.js.es6 +++ b/test/javascripts/acceptance/group-edit-test.js.es6 @@ -2,39 +2,39 @@ import { acceptance, logIn } from "helpers/qunit-helpers"; acceptance("Editing Group"); -test("Editing group", () => { +QUnit.test("Editing group", assert => { logIn(); Discourse.reset(); visit("/groups/discourse/edit"); andThen(() => { - ok(find('.group-flair-inputs').length === 1, 'it should display avatar flair inputs'); - ok(find('.group-edit-bio').length === 1, 'it should display group bio input'); - ok(find('.group-edit-full-name').length === 1, 'it should display group full name input'); - ok(find('.group-edit-public').length === 1, 'it should display group public input'); - ok(find('.group-edit-allow-membership-requests').length === 1, 'it should display group allow_membership_requets input'); - ok(find('.group-members-input .item').length === 7, 'it should display group members'); - ok(find('.group-members-input-selector').length === 1, 'it should display input to add group members'); - ok(find('.group-members-input-selector .add[disabled]').length === 1, 'add members button should be disabled'); + assert.ok(find('.group-flair-inputs').length === 1, 'it should display avatar flair inputs'); + assert.ok(find('.group-edit-bio').length === 1, 'it should display group bio input'); + assert.ok(find('.group-edit-full-name').length === 1, 'it should display group full name input'); + assert.ok(find('.group-edit-public').length === 1, 'it should display group public input'); + assert.ok(find('.group-edit-allow-membership-requests').length === 1, 'it should display group allow_membership_requets input'); + assert.ok(find('.group-members-input .item').length === 7, 'it should display group members'); + assert.ok(find('.group-members-input-selector').length === 1, 'it should display input to add group members'); + assert.ok(find('.group-members-input-selector .add[disabled]').length === 1, 'add members button should be disabled'); }); andThen(() => { - ok(find('.group-edit-allow-membership-requests[disabled]').length === 1, 'it should disable group allow_membership_request input'); + assert.ok(find('.group-edit-allow-membership-requests[disabled]').length === 1, 'it should disable group allow_membership_request input'); }); click('.group-edit-public'); click('.group-edit-allow-membership-requests'); andThen(() => { - ok(find('.group-edit-public[disabled]').length === 1, 'it should disable group public input'); + assert.ok(find('.group-edit-public[disabled]').length === 1, 'it should disable group public input'); }); }); -test("Editing group as an anonymous user", () => { +QUnit.test("Editing group as an anonymous user", assert => { visit("/groups/discourse/edit"); andThen(() => { - ok(count('.group-members tr') > 0, "it should redirect to members page for an anonymous user"); + assert.ok(count('.group-members tr') > 0, "it should redirect to members page for an anonymous user"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/group-logs-test.js.es6 b/test/javascripts/acceptance/group-logs-test.js.es6 index 58a1acb7bea..86d760cb0c2 100644 --- a/test/javascripts/acceptance/group-logs-test.js.es6 +++ b/test/javascripts/acceptance/group-logs-test.js.es6 @@ -2,7 +2,7 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Group Logs", { loggedIn: true, - setup() { + beforeEach() { const response = object => { return [ 200, @@ -26,15 +26,15 @@ acceptance("Group Logs", { } }); -test("Browsing group logs", () => { +QUnit.test("Browsing group logs", assert => { visit("/groups/snorlax/logs"); andThen(() => { - ok(find('tr.group-logs-row').length === 2, 'it should display the right number of logs'); + assert.ok(find('tr.group-logs-row').length === 2, 'it should display the right number of logs'); click(find(".group-logs-row button")[0]); }); andThen(() => { - ok(find('tr.group-logs-row').length === 1, 'it should display the right number of logs'); + assert.ok(find('tr.group-logs-row').length === 1, 'it should display the right number of logs'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/groups-test.js.es6 b/test/javascripts/acceptance/groups-test.js.es6 index baf138e76d0..0534127ea7b 100644 --- a/test/javascripts/acceptance/groups-test.js.es6 +++ b/test/javascripts/acceptance/groups-test.js.es6 @@ -2,104 +2,104 @@ import { acceptance, logIn } from "helpers/qunit-helpers"; acceptance("Groups"); -test("Browsing Groups", () => { +QUnit.test("Browsing Groups", assert => { visit("/groups"); andThen(() => { - equal(count('.groups-table-row'), 2, 'it displays visible groups'); - equal(find('.group-index-join').length, 1, 'it shows button to join group'); - equal(find('.group-index-request').length, 1, 'it shows button to request for group membership'); + assert.equal(count('.groups-table-row'), 2, 'it displays visible groups'); + assert.equal(find('.group-index-join').length, 1, 'it shows button to join group'); + assert.equal(find('.group-index-request').length, 1, 'it shows button to request for group membership'); }); click('.group-index-join'); andThen(() => { - ok(exists('.modal.login-modal'), 'it shows the login modal'); + assert.ok(exists('.modal.login-modal'), 'it shows the login modal'); }); click('.login-modal .close'); andThen(() => { - ok(invisible('.modal.login-modal'), 'it closes the login modal'); + assert.ok(invisible('.modal.login-modal'), 'it closes the login modal'); }); click('.group-index-request'); andThen(() => { - ok(exists('.modal.login-modal'), 'it shows the login modal'); + assert.ok(exists('.modal.login-modal'), 'it shows the login modal'); }); click("a[href='/groups/discourse/members']"); andThen(() => { - equal(find('.group-info-name').text().trim(), 'Awesome Team', "it displays the group page"); + assert.equal(find('.group-info-name').text().trim(), 'Awesome Team', "it displays the group page"); }); click('.group-index-join'); andThen(() => { - ok(exists('.modal.login-modal'), 'it shows the login modal'); + assert.ok(exists('.modal.login-modal'), 'it shows the login modal'); }); }); -test("Viewing Group", () => { +QUnit.test("Viewing Group", assert => { visit("/groups/discourse"); andThen(() => { - ok(count('.avatar-flair .fa-adjust') === 1, "it displays the group's avatar flair"); - ok(count('.group-members tr') > 0, "it lists group members"); + assert.ok(count('.avatar-flair .fa-adjust') === 1, "it displays the group's avatar flair"); + assert.ok(count('.group-members tr') > 0, "it lists group members"); }); click(".nav-pills li a[title='Activity']"); andThen(() => { - ok(count('.user-stream .item') > 0, "it lists stream items"); + assert.ok(count('.user-stream .item') > 0, "it lists stream items"); }); click(".group-activity-nav li a[href='/groups/discourse/activity/topics']"); andThen(() => { - ok(count('.user-stream .item') > 0, "it lists stream items"); + assert.ok(count('.user-stream .item') > 0, "it lists stream items"); }); click(".group-activity-nav li a[href='/groups/discourse/activity/mentions']"); andThen(() => { - ok(count('.user-stream .item') > 0, "it lists stream items"); + assert.ok(count('.user-stream .item') > 0, "it lists stream items"); }); andThen(() => { - equal( + assert.equal( find(".group-activity li a[href='/groups/discourse/activity/messages']").length, 0, 'it should not show messages tab if user is not a group user or admin' ); - ok(find(".nav-pills li a[title='Edit Group']").length === 0, 'it should not show messages tab if user is not admin'); - ok(find(".nav-pills li a[title='Logs']").length === 0, 'it should not show Logs tab if user is not admin'); - ok(count('.user-stream .item') > 0, "it lists stream items"); + assert.ok(find(".nav-pills li a[title='Edit Group']").length === 0, 'it should not show messages tab if user is not admin'); + assert.ok(find(".nav-pills li a[title='Logs']").length === 0, 'it should not show Logs tab if user is not admin'); + assert.ok(count('.user-stream .item') > 0, "it lists stream items"); }); }); -test("Admin Viewing Group", () => { +QUnit.test("Admin Viewing Group", assert => { logIn(); Discourse.reset(); visit("/groups/discourse"); andThen(() => { - ok(find(".nav-pills li a[title='Edit Group']").length === 1, 'it should show edit group tab if user is admin'); - ok(find(".nav-pills li a[title='Logs']").length === 1, 'it should show Logs tab if user is admin'); + assert.ok(find(".nav-pills li a[title='Edit Group']").length === 1, 'it should show edit group tab if user is admin'); + assert.ok(find(".nav-pills li a[title='Logs']").length === 1, 'it should show Logs tab if user is admin'); - equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name'); + assert.equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name'); }); click(".nav-pills li a[title='Activity']"); andThen(() => { - equal( + assert.equal( find(".group-activity li a[href='/groups/discourse/activity/messages']").length, 1, 'it should show messages tab if user is admin' ); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/invite-accept-test.js.es6 b/test/javascripts/acceptance/invite-accept-test.js.es6 index f89d5329bc0..697948e69de 100644 --- a/test/javascripts/acceptance/invite-accept-test.js.es6 +++ b/test/javascripts/acceptance/invite-accept-test.js.es6 @@ -7,7 +7,7 @@ acceptance("Invite Accept", { } }); -test("Invite Acceptance Page", () => { +QUnit.test("Invite Acceptance Page", assert => { PreloadStore.store('invite_info', { invited_by: {"id":123,"username":"neil","avatar_template":"/user_avatar/localhost/neil/{size}/25_1.png","name":"Neil Lalonde","title":"team"}, email: "invited@asdf.com", @@ -16,35 +16,35 @@ test("Invite Acceptance Page", () => { visit("/invites/myvalidinvitetoken"); andThen(() => { - ok(exists("#new-account-username"), "shows the username input"); - equal(find("#new-account-username").val(), "invited", "username is prefilled"); - ok(exists("#new-account-name"), "shows the name input"); - ok(exists("#new-account-password"), "shows the password input"); - ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled because name is not filled'); + assert.ok(exists("#new-account-username"), "shows the username input"); + assert.equal(find("#new-account-username").val(), "invited", "username is prefilled"); + assert.ok(exists("#new-account-name"), "shows the name input"); + assert.ok(exists("#new-account-password"), "shows the password input"); + assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled because name is not filled'); }); fillIn("#new-account-name", 'John Doe'); andThen(() => { - not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled'); + assert.not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled'); }); fillIn("#new-account-username", 'a'); andThen(() => { - ok(exists(".username-input .bad"), "username is not valid"); - ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled'); + assert.ok(exists(".username-input .bad"), "username is not valid"); + assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled'); }); fillIn("#new-account-password", 'aaa'); andThen(() => { - ok(exists(".password-input .bad"), "password is not valid"); - ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled'); + assert.ok(exists(".password-input .bad"), "password is not valid"); + assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled'); }); fillIn("#new-account-username", 'validname'); fillIn("#new-account-password", 'secur3ty4Y0uAndMe'); andThen(() => { - ok(exists(".username-input .good"), "username is valid"); - ok(exists(".password-input .good"), "password is valid"); - not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled'); + assert.ok(exists(".username-input .good"), "username is valid"); + assert.ok(exists(".password-input .good"), "password is valid"); + assert.not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled'); }); }); diff --git a/test/javascripts/acceptance/invite-show-user-fields-test.js.es6 b/test/javascripts/acceptance/invite-show-user-fields-test.js.es6 index bf4893a0e5c..823a5113ce4 100644 --- a/test/javascripts/acceptance/invite-show-user-fields-test.js.es6 +++ b/test/javascripts/acceptance/invite-show-user-fields-test.js.es6 @@ -8,12 +8,12 @@ acceptance("Accept Invite - User Fields", { } }); -test("accept invite with user fields", () => { +QUnit.test("accept invite with user fields", assert => { visit("/invites/myvalidinvitetoken"); andThen(() => { - ok(exists(".invites-show"), "shows the accept invite page"); - ok(exists('.user-field'), "it has at least one user field"); - ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled'); + assert.ok(exists(".invites-show"), "shows the accept invite page"); + assert.ok(exists('.user-field'), "it has at least one user field"); + assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled'); }); fillIn("#new-account-name", 'John Doe'); @@ -21,24 +21,24 @@ test("accept invite with user fields", () => { fillIn("#new-account-password", 'secur3ty4Y0uAndMe'); andThen(() => { - ok(exists(".username-input .good"), "username is valid"); - ok(exists('.invites-show .btn-primary:disabled'), 'submit is still disabled due to lack of user fields'); + assert.ok(exists(".username-input .good"), "username is valid"); + assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is still disabled due to lack of user fields'); }); fillIn(".user-field input[type=text]:first", "Barky"); andThen(() => { - ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled because field is not checked'); + assert.ok(exists('.invites-show .btn-primary:disabled'), 'submit is disabled because field is not checked'); }); click(".user-field input[type=checkbox]"); andThen(() => { - not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled because field is checked'); + assert.not(exists('.invites-show .btn-primary:disabled'), 'submit is enabled because field is checked'); }); click(".user-field input[type=checkbox]"); andThen(() => { - ok(exists('.invites-show .btn-primary:disabled'), 'unclicking the checkbox disables the submit'); + assert.ok(exists('.invites-show .btn-primary:disabled'), 'unclicking the checkbox disables the submit'); }); }); diff --git a/test/javascripts/acceptance/login-required-test.js.es6 b/test/javascripts/acceptance/login-required-test.js.es6 index 4bbec697a41..6153b12f22a 100644 --- a/test/javascripts/acceptance/login-required-test.js.es6 +++ b/test/javascripts/acceptance/login-required-test.js.es6 @@ -6,24 +6,24 @@ acceptance("Login Required", { } }); -test("redirect", () => { +QUnit.test("redirect", assert => { visit('/latest'); andThen(() => { - equal(currentPath(), "login", "it redirects them to login"); + assert.equal(currentPath(), "login", "it redirects them to login"); }); click('#site-logo'); andThen(() => { - equal(currentPath(), "login", "clicking the logo keeps them on login"); + assert.equal(currentPath(), "login", "clicking the logo keeps them on login"); }); click('header .login-button'); andThen(() => { - ok(exists('.login-modal'), "they can still access the login modal"); + assert.ok(exists('.login-modal'), "they can still access the login modal"); }); click('.modal-header .close'); andThen(() => { - ok(invisible('.login-modal'), "it closes the login modal"); + assert.ok(invisible('.login-modal'), "it closes the login modal"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/mobile-discovery-test.js.es6 b/test/javascripts/acceptance/mobile-discovery-test.js.es6 index 4d0198bffe7..564c5b4ec1f 100644 --- a/test/javascripts/acceptance/mobile-discovery-test.js.es6 +++ b/test/javascripts/acceptance/mobile-discovery-test.js.es6 @@ -1,15 +1,15 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Topic Discovery - Mobile", { mobileView: true }); -test("Visit Discovery Pages", () => { +QUnit.test("Visit Discovery Pages", assert => { visit("/"); andThen(() => { - ok(exists(".topic-list"), "The list of topics was rendered"); - ok(exists('.topic-list .topic-list-item'), "has topics"); + assert.ok(exists(".topic-list"), "The list of topics was rendered"); + assert.ok(exists('.topic-list .topic-list-item'), "has topics"); }); visit("/categories"); andThen(() => { - ok(exists('.category'), "has a list of categories"); + assert.ok(exists('.category'), "has a list of categories"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/mobile-sign-in-test.js.es6 b/test/javascripts/acceptance/mobile-sign-in-test.js.es6 index 80831091317..34c03ec7d83 100644 --- a/test/javascripts/acceptance/mobile-sign-in-test.js.es6 +++ b/test/javascripts/acceptance/mobile-sign-in-test.js.es6 @@ -2,10 +2,10 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Signing In - Mobile", { mobileView: true }); -test("sign in", () => { +QUnit.test("sign in", assert => { visit("/"); click("header .login-button"); andThen(() => { - ok(exists('#login-form'), "it shows the login modal"); + assert.ok(exists('#login-form'), "it shows the login modal"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/mobile-users-test.js.es6 b/test/javascripts/acceptance/mobile-users-test.js.es6 index 8cc2cb9da1b..70d5f2a0c52 100644 --- a/test/javascripts/acceptance/mobile-users-test.js.es6 +++ b/test/javascripts/acceptance/mobile-users-test.js.es6 @@ -2,9 +2,9 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("User Directory - Mobile", { mobileView: true }); -test("Visit Page", () => { +QUnit.test("Visit Page", assert => { visit("/users"); andThen(() => { - ok(exists('.directory .user'), "has a list of users"); + assert.ok(exists('.directory .user'), "has a list of users"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/modal-test.js.es6 b/test/javascripts/acceptance/modal-test.js.es6 index e3f0986f01b..1a570f222d7 100644 --- a/test/javascripts/acceptance/modal-test.js.es6 +++ b/test/javascripts/acceptance/modal-test.js.es6 @@ -1,30 +1,30 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Modal"); -test("modal", () => { +QUnit.test("modal", assert => { visit('/'); andThen(() => { - ok(find('#discourse-modal:visible').length === 0, 'there is no modal at first'); + assert.ok(find('#discourse-modal:visible').length === 0, 'there is no modal at first'); }); click('.login-button'); andThen(() => { - ok(find('#discourse-modal:visible').length === 1, 'modal should appear'); + assert.ok(find('#discourse-modal:visible').length === 1, 'modal should appear'); }); click('.modal-outer-container'); andThen(() => { - ok(find('#discourse-modal:visible').length === 0, 'modal should disappear when you click outside'); + assert.ok(find('#discourse-modal:visible').length === 0, 'modal should disappear when you click outside'); }); click('.login-button'); andThen(() => { - ok(find('#discourse-modal:visible').length === 1, 'modal should reappear'); + assert.ok(find('#discourse-modal:visible').length === 1, 'modal should reappear'); }); keyEvent('#main-outlet', 'keydown', 27); andThen(() => { - ok(find('#discourse-modal:visible').length === 0, 'ESC should close the modal'); + assert.ok(find('#discourse-modal:visible').length === 0, 'ESC should close the modal'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/password-reset-test.js.es6 b/test/javascripts/acceptance/password-reset-test.js.es6 index c8eaf488a2d..4706b88c29b 100644 --- a/test/javascripts/acceptance/password-reset-test.js.es6 +++ b/test/javascripts/acceptance/password-reset-test.js.es6 @@ -3,7 +3,7 @@ import PreloadStore from 'preload-store'; import { parsePostData } from "helpers/create-pretender"; acceptance("Password Reset", { - setup() { + beforeEach() { const response = (object) => { return [ 200, @@ -27,36 +27,35 @@ acceptance("Password Reset", { } }); -test("Password Reset Page", () => { +QUnit.test("Password Reset Page", assert => { PreloadStore.store('password_reset', {is_developer: false}); visit("/u/password-reset/myvalidtoken"); andThen(() => { - ok(exists(".password-reset input"), "shows the input"); + assert.ok(exists(".password-reset input"), "shows the input"); }); fillIn('.password-reset input', 'perf3ctly5ecur3'); andThen(() => { - ok(exists(".password-reset .tip.good"), "input looks good"); + assert.ok(exists(".password-reset .tip.good"), "input looks good"); }); fillIn('.password-reset input', '123'); andThen(() => { - ok(exists(".password-reset .tip.bad"), "input is not valid"); - ok(find(".password-reset .tip.bad").html().indexOf(I18n.t('user.password.too_short')) > -1, "password too short"); + assert.ok(exists(".password-reset .tip.bad"), "input is not valid"); + assert.ok(find(".password-reset .tip.bad").html().indexOf(I18n.t('user.password.too_short')) > -1, "password too short"); }); fillIn('.password-reset input', 'jonesyAlienSlayer'); click('.password-reset form button'); andThen(() => { - ok(exists(".password-reset .tip.bad"), "input is not valid"); - ok(find(".password-reset .tip.bad").html().indexOf("is the name of your cat") > -1, "server validation error message shows"); + assert.ok(exists(".password-reset .tip.bad"), "input is not valid"); + assert.ok(find(".password-reset .tip.bad").html().indexOf("is the name of your cat") > -1, "server validation error message shows"); }); fillIn('.password-reset input', 'perf3ctly5ecur3'); click('.password-reset form button'); andThen(() => { - ok(!exists(".password-reset form"), "form is gone"); + assert.ok(!exists(".password-reset form"), "form is gone"); }); -}); - +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/plugin-outlet-connector-class-test.js.es6 b/test/javascripts/acceptance/plugin-outlet-connector-class-test.js.es6 index 60a85e3cc77..b7a371d1e32 100644 --- a/test/javascripts/acceptance/plugin-outlet-connector-class-test.js.es6 +++ b/test/javascripts/acceptance/plugin-outlet-connector-class-test.js.es6 @@ -3,7 +3,7 @@ import { extraConnectorClass } from 'discourse/lib/plugin-connectors'; const PREFIX = "javascripts/single-test/connectors"; acceptance("Plugin Outlet - Connector Class", { - setup() { + beforeEach() { extraConnectorClass('user-profile-primary/hello', { actions: { sayHello() { @@ -28,13 +28,13 @@ acceptance("Plugin Outlet - Connector Class", { ); }, - teardown() { + afterEach() { delete Ember.TEMPLATES[`${PREFIX}/user-profile-primary/hello`]; delete Ember.TEMPLATES[`${PREFIX}/user-profile-primary/dont-render`]; } }); -test("Renders a template into the outlet", assert => { +QUnit.test("Renders a template into the outlet", assert => { visit("/u/eviltrout"); andThen(() => { assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names'); @@ -44,4 +44,4 @@ test("Renders a template into the outlet", assert => { andThen(() => { assert.equal(find('.hello-result').text(), 'hello!', 'actions delegate properly'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/plugin-outlet-multi-template-test.js.es6 b/test/javascripts/acceptance/plugin-outlet-multi-template-test.js.es6 index b74b46395be..3f4722d7576 100644 --- a/test/javascripts/acceptance/plugin-outlet-multi-template-test.js.es6 +++ b/test/javascripts/acceptance/plugin-outlet-multi-template-test.js.es6 @@ -5,20 +5,20 @@ const HELLO = 'javascripts/multi-test/connectors/user-profile-primary/hello'; const GOODBYE = 'javascripts/multi-test/connectors/user-profile-primary/goodbye'; acceptance("Plugin Outlet - Multi Template", { - setup() { + beforeEach() { clearCache(); Ember.TEMPLATES[HELLO] = Ember.HTMLBars.compile(`Hello`); Ember.TEMPLATES[GOODBYE] = Ember.HTMLBars.compile(`Goodbye`); }, - teardown() { + afterEach() { delete Ember.TEMPLATES[HELLO]; delete Ember.TEMPLATES[GOODBYE]; clearCache(); } }); -test("Renders a template into the outlet", assert => { +QUnit.test("Renders a template into the outlet", assert => { visit("/u/eviltrout"); andThen(() => { assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names'); @@ -26,4 +26,4 @@ test("Renders a template into the outlet", assert => { assert.equal(find('.hello-span').text(), 'Hello', 'it renders into the outlet'); assert.equal(find('.bye-span').text(), 'Goodbye', 'it renders into the outlet'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/plugin-outlet-single-template-test.js.es6 b/test/javascripts/acceptance/plugin-outlet-single-template-test.js.es6 index 63a05b36296..48ae7ba07c2 100644 --- a/test/javascripts/acceptance/plugin-outlet-single-template-test.js.es6 +++ b/test/javascripts/acceptance/plugin-outlet-single-template-test.js.es6 @@ -2,21 +2,21 @@ import { acceptance } from "helpers/qunit-helpers"; const CONNECTOR = 'javascripts/single-test/connectors/user-profile-primary/hello'; acceptance("Plugin Outlet - Single Template", { - setup() { + beforeEach() { Ember.TEMPLATES[CONNECTOR] = Ember.HTMLBars.compile( `{{model.username}}` ); }, - teardown() { + afterEach() { delete Ember.TEMPLATES[CONNECTOR]; } }); -test("Renders a template into the outlet", assert => { +QUnit.test("Renders a template into the outlet", assert => { visit("/u/eviltrout"); andThen(() => { assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names'); assert.equal(find('.hello-username').text(), 'eviltrout', 'it renders into the outlet'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/preferences-test.js.es6 b/test/javascripts/acceptance/preferences-test.js.es6 index ccd2aff7b41..e4607f5bcf1 100644 --- a/test/javascripts/acceptance/preferences-test.js.es6 +++ b/test/javascripts/acceptance/preferences-test.js.es6 @@ -1,20 +1,20 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("User Preferences", { loggedIn: true }); -test("update some fields", () => { +QUnit.test("update some fields", assert => { visit("/u/eviltrout/preferences"); andThen(() => { - ok($('body.user-preferences-page').length, "has the body class"); - equal(currentURL(), '/u/eviltrout/preferences/account', "defaults to account tab"); - ok(exists('.user-preferences'), 'it shows the preferences'); + assert.ok($('body.user-preferences-page').length, "has the body class"); + assert.equal(currentURL(), '/u/eviltrout/preferences/account', "defaults to account tab"); + assert.ok(exists('.user-preferences'), 'it shows the preferences'); }); const savePreferences = () => { click('.save-user'); - ok(!exists('.saved-user'), "it hasn't been saved yet"); + assert.ok(!exists('.saved-user'), "it hasn't been saved yet"); andThen(() => { - ok(exists('.saved-user'), 'it displays the saved message'); + assert.ok(exists('.saved-user'), 'it displays the saved message'); }); }; @@ -37,39 +37,39 @@ test("update some fields", () => { fillIn('.category-controls .category-selector', 'faq'); savePreferences(); - ok(!exists('.preferences-nav .nav-tags a'), "tags tab isn't there when tags are disabled"); + assert.ok(!exists('.preferences-nav .nav-tags a'), "tags tab isn't there when tags are disabled"); // Error: Unhandled request in test environment: /themes/assets/10d71596-7e4e-4dc0-b368-faa3b6f1ce6d?_=1493833562388 (GET) // click(".preferences-nav .nav-interface a"); // click('.control-group.other input[type=checkbox]:first'); // savePreferences(); - ok(!exists('.preferences-nav .nav-apps a'), "apps tab isn't there when you have no authorized apps"); + assert.ok(!exists('.preferences-nav .nav-apps a'), "apps tab isn't there when you have no authorized apps"); }); -test("username", () => { +QUnit.test("username", assert => { visit("/u/eviltrout/preferences/username"); andThen(() => { - ok(exists("#change_username"), "it has the input element"); + assert.ok(exists("#change_username"), "it has the input element"); }); }); -test("about me", () => { +QUnit.test("about me", assert => { visit("/u/eviltrout/preferences/about-me"); andThen(() => { - ok(exists(".raw-bio"), "it has the input element"); + assert.ok(exists(".raw-bio"), "it has the input element"); }); }); -test("email", () => { +QUnit.test("email", assert => { visit("/u/eviltrout/preferences/email"); andThen(() => { - ok(exists("#change-email"), "it has the input element"); + assert.ok(exists("#change-email"), "it has the input element"); }); fillIn("#change-email", 'invalidemail'); andThen(() => { - equal(find('.tip.bad').text().trim(), I18n.t('user.email.invalid'), 'it should display invalid email tip'); + assert.equal(find('.tip.bad').text().trim(), I18n.t('user.email.invalid'), 'it should display invalid email tip'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/raw-plugin-outlet-test.js.es6 b/test/javascripts/acceptance/raw-plugin-outlet-test.js.es6 index e21de0a31ec..5303d53cfe2 100644 --- a/test/javascripts/acceptance/raw-plugin-outlet-test.js.es6 +++ b/test/javascripts/acceptance/raw-plugin-outlet-test.js.es6 @@ -2,21 +2,21 @@ import { acceptance } from "helpers/qunit-helpers"; const CONNECTOR = 'javascripts/raw-test/connectors/topic-list-before-status/lala'; acceptance("Raw Plugin Outlet", { - setup() { + beforeEach() { Discourse.RAW_TEMPLATES[CONNECTOR] = Handlebars.compile( `{{context.topic.id}}` ); }, - teardown() { + afterEach() { delete Discourse.RAW_TEMPLATES[CONNECTOR]; } }); -test("Renders the raw plugin outlet", assert => { +QUnit.test("Renders the raw plugin outlet", assert => { visit("/"); andThen(() => { assert.ok(find('.topic-lala').length > 0, 'it renders the outlet'); assert.equal(find('.topic-lala:eq(0)').text(), '11557', 'it has the topic id'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/search-full-test.js.es6 b/test/javascripts/acceptance/search-full-test.js.es6 index d8050d72f4c..b978f8879d5 100644 --- a/test/javascripts/acceptance/search-full-test.js.es6 +++ b/test/javascripts/acceptance/search-full-test.js.es6 @@ -1,7 +1,7 @@ import { acceptance, waitFor } from "helpers/qunit-helpers"; acceptance("Search - Full Page", { settings: {tagging_enabled: true}, - setup() { + beforeEach() { const response = (object) => { return [ 200, @@ -39,12 +39,12 @@ acceptance("Search - Full Page", { } }); -test("perform various searches", assert => { +QUnit.test("perform various searches", assert => { visit("/search"); andThen(() => { - ok($('body.search-page').length, "has body class"); - ok(exists('.search-container'), "has container class"); + assert.ok($('body.search-page').length, "has body class"); + assert.ok(exists('.search-container'), "has container class"); assert.ok(find('input.search').length > 0); assert.ok(find('.fps-topic').length === 0); }); @@ -60,7 +60,7 @@ test("perform various searches", assert => { andThen(() => assert.ok(find('.fps-topic').length === 1, 'has one post')); }); -test("open advanced search", assert => { +QUnit.test("open advanced search", assert => { visit("/search"); andThen(() => assert.ok(exists('.search .search-advanced'), 'shows advanced search panel')); @@ -95,7 +95,7 @@ test("open advanced search", assert => { // }); // }); -test("escape search term", (assert) => { +QUnit.test("escape search term", (assert) => { visit("/search"); fillIn('.search input.full-page-search', '@gmail.com'); click('.search-advanced-btn'); @@ -105,7 +105,7 @@ test("escape search term", (assert) => { }); }); -test("update username through advanced search ui", assert => { +QUnit.test("update username through advanced search ui", assert => { visit("/search"); fillIn('.search input.full-page-search', 'none'); click('.search-advanced-btn'); @@ -114,7 +114,7 @@ test("update username through advanced search ui", assert => { keyEvent('.search-advanced-options .user-selector', 'keydown', 8); andThen(() => { - waitFor(() => { + waitFor(assert, () => { assert.ok(visible('.search-advanced-options .autocomplete'), '"autocomplete" popup is visible'); assert.ok(exists('.search-advanced-options .autocomplete ul li a span.username:contains("admin")'), '"autocomplete" popup has an entry for "admin"'); @@ -128,7 +128,7 @@ test("update username through advanced search ui", assert => { }); }); -test("update category through advanced search ui", assert => { +QUnit.test("update category through advanced search ui", assert => { visit("/search"); fillIn('.search input.full-page-search', 'none'); click('.search-advanced-btn'); @@ -209,7 +209,7 @@ test("update category through advanced search ui", assert => { // }); // }); -test("update in:likes filter through advanced search ui", assert => { +QUnit.test("update in:likes filter through advanced search ui", assert => { visit("/search"); fillIn('.search input.full-page-search', 'none'); click('.search-advanced-btn'); @@ -221,7 +221,7 @@ test("update in:likes filter through advanced search ui", assert => { }); }); -test("update in:private filter through advanced search ui", assert => { +QUnit.test("update in:private filter through advanced search ui", assert => { visit("/search"); fillIn('.search input.full-page-search', 'none'); click('.search-advanced-btn'); @@ -233,7 +233,7 @@ test("update in:private filter through advanced search ui", assert => { }); }); -test("update in:seen filter through advanced search ui", assert => { +QUnit.test("update in:seen filter through advanced search ui", assert => { visit("/search"); fillIn('.search input.full-page-search', 'none'); click('.search-advanced-btn'); @@ -248,7 +248,7 @@ test("update in:seen filter through advanced search ui", assert => { }); }); -test("update in filter through advanced search ui", assert => { +QUnit.test("update in filter through advanced search ui", assert => { visit("/search"); fillIn('.search input.full-page-search', 'none'); click('.search-advanced-btn'); @@ -261,7 +261,7 @@ test("update in filter through advanced search ui", assert => { }); }); -test("update status through advanced search ui", assert => { +QUnit.test("update status through advanced search ui", assert => { visit("/search"); fillIn('.search input.full-page-search', 'none'); click('.search-advanced-btn'); @@ -274,7 +274,7 @@ test("update status through advanced search ui", assert => { }); }); -test("update post time through advanced search ui", assert => { +QUnit.test("update post time through advanced search ui", assert => { visit("/search"); fillIn('.search input.full-page-search', 'none'); click('.search-advanced-btn'); @@ -289,7 +289,7 @@ test("update post time through advanced search ui", assert => { }); }); -test("update min post count through advanced search ui", assert => { +QUnit.test("update min post count through advanced search ui", assert => { visit("/search"); fillIn('.search input.full-page-search', 'none'); click('.search-advanced-btn'); @@ -301,7 +301,7 @@ test("update min post count through advanced search ui", assert => { }); }); -test("validate advanced search when initially empty", assert => { +QUnit.test("validate advanced search when initially empty", assert => { visit("/search?expanded=true"); click('.search-advanced-options .in-likes'); diff --git a/test/javascripts/acceptance/search-test.js.es6 b/test/javascripts/acceptance/search-test.js.es6 index b80552708bc..475c164137f 100644 --- a/test/javascripts/acceptance/search-test.js.es6 +++ b/test/javascripts/acceptance/search-test.js.es6 @@ -1,7 +1,7 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Search"); -test("search", (assert) => { +QUnit.test("search", (assert) => { visit("/"); click('#search-button'); @@ -25,29 +25,29 @@ test("search", (assert) => { }); }); -test("search scope checkbox", () => { +QUnit.test("search scope checkbox", assert => { visit("/c/bug"); click('#search-button'); andThen(() => { - ok(exists('.search-context input:checked'), 'scope to category checkbox is checked'); + assert.ok(exists('.search-context input:checked'), 'scope to category checkbox is checked'); }); click('#search-button'); visit("/t/internationalization-localization/280"); click('#search-button'); andThen(() => { - not(exists('.search-context input:checked'), 'scope to topic checkbox is not checked'); + assert.not(exists('.search-context input:checked'), 'scope to topic checkbox is not checked'); }); click('#search-button'); visit("/u/eviltrout"); click('#search-button'); andThen(() => { - ok(exists('.search-context input:checked'), 'scope to user checkbox is checked'); + assert.ok(exists('.search-context input:checked'), 'scope to user checkbox is checked'); }); }); -test("Search with context", assert => { +QUnit.test("Search with context", assert => { visit("/t/internationalization-localization/280/1"); click('#search-button'); @@ -72,4 +72,4 @@ test("Search with context", assert => { andThen(() => { assert.ok(!$('.search-context input[type=checkbox]').is(":checked")); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/sign-in-test.js.es6 b/test/javascripts/acceptance/sign-in-test.js.es6 index 21403770ba6..12d77228a59 100644 --- a/test/javascripts/acceptance/sign-in-test.js.es6 +++ b/test/javascripts/acceptance/sign-in-test.js.es6 @@ -1,11 +1,11 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Signing In"); -test("sign in", () => { +QUnit.test("sign in", assert => { visit("/"); click("header .login-button"); andThen(() => { - ok(exists('.login-modal'), "it shows the login modal"); + assert.ok(exists('.login-modal'), "it shows the login modal"); }); // Test invalid password first @@ -13,48 +13,48 @@ test("sign in", () => { fillIn('#login-account-password', 'incorrect'); click('.modal-footer .btn-primary'); andThen(() => { - ok(exists('#modal-alert:visible'), 'it displays the login error'); - not(exists('.modal-footer .btn-primary:disabled'), "enables the login button"); + assert.ok(exists('#modal-alert:visible'), 'it displays the login error'); + assert.not(exists('.modal-footer .btn-primary:disabled'), "enables the login button"); }); // Use the correct password fillIn('#login-account-password', 'correct'); click('.modal-footer .btn-primary'); andThen(() => { - ok(exists('.modal-footer .btn-primary:disabled'), "disables the login button"); + assert.ok(exists('.modal-footer .btn-primary:disabled'), "disables the login button"); }); }); -test("sign in - not activated", () => { +QUnit.test("sign in - not activated", assert => { visit("/"); andThen(() => { click("header .login-button"); andThen(() => { - ok(exists('.login-modal'), "it shows the login modal"); + assert.ok(exists('.login-modal'), "it shows the login modal"); }); fillIn('#login-account-name', 'eviltrout'); fillIn('#login-account-password', 'not-activated'); click('.modal-footer .btn-primary'); andThen(() => { - equal(find('.modal-body b').text(), 'eviltrout@example.com'); - ok(!exists('.modal-body small'), 'it escapes the email address'); + assert.equal(find('.modal-body b').text(), 'eviltrout@example.com'); + assert.ok(!exists('.modal-body small'), 'it escapes the email address'); }); click('.modal-footer button.resend'); andThen(() => { - equal(find('.modal-body b').text(), 'current@example.com'); - ok(!exists('.modal-body small'), 'it escapes the email address'); + assert.equal(find('.modal-body b').text(), 'current@example.com'); + assert.ok(!exists('.modal-body small'), 'it escapes the email address'); }); }); }); -test("sign in - not activated - edit email", () => { +QUnit.test("sign in - not activated - edit email", assert => { visit("/"); andThen(() => { click("header .login-button"); andThen(() => { - ok(exists('.login-modal'), "it shows the login modal"); + assert.ok(exists('.login-modal'), "it shows the login modal"); }); fillIn('#login-account-name', 'eviltrout'); @@ -62,27 +62,27 @@ test("sign in - not activated - edit email", () => { click('.modal-footer .btn-primary'); click('.modal-footer button.edit-email'); andThen(() => { - equal(find('.activate-new-email').val(), 'current@example.com'); - equal(find('.modal-footer .btn-primary:disabled').length, 1, "must change email"); + assert.equal(find('.activate-new-email').val(), 'current@example.com'); + assert.equal(find('.modal-footer .btn-primary:disabled').length, 1, "must change email"); }); fillIn('.activate-new-email', 'different@example.com'); andThen(() => { - equal(find('.modal-footer .btn-primary:disabled').length, 0); + assert.equal(find('.modal-footer .btn-primary:disabled').length, 0); }); click(".modal-footer .btn-primary"); andThen(() => { - equal(find('.modal-body b').text(), 'different@example.com'); + assert.equal(find('.modal-body b').text(), 'different@example.com'); }); }); }); -test("create account", () => { +QUnit.test("create account", assert => { visit("/"); click("header .sign-up-button"); andThen(() => { - ok(exists('.create-account'), "it shows the create account modal"); - ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first'); + assert.ok(exists('.create-account'), "it shows the create account modal"); + assert.ok(exists('.modal-footer .btn-primary:disabled'), 'create account is disabled at first'); }); fillIn('#new-account-name', 'Dr. Good Tuna'); @@ -92,18 +92,18 @@ test("create account", () => { fillIn('#new-account-email', 'good.tuna@test.com'); fillIn('#new-account-username', 'taken'); andThen(() => { - ok(exists('#username-validation.bad'), 'the username validation is bad'); - ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled'); + assert.ok(exists('#username-validation.bad'), 'the username validation is bad'); + assert.ok(exists('.modal-footer .btn-primary:disabled'), 'create account is still disabled'); }); fillIn('#new-account-username', 'goodtuna'); andThen(() => { - ok(exists('#username-validation.good'), 'the username validation is good'); - not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled'); + assert.ok(exists('#username-validation.good'), 'the username validation is good'); + assert.not(exists('.modal-footer .btn-primary:disabled'), 'create account is enabled'); }); click('.modal-footer .btn-primary'); andThen(() => { - ok(exists('.modal-footer .btn-primary:disabled'), "create account is disabled"); + assert.ok(exists('.modal-footer .btn-primary:disabled'), "create account is disabled"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/static-test.js.es6 b/test/javascripts/acceptance/static-test.js.es6 index 26bc4e594bc..97592dbd4a9 100644 --- a/test/javascripts/acceptance/static-test.js.es6 +++ b/test/javascripts/acceptance/static-test.js.es6 @@ -1,33 +1,33 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Static"); -test("Static Pages", () => { +QUnit.test("Static Pages", assert => { visit("/faq"); andThen(() => { - ok($('body.static-faq').length, "has the body class"); - ok(exists(".body-page"), "The content is present"); + assert.ok($('body.static-faq').length, "has the body class"); + assert.ok(exists(".body-page"), "The content is present"); }); visit("/guidelines"); andThen(() => { - ok($('body.static-guidelines').length, "has the body class"); - ok(exists(".body-page"), "The content is present"); + assert.ok($('body.static-guidelines').length, "has the body class"); + assert.ok(exists(".body-page"), "The content is present"); }); visit("/tos"); andThen(() => { - ok($('body.static-tos').length, "has the body class"); - ok(exists(".body-page"), "The content is present"); + assert.ok($('body.static-tos').length, "has the body class"); + assert.ok(exists(".body-page"), "The content is present"); }); visit("/privacy"); andThen(() => { - ok($('body.static-privacy').length, "has the body class"); - ok(exists(".body-page"), "The content is present"); + assert.ok($('body.static-privacy').length, "has the body class"); + assert.ok(exists(".body-page"), "The content is present"); }); visit("/login"); andThen(() => { - equal(currentPath(), "discovery.latest", "it redirects them to latest unless `login_required`"); + assert.equal(currentPath(), "discovery.latest", "it redirects them to latest unless `login_required`"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/tag-hashtag-test.js.es6 b/test/javascripts/acceptance/tag-hashtag-test.js.es6 index e20c0afade6..559b9ff9269 100644 --- a/test/javascripts/acceptance/tag-hashtag-test.js.es6 +++ b/test/javascripts/acceptance/tag-hashtag-test.js.es6 @@ -3,7 +3,7 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Tag Hashtag", { loggedIn: true, settings: { tagging_enabled: true }, - setup() { + beforeEach() { const response = (object) => { return [ 200, @@ -26,18 +26,18 @@ acceptance("Tag Hashtag", { } }); -test("tag is cooked properly", () => { +QUnit.test("tag is cooked properly", assert => { visit("/t/internationalization-localization/280"); click('#topic-footer-buttons .btn.create'); fillIn('.d-editor-input', "this is a tag hashtag #monkey::tag"); andThen(() => { // TODO: Test that the autocomplete shows - equal(find('.d-editor-preview:visible').html().trim(), "this is a tag hashtag #monkey
"); + assert.equal(find('.d-editor-preview:visible').html().trim(), "this is a tag hashtag #monkey
"); }); click('#reply-control .btn.create'); andThen(() => { - equal(find('.topic-post:last .cooked').html().trim(), "this is a tag hashtag #monkey
"); + assert.equal(find('.topic-post:last .cooked').html().trim(), "this is a tag hashtag #monkey
"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/tags-test.js.es6 b/test/javascripts/acceptance/tags-test.js.es6 index c24cbee8d18..ca7a745a94c 100644 --- a/test/javascripts/acceptance/tags-test.js.es6 +++ b/test/javascripts/acceptance/tags-test.js.es6 @@ -1,11 +1,11 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Tags", { loggedIn: true }); -test("list the tags", () => { +QUnit.test("list the tags", assert => { visit("/tags"); andThen(() => { - ok($('body.tags-page').length, "has the body class"); - ok(exists('.tag-eviltrout'), "shows the evil trout tag"); + assert.ok($('body.tags-page').length, "has the body class"); + assert.ok(exists('.tag-eviltrout'), "shows the evil trout tag"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/topic-anonymous-test.js.es6 b/test/javascripts/acceptance/topic-anonymous-test.js.es6 index 831968a21c3..f077e99fca3 100644 --- a/test/javascripts/acceptance/topic-anonymous-test.js.es6 +++ b/test/javascripts/acceptance/topic-anonymous-test.js.es6 @@ -1,22 +1,22 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Topic - Anonymous"); -test("Enter a Topic", () => { +QUnit.test("Enter a Topic", assert => { visit("/t/internationalization-localization/280/1"); andThen(() => { - ok(exists("#topic"), "The topic was rendered"); - ok(exists("#topic .cooked"), "The topic has cooked posts"); + assert.ok(exists("#topic"), "The topic was rendered"); + assert.ok(exists("#topic .cooked"), "The topic has cooked posts"); }); }); -test("Enter without an id", () => { +QUnit.test("Enter without an id", assert => { visit("/t/internationalization-localization"); andThen(() => { - ok(exists("#topic"), "The topic was rendered"); + assert.ok(exists("#topic"), "The topic was rendered"); }); }); -test("Enter a 404 topic", assert => { +QUnit.test("Enter a 404 topic", assert => { visit("/t/not-found/404"); andThen(() => { assert.ok(!exists("#topic"), "The topic was not rendered"); @@ -24,7 +24,7 @@ test("Enter a 404 topic", assert => { }); }); -test("Enter without access", assert => { +QUnit.test("Enter without access", assert => { visit("/t/i-dont-have-access/403"); andThen(() => { assert.ok(!exists("#topic"), "The topic was not rendered"); @@ -32,10 +32,10 @@ test("Enter without access", assert => { }); }); -test("Enter with 500 errors", assert => { +QUnit.test("Enter with 500 errors", assert => { visit("/t/throws-error/500"); andThen(() => { assert.ok(!exists("#topic"), "The topic was not rendered"); assert.ok(exists(".topic-error"), "An error message is displayed"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/topic-discovery-test.js.es6 b/test/javascripts/acceptance/topic-discovery-test.js.es6 index c0767e82829..458c3471a03 100644 --- a/test/javascripts/acceptance/topic-discovery-test.js.es6 +++ b/test/javascripts/acceptance/topic-discovery-test.js.es6 @@ -1,46 +1,46 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Topic Discovery"); -test("Visit Discovery Pages", () => { +QUnit.test("Visit Discovery Pages", assert => { visit("/"); andThen(() => { - ok($('body.navigation-topics').length, "has the default navigation"); - ok(exists(".topic-list"), "The list of topics was rendered"); - ok(exists('.topic-list .topic-list-item'), "has topics"); + assert.ok($('body.navigation-topics').length, "has the default navigation"); + assert.ok(exists(".topic-list"), "The list of topics was rendered"); + assert.ok(exists('.topic-list .topic-list-item'), "has topics"); }); visit("/c/bug"); andThen(() => { - ok(exists(".topic-list"), "The list of topics was rendered"); - ok(exists('.topic-list .topic-list-item'), "has topics"); - ok(!exists('.category-list'), "doesn't render subcategories"); - ok($('body.category-bug').length, "has a custom css class for the category id on the body"); + assert.ok(exists(".topic-list"), "The list of topics was rendered"); + assert.ok(exists('.topic-list .topic-list-item'), "has topics"); + assert.ok(!exists('.category-list'), "doesn't render subcategories"); + assert.ok($('body.category-bug').length, "has a custom css class for the category id on the body"); }); visit("/categories"); andThen(() => { - ok($('body.navigation-categories').length, "has the body class"); - ok($('body.category-bug').length === 0, "removes the custom category class"); - ok(exists('.category'), "has a list of categories"); - ok($('body.categories-list').length, "has a custom class to indicate categories"); + assert.ok($('body.navigation-categories').length, "has the body class"); + assert.ok($('body.category-bug').length === 0, "removes the custom category class"); + assert.ok(exists('.category'), "has a list of categories"); + assert.ok($('body.categories-list').length, "has a custom class to indicate categories"); }); visit("/top"); andThen(() => { - ok($('body.categories-list').length === 0, "removes the `categories-list` class"); - ok(exists('.topic-list .topic-list-item'), "has topics"); + assert.ok($('body.categories-list').length === 0, "removes the `categories-list` class"); + assert.ok(exists('.topic-list .topic-list-item'), "has topics"); }); visit("/c/feature"); andThen(() => { - ok(exists(".topic-list"), "The list of topics was rendered"); - ok(exists(".category-boxes"), "The list of subcategories were rendered with box style"); + assert.ok(exists(".topic-list"), "The list of topics was rendered"); + assert.ok(exists(".category-boxes"), "The list of subcategories were rendered with box style"); }); visit("/c/dev"); andThen(() => { - ok(exists(".topic-list"), "The list of topics was rendered"); - ok(exists(".category-boxes-with-topics"), "The list of subcategories were rendered with box-with-featured-topics style"); - ok(exists(".category-boxes-with-topics .featured-topics"), "The featured topics are there too"); + assert.ok(exists(".topic-list"), "The list of topics was rendered"); + assert.ok(exists(".category-boxes-with-topics"), "The list of subcategories were rendered with box-with-featured-topics style"); + assert.ok(exists(".category-boxes-with-topics .featured-topics"), "The featured topics are there too"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/topic-notifications-button-test.js.es6 b/test/javascripts/acceptance/topic-notifications-button-test.js.es6 index 4689b86bb09..bb1c314a1c0 100644 --- a/test/javascripts/acceptance/topic-notifications-button-test.js.es6 +++ b/test/javascripts/acceptance/topic-notifications-button-test.js.es6 @@ -1,7 +1,7 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Topic Notifications button", { loggedIn: true, - setup() { + beforeEach() { const response = object => { return [ 200, @@ -16,13 +16,13 @@ acceptance("Topic Notifications button", { } }); -test("Updating topic notification level", () => { +QUnit.test("Updating topic notification level", assert => { visit("/t/internationalization-localization/280"); const notificationOptions = "#topic-footer-buttons .notification-options"; andThen(() => { - ok( + assert.ok( exists(`${notificationOptions} .tracking`), "it should display the notification options button in the topic's footer" ); @@ -32,7 +32,7 @@ test("Updating topic notification level", () => { click(`${notificationOptions} .dropdown-menu .watching`); andThen(() => { - ok( + assert.ok( exists(`${notificationOptions} .watching`), "it should display the right notification level" ); @@ -44,4 +44,4 @@ test("Updating topic notification level", () => { // 'it should display the right notification level in topic timeline' // ); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/topic-test.js.es6 b/test/javascripts/acceptance/topic-test.js.es6 index a3b85778ce6..08b54bfd519 100644 --- a/test/javascripts/acceptance/topic-test.js.es6 +++ b/test/javascripts/acceptance/topic-test.js.es6 @@ -1,20 +1,20 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Topic", { loggedIn: true }); -test("Share Popup", () => { +QUnit.test("Share Popup", assert => { visit("/t/internationalization-localization/280"); andThen(() => { - ok(!exists('#share-link.visible'), 'it is not visible'); + assert.ok(!exists('#share-link.visible'), 'it is not visible'); }); click("button[data-share-url]"); andThen(() => { - ok(exists('#share-link.visible'), 'it shows the popup'); + assert.ok(exists('#share-link.visible'), 'it shows the popup'); }); click('#share-link .close-share'); andThen(() => { - ok(!exists('#share-link.visible'), 'it closes the popup'); + assert.ok(!exists('#share-link.visible'), 'it closes the popup'); }); // TODO tgxworld This fails on Travis but we need to push the security fix out @@ -30,23 +30,23 @@ test("Share Popup", () => { // }); }); -test("Showing and hiding the edit controls", () => { +QUnit.test("Showing and hiding the edit controls", assert => { visit("/t/internationalization-localization/280"); click('#topic-title .fa-pencil'); andThen(() => { - ok(exists('#edit-title'), 'it shows the editing controls'); + assert.ok(exists('#edit-title'), 'it shows the editing controls'); }); fillIn('#edit-title', 'this is the new title'); click('#topic-title .cancel-edit'); andThen(() => { - ok(!exists('#edit-title'), 'it hides the editing controls'); + assert.ok(!exists('#edit-title'), 'it hides the editing controls'); }); }); -test("Updating the topic title and category", () => { +QUnit.test("Updating the topic title and category", assert => { visit("/t/internationalization-localization/280"); click('#topic-title .fa-pencil'); @@ -56,12 +56,12 @@ test("Updating the topic title and category", () => { click('#topic-title .submit-edit'); andThen(() => { - equal(find('#topic-title .badge-category').text(), 'faq', 'it displays the new category'); - equal(find('.fancy-title').text().trim(), 'this is the new title', 'it displays the new title'); + assert.equal(find('#topic-title .badge-category').text(), 'faq', 'it displays the new category'); + assert.equal(find('.fancy-title').text().trim(), 'this is the new title', 'it displays the new title'); }); }); -test("Marking a topic as wiki", () => { +QUnit.test("Marking a topic as wiki", assert => { server.put('/posts/398/wiki', () => { // eslint-disable-line no-undef return [ 200, @@ -73,7 +73,7 @@ test("Marking a topic as wiki", () => { visit("/t/internationalization-localization/280"); andThen(() => { - ok(find('a.wiki').length === 0, 'it does not show the wiki icon'); + assert.ok(find('a.wiki').length === 0, 'it does not show the wiki icon'); }); click('.topic-post:eq(0) button.show-more-actions'); @@ -81,39 +81,39 @@ test("Marking a topic as wiki", () => { click('.btn.wiki'); andThen(() => { - ok(find('a.wiki').length === 1, 'it shows the wiki icon'); + assert.ok(find('a.wiki').length === 1, 'it shows the wiki icon'); }); }); -test("Reply as new topic", () => { +QUnit.test("Reply as new topic", assert => { visit("/t/internationalization-localization/280"); click("button.share:eq(0)"); click(".reply-as-new-topic a"); andThen(() => { - ok(exists('.d-editor-input'), 'the composer input is visible'); + assert.ok(exists('.d-editor-input'), 'the composer input is visible'); - equal( + assert.equal( find('.d-editor-input').val().trim(), `Continuing the discussion from [Internationalization / localization](${window.location.origin}/t/internationalization-localization/280):`, "it fills composer with the ring string" ); - equal( + assert.equal( find('.category-combobox').select2('data').text, "feature", "it fills category selector with the right category" ); }); }); -test("Reply as new message", () => { +QUnit.test("Reply as new message", assert => { visit("/t/pm-for-testing/12"); click("button.share:eq(0)"); click(".reply-as-new-topic a"); andThen(() => { - ok(exists('.d-editor-input'), 'the composer input is visible'); + assert.ok(exists('.d-editor-input'), 'the composer input is visible'); - equal( + assert.equal( find('.d-editor-input').val().trim(), `Continuing the discussion from [PM for testing](${window.location.origin}/t/pm-for-testing/12):`, "it fills composer with the ring string" @@ -121,24 +121,24 @@ test("Reply as new message", () => { const targets = find('.item span', '.composer-fields'); - equal( + assert.equal( $(targets[0]).text(), "someguy", "it fills up the composer with the right user to start the PM to" ); - equal( + assert.equal( $(targets[1]).text(), "test", "it fills up the composer with the right user to start the PM to" ); - equal( + assert.equal( $(targets[2]).text(), "Group", "it fills up the composer with the right group to start the PM to" ); }); }); -test("Updating the topic title with emojis", () => { +QUnit.test("Updating the topic title with emojis", assert => { visit("/t/internationalization-localization/280"); click('#topic-title .fa-pencil'); @@ -147,6 +147,6 @@ test("Updating the topic title with emojis", () => { click('#topic-title .submit-edit'); andThen(() => { - equal(find('.fancy-title').html().trim(), 'emojis title ', 'it displays the new title with emojis'); + assert.equal(find('.fancy-title').html().trim(), 'emojis title ', 'it displays the new title with emojis'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/unknown-test.js.es6 b/test/javascripts/acceptance/unknown-test.js.es6 index 148d8d2eefd..541df10e1f0 100644 --- a/test/javascripts/acceptance/unknown-test.js.es6 +++ b/test/javascripts/acceptance/unknown-test.js.es6 @@ -1,10 +1,10 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Unknown"); -test("Unknown URL", () => { - expect(1); +QUnit.test("Unknown URL", assert => { + assert.expect(1); visit("/url-that-doesn't-exist"); andThen(() => { - ok(exists(".page-not-found"), "The not found content is present"); + assert.ok(exists(".page-not-found"), "The not found content is present"); }); }); diff --git a/test/javascripts/acceptance/user-anonymous-test.js.es6 b/test/javascripts/acceptance/user-anonymous-test.js.es6 index ae9b7c149f4..91f3c62c758 100644 --- a/test/javascripts/acceptance/user-anonymous-test.js.es6 +++ b/test/javascripts/acceptance/user-anonymous-test.js.es6 @@ -1,54 +1,54 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("User Anonymous"); -export function hasStream() { +function hasStream(assert) { andThen(() => { - ok(exists('.user-main .about'), 'it has the about section'); - ok(count('.user-stream .item') > 0, 'it has stream items'); + assert.ok(exists('.user-main .about'), 'it has the about section'); + assert.ok(count('.user-stream .item') > 0, 'it has stream items'); }); } -function hasTopicList() { +function hasTopicList(assert) { andThen(() => { - equal(count('.user-stream .item'), 0, "has no stream displayed"); - ok(count('.topic-list tr') > 0, 'it has a topic list'); + assert.equal(count('.user-stream .item'), 0, "has no stream displayed"); + assert.ok(count('.topic-list tr') > 0, 'it has a topic list'); }); } -test("Root URL", () => { +QUnit.test("Root URL", assert => { visit("/u/eviltrout"); andThen(() => { - ok($('body.user-summary-page').length, "has the body class"); - equal(currentPath(), 'user.summary', "it defaults to summary"); + assert.ok($('body.user-summary-page').length, "has the body class"); + assert.equal(currentPath(), 'user.summary', "it defaults to summary"); }); }); -test("Filters", () => { +QUnit.test("Filters", assert => { visit("/u/eviltrout/activity"); andThen(() => { - ok($('body.user-activity-page').length, "has the body class"); + assert.ok($('body.user-activity-page').length, "has the body class"); }); - hasStream(); + hasStream(assert); visit("/u/eviltrout/activity/topics"); - hasTopicList(); + hasTopicList(assert); visit("/u/eviltrout/activity/replies"); - hasStream(); + hasStream(assert); }); -test("Badges", () => { +QUnit.test("Badges", assert => { visit("/u/eviltrout/badges"); andThen(() => { - ok($('body.user-badges-page').length, "has the body class"); - ok(exists(".user-badges-list .badge-card"), "shows a badge"); + assert.ok($('body.user-badges-page').length, "has the body class"); + assert.ok(exists(".user-badges-list .badge-card"), "shows a badge"); }); }); -test("Restricted Routes", () => { +QUnit.test("Restricted Routes", assert => { visit("/u/eviltrout/preferences"); andThen(() => { - equal(currentURL(), '/u/eviltrout/activity', "it redirects from preferences"); + assert.equal(currentURL(), '/u/eviltrout/activity', "it redirects from preferences"); }); }); diff --git a/test/javascripts/acceptance/user-card-test.js.es6 b/test/javascripts/acceptance/user-card-test.js.es6 index 4a4d7288bfd..e19d96836b7 100644 --- a/test/javascripts/acceptance/user-card-test.js.es6 +++ b/test/javascripts/acceptance/user-card-test.js.es6 @@ -1,14 +1,14 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("User Card"); -test("card", () => { +QUnit.test("card", assert => { visit('/'); - ok(invisible('#user-card'), 'user card is invisible by default'); + assert.ok(invisible('#user-card'), 'user card is invisible by default'); click('a[data-user-card=eviltrout]:first'); andThen(() => { - ok(visible('#user-card'), 'card should appear'); + assert.ok(visible('#user-card'), 'card should appear'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/user-test.js.es6 b/test/javascripts/acceptance/user-test.js.es6 index 84269cbe08c..22759a7ee7e 100644 --- a/test/javascripts/acceptance/user-test.js.es6 +++ b/test/javascripts/acceptance/user-test.js.es6 @@ -2,32 +2,32 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("User", {loggedIn: true}); -test("Invites", () => { +QUnit.test("Invites", assert => { visit("/u/eviltrout/invited/pending"); andThen(() => { - ok($('body.user-invites-page').length, "has the body class"); + assert.ok($('body.user-invites-page').length, "has the body class"); }); }); -test("Messages", () => { +QUnit.test("Messages", assert => { visit("/u/eviltrout/messages"); andThen(() => { - ok($('body.user-messages-page').length, "has the body class"); + assert.ok($('body.user-messages-page').length, "has the body class"); }); }); -test("Notifications", () => { +QUnit.test("Notifications", assert => { visit("/u/eviltrout/notifications"); andThen(() => { - ok($('body.user-notifications-page').length, "has the body class"); + assert.ok($('body.user-notifications-page').length, "has the body class"); }); }); -test("Root URL - Viewing Self", () => { +QUnit.test("Root URL - Viewing Self", assert => { visit("/u/eviltrout"); andThen(() => { - ok($('body.user-activity-page').length, "has the body class"); - equal(currentPath(), 'user.userActivity.index', "it defaults to activity"); - ok(exists('.container.viewing-self'), "has the viewing-self class"); + assert.ok($('body.user-activity-page').length, "has the body class"); + assert.equal(currentPath(), 'user.userActivity.index', "it defaults to activity"); + assert.ok(exists('.container.viewing-self'), "has the viewing-self class"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/acceptance/users-test.js.es6 b/test/javascripts/acceptance/users-test.js.es6 index eb89741d252..427225a774e 100644 --- a/test/javascripts/acceptance/users-test.js.es6 +++ b/test/javascripts/acceptance/users-test.js.es6 @@ -1,17 +1,17 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("User Directory"); -test("Visit Page", function() { +QUnit.test("Visit Page", assert => { visit("/users"); andThen(() => { - ok($('body.users-page').length, "has the body class"); - ok(exists('.directory table tr'), "has a list of users"); + assert.ok($('body.users-page').length, "has the body class"); + assert.ok(exists('.directory table tr'), "has a list of users"); }); }); -test("Visit All Time", function() { +QUnit.test("Visit All Time", assert => { visit("/users?period=all"); andThen(() => { - ok(exists('.time-read'), "has time read column"); + assert.ok(exists('.time-read'), "has time read column"); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/admin/controllers/admin-customize-themes-test.js.es6 b/test/javascripts/admin/controllers/admin-customize-themes-test.js.es6 index 2c70b5b12fc..41468970937 100644 --- a/test/javascripts/admin/controllers/admin-customize-themes-test.js.es6 +++ b/test/javascripts/admin/controllers/admin-customize-themes-test.js.es6 @@ -2,13 +2,13 @@ import { mapRoutes } from 'discourse/mapping-router'; import Theme from 'admin/models/theme'; moduleFor('controller:admin-customize-themes', { - setup() { + beforeEach() { this.registry.register('router:main', mapRoutes()); }, needs: ['controller:adminUser'] }); -test("can list sorted themes", function() { +QUnit.test("can list sorted themes", function(assert) { const defaultTheme = Theme.create({id: 2, 'default': true, name: 'default'}); const userTheme = Theme.create({id: 3, 'user_selectable': true, name: 'name'}); @@ -23,7 +23,7 @@ test("can list sorted themes", function() { }); - deepEqual(controller.get('sortedThemes').map(t=>t.get('name')), [ + assert.deepEqual(controller.get('sortedThemes').map(t=>t.get('name')), [ defaultTheme, userTheme, strayTheme1, diff --git a/test/javascripts/admin/controllers/admin-user-badges-test.js.es6 b/test/javascripts/admin/controllers/admin-user-badges-test.js.es6 index f58845ecfc0..112ef64d041 100644 --- a/test/javascripts/admin/controllers/admin-user-badges-test.js.es6 +++ b/test/javascripts/admin/controllers/admin-user-badges-test.js.es6 @@ -2,13 +2,13 @@ import Badge from 'discourse/models/badge'; import { mapRoutes } from 'discourse/mapping-router'; moduleFor('controller:admin-user-badges', { - setup() { + beforeEach() { this.registry.register('router:main', mapRoutes()); }, needs: ['controller:adminUser'] }); -test("grantableBadges", function() { +QUnit.test("grantableBadges", function(assert) { const badgeFirst = Badge.create({id: 3, name: "A Badge", enabled: true}); const badgeMiddle = Badge.create({id: 1, name: "My Badge", enabled: true}); const badgeLast = Badge.create({id: 2, name: "Zoo Badge", enabled: true}); @@ -20,6 +20,6 @@ test("grantableBadges", function() { }); - not(badgeNames.includes(badgeDisabled), "excludes disabled badges"); - deepEqual(badgeNames, sortedNames, "sorts badges by name"); + assert.not(badgeNames.includes(badgeDisabled), "excludes disabled badges"); + assert.deepEqual(badgeNames, sortedNames, "sorts badges by name"); }); diff --git a/test/javascripts/admin/models/admin-user-test.js.es6 b/test/javascripts/admin/models/admin-user-test.js.es6 index e735ec9456c..161a8be373b 100644 --- a/test/javascripts/admin/models/admin-user-test.js.es6 +++ b/test/javascripts/admin/models/admin-user-test.js.es6 @@ -1,20 +1,19 @@ -import { blank, present } from 'helpers/qunit-helpers'; import AdminUser from 'admin/models/admin-user'; import ApiKey from 'admin/models/api-key'; -module("model:admin-user"); +QUnit.module("model:admin-user"); -test('generate key', function(assert) { +QUnit.test('generate key', function(assert) { assert.expect(2); var adminUser = AdminUser.create({id: 333}); assert.ok(!adminUser.get('api_key'), 'it has no api key by default'); return adminUser.generateApiKey().then(function() { - present(adminUser.get('api_key'), 'it has an api_key now'); + assert.present(adminUser.get('api_key'), 'it has an api_key now'); }); }); -test('revoke key', function(assert) { +QUnit.test('revoke key', function(assert) { assert.expect(2); var apiKey = ApiKey.create({id: 1234, key: 'asdfasdf'}), @@ -22,6 +21,6 @@ test('revoke key', function(assert) { assert.equal(adminUser.get('api_key'), apiKey, 'it has the api key in the beginning'); return adminUser.revokeApiKey().then(function() { - blank(adminUser.get('api_key'), 'it cleared the api_key'); + assert.blank(adminUser.get('api_key'), 'it cleared the api_key'); }); -}); +}); \ No newline at end of file diff --git a/test/javascripts/admin/models/theme-test.js.es6 b/test/javascripts/admin/models/theme-test.js.es6 index 88d9d62947e..4a16c584c85 100644 --- a/test/javascripts/admin/models/theme-test.js.es6 +++ b/test/javascripts/admin/models/theme-test.js.es6 @@ -1,8 +1,8 @@ import Theme from 'admin/models/theme'; -module("model:theme"); +QUnit.module("model:theme"); -test('can add an upload correctly', function(assert) { +QUnit.test('can add an upload correctly', function(assert) { let theme = Theme.create(); assert.equal(theme.get("uploads.length"), 0, "uploads should be an empty array"); @@ -14,4 +14,4 @@ test('can add an upload correctly', function(assert) { assert.equal(fields[0].type_id, 2, 'expecting type id to be set'); assert.equal(theme.get("uploads.length"), 1, "expecting an upload"); -}); +}); \ No newline at end of file diff --git a/test/javascripts/components/ace-editor-test.js.es6 b/test/javascripts/components/ace-editor-test.js.es6 index 76aa436ff3a..4a05e6f83e2 100644 --- a/test/javascripts/components/ace-editor-test.js.es6 +++ b/test/javascripts/components/ace-editor-test.js.es6 @@ -5,7 +5,7 @@ moduleForComponent('ace-editor', {integration: true}); componentTest('css editor', { template: '{{ace-editor mode="css"}}', test(assert) { - expect(1); + assert.expect(1); assert.ok(this.$('.ace_editor').length, 'it renders the ace editor'); } }); @@ -13,7 +13,7 @@ componentTest('css editor', { componentTest('html editor', { template: '{{ace-editor mode="html" content="wat"}}', test(assert) { - expect(1); + assert.expect(1); assert.ok(this.$('.ace_editor').length, 'it renders the ace editor'); } }); diff --git a/test/javascripts/components/combo-box-test.js.es6 b/test/javascripts/components/combo-box-test.js.es6 index 39232362ffb..285d817e3a7 100644 --- a/test/javascripts/components/combo-box-test.js.es6 +++ b/test/javascripts/components/combo-box-test.js.es6 @@ -3,7 +3,7 @@ moduleForComponent('combo-box', {integration: true}); componentTest('with objects', { template: '{{combo-box content=items value=value}}', - setup() { + beforeEach() { this.set('items', [{id: 1, name: 'hello'}, {id: 2, name: 'world'}]); }, @@ -17,7 +17,7 @@ componentTest('with objects', { componentTest('with objects and valueAttribute', { template: '{{combo-box content=items valueAttribute="value"}}', - setup() { + beforeEach() { this.set('items', [{value: 0, name: 'hello'}, {value: 1, name: 'world'}]); }, @@ -30,7 +30,7 @@ componentTest('with objects and valueAttribute', { componentTest('with an array', { template: '{{combo-box content=items value=value}}', - setup() { + beforeEach() { this.set('items', ['evil', 'trout', 'hat']); }, @@ -44,7 +44,7 @@ componentTest('with an array', { componentTest('with none', { template: '{{combo-box content=items none="test.none" value=value}}', - setup() { + beforeEach() { I18n.translations[I18n.locale].js.test = {none: 'none'}; this.set('items', ['evil', 'trout', 'hat']); }, @@ -59,7 +59,7 @@ componentTest('with none', { componentTest('with Object none', { template: '{{combo-box content=items none=none value=value selected="something"}}', - setup() { + beforeEach() { this.set('none', { id: 'something', name: 'none' }); this.set('items', ['evil', 'trout', 'hat']); }, diff --git a/test/javascripts/components/d-editor-test.js.es6 b/test/javascripts/components/d-editor-test.js.es6 index cddd81828d7..99bf4616ec6 100644 --- a/test/javascripts/components/d-editor-test.js.es6 +++ b/test/javascripts/components/d-editor-test.js.es6 @@ -31,7 +31,7 @@ componentTest('preview sanitizes HTML', { componentTest('updating the value refreshes the preview', { template: '{{d-editor value=value}}', - setup() { + beforeEach() { this.set('value', 'evil trout'); }, @@ -52,7 +52,7 @@ function jumpEnd(textarea) { function testCase(title, testFunc) { componentTest(title, { template: '{{d-editor value=value}}', - setup() { + beforeEach() { this.set('value', 'hello world.'); }, test(assert) { @@ -65,7 +65,7 @@ function testCase(title, testFunc) { function composerTestCase(title, testFunc) { componentTest(title, { template: '{{d-editor value=value composerEvents=true}}', - setup() { + beforeEach() { this.set('value', 'hello world.'); }, test(assert) { @@ -269,7 +269,7 @@ testCase('link modal (link with description)', function(assert) { componentTest('advanced code', { template: '{{d-editor value=value}}', - setup() { + beforeEach() { this.siteSettings.code_formatting_style = '4-spaces-indent'; this.set('value', ` @@ -304,7 +304,7 @@ function xyz(x, y, z) { componentTest('code button', { template: '{{d-editor value=value}}', - setup() { + beforeEach() { this.siteSettings.code_formatting_style = '4-spaces-indent'; }, @@ -406,7 +406,7 @@ third line` componentTest('code fences', { template: '{{d-editor value=value}}', - setup() { + beforeEach() { this.set('value', ''); }, @@ -740,7 +740,7 @@ testCase(`doesn't jump to bottom with long text`, function(assert, textarea) { componentTest('emoji', { template: '{{d-editor value=value}}', - setup() { + beforeEach() { // Test adding a custom button withPluginApi('0.1', api => { api.onToolbarCreate(toolbar => { diff --git a/test/javascripts/components/group-membership-button-test.js.es6 b/test/javascripts/components/group-membership-button-test.js.es6 index 930b7270b4f..9f404c151b5 100644 --- a/test/javascripts/components/group-membership-button-test.js.es6 +++ b/test/javascripts/components/group-membership-button-test.js.es6 @@ -1,48 +1,48 @@ moduleFor('component:group-membership-button'); -test('canJoinGroup', function() { +QUnit.test('canJoinGroup', function(assert) { this.subject().setProperties({ model: { public: false } }); - equal(this.subject().get("canJoinGroup"), false, "non public group cannot be joined"); + assert.equal(this.subject().get("canJoinGroup"), false, "non public group cannot be joined"); this.subject().set("model.public", true); - equal(this.subject().get("canJoinGroup"), true, "public group can be joined"); + assert.equal(this.subject().get("canJoinGroup"), true, "public group can be joined"); this.subject().setProperties({ currentUser: null, model: { public: true } }); - equal(this.subject().get("canJoinGroup"), true, "can't join group when not logged in"); + assert.equal(this.subject().get("canJoinGroup"), true, "can't join group when not logged in"); }); -test('userIsGroupUser', function() { +QUnit.test('userIsGroupUser', function(assert) { this.subject().setProperties({ model: { is_group_user: true } }); - equal(this.subject().get('userIsGroupUser'), true); + assert.equal(this.subject().get('userIsGroupUser'), true); this.subject().set('model.is_group_user', false); - equal(this.subject().get('userIsGroupUser'), false); + assert.equal(this.subject().get('userIsGroupUser'), false); this.subject().setProperties({ model: { id: 1 }, groupUserIds: [1] }); - equal(this.subject().get('userIsGroupUser'), true); + assert.equal(this.subject().get('userIsGroupUser'), true); this.subject().set('groupUserIds', [3]); - equal(this.subject().get('userIsGroupUser'), false); + assert.equal(this.subject().get('userIsGroupUser'), false); this.subject().set('groupUserIds', undefined); - equal(this.subject().get('userIsGroupUser'), false); + assert.equal(this.subject().get('userIsGroupUser'), false); this.subject().setProperties({ groupUserIds: [1, 3], model: { id: 1, is_group_user: false } }); - equal(this.subject().get('userIsGroupUser'), false); + assert.equal(this.subject().get('userIsGroupUser'), false); }); diff --git a/test/javascripts/components/keyboard-shortcuts-test.js.es6 b/test/javascripts/components/keyboard-shortcuts-test.js.es6 index 745a8f3c246..642f35d5432 100644 --- a/test/javascripts/components/keyboard-shortcuts-test.js.es6 +++ b/test/javascripts/components/keyboard-shortcuts-test.js.es6 @@ -3,8 +3,8 @@ import DiscourseURL from 'discourse/lib/url'; var testMouseTrap; import KeyboardShortcuts from 'discourse/lib/keyboard-shortcuts'; -module("lib:keyboard-shortcuts", { - setup: function() { +QUnit.module("lib:keyboard-shortcuts", { + beforeEach() { var _bindings = {}; testMouseTrap = { @@ -62,7 +62,7 @@ module("lib:keyboard-shortcuts", { ].join("\n")); }, - teardown: function() { + afterEach() { $("#qunit-scratch").html(""); } }); @@ -72,11 +72,11 @@ var pathBindings = KeyboardShortcuts.PATH_BINDINGS; _.each(pathBindings, function(path, binding) { var testName = binding + " goes to " + path; - test(testName, function() { + test(testName, function(assert) { KeyboardShortcuts.bindEvents(testMouseTrap); testMouseTrap.trigger(binding); - ok(DiscourseURL.routeTo.calledWith(path)); + assert.ok(DiscourseURL.routeTo.calledWith(path)); }); }); @@ -87,10 +87,10 @@ _.each(clickBindings, function(selector, binding) { var testName = binding + " clicks on " + selector; - test(testName, function() { + test(testName, function(assert) { KeyboardShortcuts.bindEvents(testMouseTrap); $(selector).on("click", function() { - ok(true, selector + " was clicked"); + assert.ok(true, selector + " was clicked"); }); _.each(bindings, function(b) { @@ -104,9 +104,9 @@ var functionBindings = KeyboardShortcuts.FUNCTION_BINDINGS; _.each(functionBindings, function(func, binding) { var testName = binding + " calls " + func; - test(testName, function() { + test(testName, function(assert) { sandbox.stub(KeyboardShortcuts, func, function() { - ok(true, func + " is called when " + binding + " is triggered"); + assert.ok(true, func + " is called when " + binding + " is triggered"); }); KeyboardShortcuts.bindEvents(testMouseTrap); @@ -114,40 +114,40 @@ _.each(functionBindings, function(func, binding) { }); }); -test("selectDown calls _moveSelection with 1", function() { +QUnit.test("selectDown calls _moveSelection with 1", assert => { var spy = sandbox.spy(KeyboardShortcuts, '_moveSelection'); KeyboardShortcuts.selectDown(); - ok(spy.calledWith(1), "_moveSelection is called with 1"); + assert.ok(spy.calledWith(1), "_moveSelection is called with 1"); }); -test("selectUp calls _moveSelection with -1", function() { +QUnit.test("selectUp calls _moveSelection with -1", assert => { var spy = sandbox.spy(KeyboardShortcuts, '_moveSelection'); KeyboardShortcuts.selectUp(); - ok(spy.calledWith(-1), "_moveSelection is called with -1"); + assert.ok(spy.calledWith(-1), "_moveSelection is called with -1"); }); -test("goBack calls history.back", function() { +QUnit.test("goBack calls history.back", assert => { var called = false; sandbox.stub(history, 'back', function() { called = true; }); KeyboardShortcuts.goBack(); - ok(called, "history.back is called"); + assert.ok(called, "history.back is called"); }); -test("nextSection calls _changeSection with 1", function() { +QUnit.test("nextSection calls _changeSection with 1", assert => { var spy = sandbox.spy(KeyboardShortcuts, '_changeSection'); KeyboardShortcuts.nextSection(); - ok(spy.calledWith(1), "_changeSection is called with 1"); + assert.ok(spy.calledWith(1), "_changeSection is called with 1"); }); -test("prevSection calls _changeSection with -1", function() { +QUnit.test("prevSection calls _changeSection with -1", assert => { var spy = sandbox.spy(KeyboardShortcuts, '_changeSection'); KeyboardShortcuts.prevSection(); - ok(spy.calledWith(-1), "_changeSection is called with -1"); + assert.ok(spy.calledWith(-1), "_changeSection is called with -1"); }); diff --git a/test/javascripts/components/text-field-test.js.es6 b/test/javascripts/components/text-field-test.js.es6 index 81b0660052b..e18662c2ab9 100644 --- a/test/javascripts/components/text-field-test.js.es6 +++ b/test/javascripts/components/text-field-test.js.es6 @@ -13,7 +13,7 @@ componentTest("renders correctly with no properties set", { componentTest("support a placeholder", { template: `{{text-field placeholderKey="placeholder.i18n.key"}}`, - setup() { + beforeEach() { sandbox.stub(I18n, "t").returnsArg(0); }, diff --git a/test/javascripts/components/value-list-test.js.es6 b/test/javascripts/components/value-list-test.js.es6 index 7bb9599eece..feefcbea079 100644 --- a/test/javascripts/components/value-list-test.js.es6 +++ b/test/javascripts/components/value-list-test.js.es6 @@ -30,7 +30,7 @@ componentTest('functionality', { componentTest('with string delimited values', { template: '{{value-list values=valueString}}', - setup() { + beforeEach() { this.set('valueString', "hello\nworld"); }, @@ -49,7 +49,7 @@ componentTest('with string delimited values', { componentTest('with array values', { template: '{{value-list values=valueArray inputType="array"}}', - setup() { + beforeEach() { this.set('valueArray', ['abc', 'def']); }, diff --git a/test/javascripts/controllers/admin-group-test.js.es6 b/test/javascripts/controllers/admin-group-test.js.es6 index e80e50d6f3c..c8b747fc5f9 100644 --- a/test/javascripts/controllers/admin-group-test.js.es6 +++ b/test/javascripts/controllers/admin-group-test.js.es6 @@ -1,33 +1,35 @@ -moduleFor("controller:admin-group"); +moduleFor("controller:admin-group", { + needs: ['controller:adminGroupsType'] +}); -test("disablePublicSetting", function() { +QUnit.test("disablePublicSetting", function(assert) { this.subject().setProperties({ model: { visible: false, allow_membership_requests: false } }); - equal(this.subject().get("disablePublicSetting"), true, "it should disable setting"); + assert.equal(this.subject().get("disablePublicSetting"), true, "it should disable setting"); this.subject().set("model.visible", true); - equal(this.subject().get("disablePublicSetting"), false, "it should enable setting"); + assert.equal(this.subject().get("disablePublicSetting"), false, "it should enable setting"); this.subject().set("model.allow_membership_requests", true); - equal(this.subject().get("disablePublicSetting"), true, "it should disable setting"); + assert.equal(this.subject().get("disablePublicSetting"), true, "it should disable setting"); }); -test("disableMembershipRequestSetting", function() { +QUnit.test("disableMembershipRequestSetting", function(assert) { this.subject().setProperties({ model: { visible: false, public: false, canEveryoneMention: true } }); - equal(this.subject().get("disableMembershipRequestSetting"), true, "it should disable setting"); + assert.equal(this.subject().get("disableMembershipRequestSetting"), true, "it should disable setting"); this.subject().set("model.visible", true); - equal(this.subject().get("disableMembershipRequestSetting"), false, "it should enable setting"); + assert.equal(this.subject().get("disableMembershipRequestSetting"), false, "it should enable setting"); this.subject().set("model.public", true); - equal(this.subject().get("disableMembershipRequestSetting"), true, "it should disalbe setting"); + assert.equal(this.subject().get("disableMembershipRequestSetting"), true, "it should disalbe setting"); }); diff --git a/test/javascripts/controllers/avatar-selector-test.js.es6 b/test/javascripts/controllers/avatar-selector-test.js.es6 index 00514303f48..ce26c62163f 100644 --- a/test/javascripts/controllers/avatar-selector-test.js.es6 +++ b/test/javascripts/controllers/avatar-selector-test.js.es6 @@ -1,13 +1,13 @@ import { mapRoutes } from 'discourse/mapping-router'; moduleFor("controller:avatar-selector", "controller:avatar-selector", { - setup() { + beforeEach() { this.registry.register('router:main', mapRoutes()); }, needs: ['controller:modal'] }); -test("avatarTemplate", function() { +QUnit.test("avatarTemplate", function(assert) { const avatarSelectorController = this.subject(); avatarSelectorController.setProperties({ @@ -17,11 +17,11 @@ test("avatarTemplate", function() { custom_avatar_upload_id: 3 }); - equal(avatarSelectorController.get("selectedUploadId"), 1, "we are using system by default"); + assert.equal(avatarSelectorController.get("selectedUploadId"), 1, "we are using system by default"); avatarSelectorController.set('selected', 'gravatar'); - equal(avatarSelectorController.get("selectedUploadId"), 2, "we are using gravatar when set"); + assert.equal(avatarSelectorController.get("selectedUploadId"), 2, "we are using gravatar when set"); avatarSelectorController.set("selected", "custom"); - equal(avatarSelectorController.get("selectedUploadId"), 3, "we are using custom when set"); + assert.equal(avatarSelectorController.get("selectedUploadId"), 3, "we are using custom when set"); }); diff --git a/test/javascripts/controllers/create-account-test.js.es6 b/test/javascripts/controllers/create-account-test.js.es6 index 11a9045a136..f5604d8169b 100644 --- a/test/javascripts/controllers/create-account-test.js.es6 +++ b/test/javascripts/controllers/create-account-test.js.es6 @@ -1,20 +1,20 @@ import { mapRoutes } from 'discourse/mapping-router'; moduleFor("controller:create-account", "controller:create-account", { - setup() { + beforeEach() { this.registry.register('router:main', mapRoutes()); }, needs: ['controller:modal', 'controller:login'] }); -test('basicUsernameValidation', function() { +QUnit.test('basicUsernameValidation', function(assert) { var subject = this.subject; var testInvalidUsername = function(username, expectedReason) { var controller = subject({ siteSettings: Discourse.SiteSettings }); controller.set('accountUsername', username); - equal(controller.get('basicUsernameValidation.failed'), true, 'username should be invalid: ' + username); - equal(controller.get('basicUsernameValidation.reason'), expectedReason, 'username validation reason: ' + username + ', ' + expectedReason); + assert.equal(controller.get('basicUsernameValidation.failed'), true, 'username should be invalid: ' + username); + assert.equal(controller.get('basicUsernameValidation.reason'), expectedReason, 'username validation reason: ' + username + ', ' + expectedReason); }; testInvalidUsername('', undefined); @@ -24,11 +24,11 @@ test('basicUsernameValidation', function() { var controller = subject({ siteSettings: Discourse.SiteSettings }); controller.set('accountUsername', 'porkchops'); controller.set('prefilledUsername', 'porkchops'); - equal(controller.get('basicUsernameValidation.ok'), true, 'Prefilled username is valid'); - equal(controller.get('basicUsernameValidation.reason'), I18n.t('user.username.prefilled'), 'Prefilled username is valid'); + assert.equal(controller.get('basicUsernameValidation.ok'), true, 'Prefilled username is valid'); + assert.equal(controller.get('basicUsernameValidation.reason'), I18n.t('user.username.prefilled'), 'Prefilled username is valid'); }); -test('passwordValidation', function() { +QUnit.test('passwordValidation', function(assert) { var subject = this.subject; var controller = subject({ siteSettings: Discourse.SiteSettings }); @@ -38,14 +38,14 @@ test('passwordValidation', function() { controller.set('prefilledUsername', 'porkchops'); controller.set('accountPassword', 'b4fcdae11f9167'); - equal(controller.get('passwordValidation.ok'), true, 'Password is ok'); - equal(controller.get('passwordValidation.reason'), I18n.t('user.password.ok'), 'Password is valid'); + assert.equal(controller.get('passwordValidation.ok'), true, 'Password is ok'); + assert.equal(controller.get('passwordValidation.reason'), I18n.t('user.password.ok'), 'Password is valid'); var testInvalidPassword = function(password, expectedReason) { var c = subject({ siteSettings: Discourse.SiteSettings }); c.set('accountPassword', password); - equal(c.get('passwordValidation.failed'), true, 'password should be invalid: ' + password); - equal(c.get('passwordValidation.reason'), expectedReason, 'password validation reason: ' + password + ', ' + expectedReason); + assert.equal(c.get('passwordValidation.failed'), true, 'password should be invalid: ' + password); + assert.equal(c.get('passwordValidation.reason'), expectedReason, 'password validation reason: ' + password + ', ' + expectedReason); }; testInvalidPassword('', undefined); diff --git a/test/javascripts/controllers/flag-test.js.es6 b/test/javascripts/controllers/flag-test.js.es6 index 90368082457..0d4b49e16b3 100644 --- a/test/javascripts/controllers/flag-test.js.es6 +++ b/test/javascripts/controllers/flag-test.js.es6 @@ -18,13 +18,13 @@ var buildAdminUser = function(args) { }; moduleFor("controller:flag", "controller:flag", { - setup() { + beforeEach() { this.registry.register('router:main', mapRoutes()); }, needs: ['controller:modal'] }); -test("canDeleteSpammer not staff", function(){ +QUnit.test("canDeleteSpammer not staff", function(assert) { const store = createStore(); var flagController = this.subject({ model: buildPost() }); @@ -32,44 +32,44 @@ test("canDeleteSpammer not staff", function(){ const spamFlag = store.createRecord('post-action-type', {name_key: 'spam'}); flagController.set('selected', spamFlag); - equal(flagController.get('canDeleteSpammer'), false, 'false if current user is not staff'); + assert.equal(flagController.get('canDeleteSpammer'), false, 'false if current user is not staff'); }); -var canDeleteSpammer = function(flagController, postActionType, expected, testName) { +var canDeleteSpammer = function(assert, flagController, postActionType, expected, testName) { const store = createStore(); const flag = store.createRecord('post-action-type', {name_key: postActionType}); flagController.set('selected', flag); - equal(flagController.get('canDeleteSpammer'), expected, testName); + assert.equal(flagController.get('canDeleteSpammer'), expected, testName); }; -test("canDeleteSpammer spam not selected", function(){ +QUnit.test("canDeleteSpammer spam not selected", function(assert) { sandbox.stub(Discourse.User, 'currentProp').withArgs('staff').returns(true); var flagController = this.subject({ model: buildPost() }); flagController.set('userDetails', buildAdminUser({can_delete_all_posts: true, can_be_deleted: true})); - canDeleteSpammer(flagController, 'off_topic', false, 'false if current user is staff, but selected is off_topic'); - canDeleteSpammer(flagController, 'inappropriate', false, 'false if current user is staff, but selected is inappropriate'); - canDeleteSpammer(flagController, 'notify_user', false, 'false if current user is staff, but selected is notify_user'); - canDeleteSpammer(flagController, 'notify_moderators', false, 'false if current user is staff, but selected is notify_moderators'); + canDeleteSpammer(assert, flagController, 'off_topic', false, 'false if current user is staff, but selected is off_topic'); + canDeleteSpammer(assert, flagController, 'inappropriate', false, 'false if current user is staff, but selected is inappropriate'); + canDeleteSpammer(assert, flagController, 'notify_user', false, 'false if current user is staff, but selected is notify_user'); + canDeleteSpammer(assert, flagController, 'notify_moderators', false, 'false if current user is staff, but selected is notify_moderators'); }); -test("canDeleteSpammer spam selected", function(){ +QUnit.test("canDeleteSpammer spam selected", function(assert) { sandbox.stub(Discourse.User, 'currentProp').withArgs('staff').returns(true); var flagController = this.subject({ model: buildPost() }); flagController.set('userDetails', buildAdminUser({can_delete_all_posts: true, can_be_deleted: true})); - canDeleteSpammer(flagController, 'spam', true, 'true if current user is staff, selected is spam, posts and user can be deleted'); + canDeleteSpammer(assert, flagController, 'spam', true, 'true if current user is staff, selected is spam, posts and user can be deleted'); flagController.set('userDetails', buildAdminUser({can_delete_all_posts: false, can_be_deleted: true})); - canDeleteSpammer(flagController, 'spam', false, 'false if current user is staff, selected is spam, posts cannot be deleted'); + canDeleteSpammer(assert, flagController, 'spam', false, 'false if current user is staff, selected is spam, posts cannot be deleted'); flagController.set('userDetails', buildAdminUser({can_delete_all_posts: true, can_be_deleted: false})); - canDeleteSpammer(flagController, 'spam', false, 'false if current user is staff, selected is spam, user cannot be deleted'); + canDeleteSpammer(assert, flagController, 'spam', false, 'false if current user is staff, selected is spam, user cannot be deleted'); flagController.set('userDetails', buildAdminUser({can_delete_all_posts: false, can_be_deleted: false})); - canDeleteSpammer(flagController, 'spam', false, 'false if current user is staff, selected is spam, user cannot be deleted'); + canDeleteSpammer(assert, flagController, 'spam', false, 'false if current user is staff, selected is spam, user cannot be deleted'); }); -test("canSendWarning not staff", function(){ +QUnit.test("canSendWarning not staff", function(assert) { const store = createStore(); var flagController = this.subject({ model: buildPost() }); @@ -77,28 +77,28 @@ test("canSendWarning not staff", function(){ const notifyUserFlag = store.createRecord('post-action-type', {name_key: 'notify_user'}); flagController.set('selected', notifyUserFlag); - equal(flagController.get('canSendWarning'), false, 'false if current user is not staff'); + assert.equal(flagController.get('canSendWarning'), false, 'false if current user is not staff'); }); -var canSendWarning = function(flagController, postActionType, expected, testName) { +var canSendWarning = function(assert, flagController, postActionType, expected, testName) { const store = createStore(); const flag = store.createRecord('post-action-type', {name_key: postActionType}); flagController.set('selected', flag); - equal(flagController.get('canSendWarning'), expected, testName); + assert.equal(flagController.get('canSendWarning'), expected, testName); }; -test("canSendWarning notify_user not selected", function(){ +QUnit.test("canSendWarning notify_user not selected", function(assert) { sandbox.stub(Discourse.User, 'currentProp').withArgs('staff').returns(true); var flagController = this.subject({ model: buildPost() }); - canSendWarning(flagController, 'off_topic', false, 'false if current user is staff, but selected is off_topic'); - canSendWarning(flagController, 'inappropriate', false, 'false if current user is staff, but selected is inappropriate'); - canSendWarning(flagController, 'spam', false, 'false if current user is staff, but selected is spam'); - canSendWarning(flagController, 'notify_moderators', false, 'false if current user is staff, but selected is notify_moderators'); + canSendWarning(assert, flagController, 'off_topic', false, 'false if current user is staff, but selected is off_topic'); + canSendWarning(assert, flagController, 'inappropriate', false, 'false if current user is staff, but selected is inappropriate'); + canSendWarning(assert, flagController, 'spam', false, 'false if current user is staff, but selected is spam'); + canSendWarning(assert, flagController, 'notify_moderators', false, 'false if current user is staff, but selected is notify_moderators'); }); -test("canSendWarning notify_user selected", function(){ +QUnit.test("canSendWarning notify_user selected", function(assert) { sandbox.stub(Discourse.User, 'currentProp').withArgs('staff').returns(true); var flagController = this.subject({ model: buildPost() }); - canSendWarning(flagController, 'notify_user', true, 'true if current user is staff, selected is notify_user'); + canSendWarning(assert, flagController, 'notify_user', true, 'true if current user is staff, selected is notify_user'); }); diff --git a/test/javascripts/controllers/group-test.js.es6 b/test/javascripts/controllers/group-test.js.es6 index 822b14dd424..a5defd2d14a 100644 --- a/test/javascripts/controllers/group-test.js.es6 +++ b/test/javascripts/controllers/group-test.js.es6 @@ -1,19 +1,21 @@ -moduleFor("controller:group"); +moduleFor("controller:group", { + needs: ['controller:application'] +}); -test("canEditGroup", function() { +QUnit.test("canEditGroup", function(assert) { const GroupController = this.subject(); GroupController.setProperties({ model: { is_group_owner: true, automatic: true } }); - equal(GroupController.get("canEditGroup"), false, "automatic groups cannot be edited"); + assert.equal(GroupController.get("canEditGroup"), false, "automatic groups cannot be edited"); GroupController.set("model.automatic", false); - equal(GroupController.get("canEditGroup"), true, "owners can edit groups"); + assert.equal(GroupController.get("canEditGroup"), true, "owners can edit groups"); GroupController.set("model.is_group_owner", false); - equal(GroupController.get("canEditGroup"), false, "normal users cannot edit groups"); + assert.equal(GroupController.get("canEditGroup"), false, "normal users cannot edit groups"); }); diff --git a/test/javascripts/controllers/history-test.js.es6 b/test/javascripts/controllers/history-test.js.es6 index fc8bbe1f5c0..11fe31a27e2 100644 --- a/test/javascripts/controllers/history-test.js.es6 +++ b/test/javascripts/controllers/history-test.js.es6 @@ -1,27 +1,27 @@ moduleFor("controller:history"); -test("displayEdit", function() { +QUnit.test("displayEdit", function(assert) { const HistoryController = this.subject(); HistoryController.setProperties({ model: { last_revision: 3, current_revision: 3, can_edit: false } }); - equal( + assert.equal( HistoryController.get("displayEdit"), false, "it should not display edit button when user cannot edit the post" ); HistoryController.set("model.can_edit", true); - equal( + assert.equal( HistoryController.get("displayEdit"), true, "it should display edit button when user can edit the post" ); HistoryController.set("model.current_revision", 2); - equal( + assert.equal( HistoryController.get("displayEdit"), false, "it should only display the edit button on the latest revision" ); diff --git a/test/javascripts/controllers/topic-test.js.es6 b/test/javascripts/controllers/topic-test.js.es6 index a8e3609e34b..1ae8080bc4e 100644 --- a/test/javascripts/controllers/topic-test.js.es6 +++ b/test/javascripts/controllers/topic-test.js.es6 @@ -1,9 +1,8 @@ -import { blank, present } from 'helpers/qunit-helpers'; import { mapRoutes } from 'discourse/mapping-router'; moduleFor('controller:topic', 'controller:topic', { needs: ['controller:modal', 'controller:composer', 'controller:application'], - setup() { + beforeEach() { this.registry.register('router:main', mapRoutes()); }, }); @@ -23,27 +22,27 @@ var buildTopic = function() { }; -test("editingMode", function() { +QUnit.test("editingMode", function(assert) { var topic = buildTopic(), topicController = this.subject({model: topic}); - ok(!topicController.get('editingTopic'), "we are not editing by default"); + assert.ok(!topicController.get('editingTopic'), "we are not editing by default"); topicController.set('model.details.can_edit', false); topicController.send('editTopic'); - ok(!topicController.get('editingTopic'), "calling editTopic doesn't enable editing unless the user can edit"); + assert.ok(!topicController.get('editingTopic'), "calling editTopic doesn't enable editing unless the user can edit"); topicController.set('model.details.can_edit', true); topicController.send('editTopic'); - ok(topicController.get('editingTopic'), "calling editTopic enables editing if the user can edit"); - equal(topicController.get('buffered.title'), topic.get('title')); - equal(topicController.get('buffered.category_id'), topic.get('category_id')); + assert.ok(topicController.get('editingTopic'), "calling editTopic enables editing if the user can edit"); + assert.equal(topicController.get('buffered.title'), topic.get('title')); + assert.equal(topicController.get('buffered.category_id'), topic.get('category_id')); topicController.send('cancelEditingTopic'); - ok(!topicController.get('editingTopic'), "cancelling edit mode reverts the property value"); + assert.ok(!topicController.get('editingTopic'), "cancelling edit mode reverts the property value"); }); -test("toggledSelectedPost", function() { +QUnit.test("toggledSelectedPost", function(assert) { var tc = this.subject({ model: buildTopic() }), post = Discourse.Post.create({id: 123, post_number: 2}), postStream = tc.get('model.postStream'); @@ -51,38 +50,38 @@ test("toggledSelectedPost", function() { postStream.appendPost(post); postStream.appendPost(Discourse.Post.create({id: 124, post_number: 3})); - blank(tc.get('selectedPosts'), "there are no selected posts by default"); - equal(tc.get('selectedPostsCount'), 0, "there is a selected post count of 0"); - ok(!tc.postSelected(post), "the post is not selected by default"); + assert.blank(tc.get('selectedPosts'), "there are no selected posts by default"); + assert.equal(tc.get('selectedPostsCount'), 0, "there is a selected post count of 0"); + assert.ok(!tc.postSelected(post), "the post is not selected by default"); tc.send('toggledSelectedPost', post); - present(tc.get('selectedPosts'), "there is a selectedPosts collection"); - equal(tc.get('selectedPostsCount'), 1, "there is a selected post now"); - ok(tc.postSelected(post), "the post is now selected"); + assert.present(tc.get('selectedPosts'), "there is a selectedPosts collection"); + assert.equal(tc.get('selectedPostsCount'), 1, "there is a selected post now"); + assert.ok(tc.postSelected(post), "the post is now selected"); tc.send('toggledSelectedPost', post); - ok(!tc.postSelected(post), "the post is no longer selected"); + assert.ok(!tc.postSelected(post), "the post is no longer selected"); }); -test("selectAll", function() { +QUnit.test("selectAll", function(assert) { var tc = this.subject({model: buildTopic(), appEvents: AppEvents.create()}), post = Discourse.Post.create({id: 123, post_number: 2}), postStream = tc.get('model.postStream'); postStream.appendPost(post); - ok(!tc.postSelected(post), "the post is not selected by default"); + assert.ok(!tc.postSelected(post), "the post is not selected by default"); tc.send('selectAll'); - ok(tc.postSelected(post), "the post is now selected"); - ok(tc.get('allPostsSelected'), "all posts are selected"); + assert.ok(tc.postSelected(post), "the post is now selected"); + assert.ok(tc.get('allPostsSelected'), "all posts are selected"); tc.send('deselectAll'); - ok(!tc.postSelected(post), "the post is deselected again"); - ok(!tc.get('allPostsSelected'), "all posts are not selected"); + assert.ok(!tc.postSelected(post), "the post is deselected again"); + assert.ok(!tc.get('allPostsSelected'), "all posts are not selected"); }); -test("Automating setting of allPostsSelected", function() { +QUnit.test("Automating setting of allPostsSelected", function(assert) { var topic = buildTopic(), tc = this.subject({model: topic}), post = Discourse.Post.create({id: 123, post_number: 2}), @@ -90,39 +89,38 @@ test("Automating setting of allPostsSelected", function() { topic.set('posts_count', 1); postStream.appendPost(post); - ok(!tc.get('allPostsSelected'), "all posts are not selected by default"); + assert.ok(!tc.get('allPostsSelected'), "all posts are not selected by default"); tc.send('toggledSelectedPost', post); - ok(tc.get('allPostsSelected'), "all posts are selected if we select the only post"); + assert.ok(tc.get('allPostsSelected'), "all posts are selected if we select the only post"); tc.send('toggledSelectedPost', post); - ok(!tc.get('allPostsSelected'), "the posts are no longer automatically selected"); + assert.ok(!tc.get('allPostsSelected'), "the posts are no longer automatically selected"); }); -test("Select Replies when present", function() { +QUnit.test("Select Replies when present", function(assert) { var topic = buildTopic(), tc = this.subject({ model: topic, appEvents: AppEvents.create() }), p1 = Discourse.Post.create({id: 1, post_number: 1, reply_count: 1}), p2 = Discourse.Post.create({id: 2, post_number: 2}), p3 = Discourse.Post.create({id: 2, post_number: 3, reply_to_post_number: 1}); - ok(!tc.postSelected(p3), "replies are not selected by default"); + assert.ok(!tc.postSelected(p3), "replies are not selected by default"); tc.send('toggledSelectedPostReplies', p1); - ok(tc.postSelected(p1), "it selects the post"); - ok(!tc.postSelected(p2), "it doesn't select a post that's not a reply"); - ok(tc.postSelected(p3), "it selects a post that is a reply"); - equal(tc.get('selectedPostsCount'), 2, "it has a selected posts count of two"); + assert.ok(tc.postSelected(p1), "it selects the post"); + assert.ok(!tc.postSelected(p2), "it doesn't select a post that's not a reply"); + assert.ok(tc.postSelected(p3), "it selects a post that is a reply"); + assert.equal(tc.get('selectedPostsCount'), 2, "it has a selected posts count of two"); // If we deselected the post whose replies are selected... tc.send('toggledSelectedPost', p1); - ok(!tc.postSelected(p1), "it deselects the post"); - ok(!tc.postSelected(p3), "it deselects the replies too"); + assert.ok(!tc.postSelected(p1), "it deselects the post"); + assert.ok(!tc.postSelected(p3), "it deselects the replies too"); // If we deselect a reply, it should deselect the parent's replies selected attribute. Weird but what else would make sense? tc.send('toggledSelectedPostReplies', p1); tc.send('toggledSelectedPost', p3); - ok(tc.postSelected(p1), "the post stays selected"); - ok(!tc.postSelected(p3), "it deselects the replies too"); + assert.ok(tc.postSelected(p1), "the post stays selected"); + assert.ok(!tc.postSelected(p3), "it deselects the replies too"); }); - diff --git a/test/javascripts/ember/resolver-test.js.es6 b/test/javascripts/ember/resolver-test.js.es6 index 648729d6bd3..85424065ecf 100644 --- a/test/javascripts/ember/resolver-test.js.es6 +++ b/test/javascripts/ember/resolver-test.js.es6 @@ -3,10 +3,10 @@ import { setResolverOption, buildResolver } from 'discourse-common/resolver'; let originalTemplates; let resolver; -function lookupTemplate(name, expectedTemplate, message) { +function lookupTemplate(assert, name, expectedTemplate, message) { var parseName = resolver.parseName(name); var result = resolver.resolveTemplate(parseName); - equal(result, expectedTemplate, message); + assert.equal(result, expectedTemplate, message); } function setTemplates(lookupTemplateStrings) { @@ -17,20 +17,20 @@ function setTemplates(lookupTemplateStrings) { const DiscourseResolver = buildResolver('discourse'); -module("lib:resolver", { - setup: function() { +QUnit.module("lib:resolver", { + beforeEach() { originalTemplates = Ember.TEMPLATES; Ember.TEMPLATES = {}; resolver = DiscourseResolver.create(); }, - teardown: function() { + afterEach() { Ember.TEMPLATES = originalTemplates; } }); -test("finds templates in top level dir", function() { +QUnit.test("finds templates in top level dir", assert => { setTemplates([ "foobar", "fooBar", @@ -38,24 +38,24 @@ test("finds templates in top level dir", function() { "foo.bar" ]); - lookupTemplate("template:foobar", "foobar", "by lowcased name"); - lookupTemplate("template:fooBar", "fooBar", "by camel cased name"); - lookupTemplate("template:foo_bar", "foo_bar", "by underscored name"); - lookupTemplate("template:foo.bar", "foo.bar", "by dotted name"); + lookupTemplate(assert, "template:foobar", "foobar", "by lowcased name"); + lookupTemplate(assert, "template:fooBar", "fooBar", "by camel cased name"); + lookupTemplate(assert, "template:foo_bar", "foo_bar", "by underscored name"); + lookupTemplate(assert, "template:foo.bar", "foo.bar", "by dotted name"); }); -test("finds templates in first-level subdir", function() { +QUnit.test("finds templates in first-level subdir", assert => { setTemplates([ "foo/bar_baz" ]); - lookupTemplate("template:foo/bar_baz", "foo/bar_baz", "with subdir defined by slash"); - lookupTemplate("template:foo.bar_baz", "foo/bar_baz", "with subdir defined by dot"); - lookupTemplate("template:fooBarBaz", "foo/bar_baz", "with subdir defined by first camel case and the rest of camel cases converted to underscores"); - lookupTemplate("template:foo_bar_baz", "foo/bar_baz", "with subdir defined by first underscore"); + lookupTemplate(assert, "template:foo/bar_baz", "foo/bar_baz", "with subdir defined by slash"); + lookupTemplate(assert, "template:foo.bar_baz", "foo/bar_baz", "with subdir defined by dot"); + lookupTemplate(assert, "template:fooBarBaz", "foo/bar_baz", "with subdir defined by first camel case and the rest of camel cases converted to underscores"); + lookupTemplate(assert, "template:foo_bar_baz", "foo/bar_baz", "with subdir defined by first underscore"); }); -test("resolves precedence between overlapping top level dir and first level subdir templates", function() { +QUnit.test("resolves precedence between overlapping top level dir and first level subdir templates", assert => { setTemplates([ "fooBar", "foo_bar", @@ -63,28 +63,28 @@ test("resolves precedence between overlapping top level dir and first level subd "foo/bar" ]); - lookupTemplate("template:foo.bar", "foo/bar", "preferring first level subdir for dotted name"); - lookupTemplate("template:fooBar", "fooBar", "preferring top level dir for camel cased name"); - lookupTemplate("template:foo_bar", "foo_bar", "preferring top level dir for underscored name"); + lookupTemplate(assert, "template:foo.bar", "foo/bar", "preferring first level subdir for dotted name"); + lookupTemplate(assert, "template:fooBar", "fooBar", "preferring top level dir for camel cased name"); + lookupTemplate(assert, "template:foo_bar", "foo_bar", "preferring top level dir for underscored name"); }); -test("finds templates in subdir deeper than one level", function() { +QUnit.test("finds templates in subdir deeper than one level", assert => { setTemplates([ "foo/bar/baz/qux" ]); - lookupTemplate("template:foo/bar/baz/qux", "foo/bar/baz/qux", "for subdirs defined by slashes"); - lookupTemplate("template:foo.bar.baz.qux", "foo/bar/baz/qux", "for subdirs defined by dots"); - lookupTemplate("template:foo/bar/bazQux", "foo/bar/baz/qux", "for subdirs defined by slashes plus one camel case"); - lookupTemplate("template:foo/bar/baz_qux", "foo/bar/baz/qux", "for subdirs defined by slashes plus one underscore"); + lookupTemplate(assert, "template:foo/bar/baz/qux", "foo/bar/baz/qux", "for subdirs defined by slashes"); + lookupTemplate(assert, "template:foo.bar.baz.qux", "foo/bar/baz/qux", "for subdirs defined by dots"); + lookupTemplate(assert, "template:foo/bar/bazQux", "foo/bar/baz/qux", "for subdirs defined by slashes plus one camel case"); + lookupTemplate(assert, "template:foo/bar/baz_qux", "foo/bar/baz/qux", "for subdirs defined by slashes plus one underscore"); - lookupTemplate("template:fooBarBazQux", undefined, "but not for subdirs defined by more than one camel case"); - lookupTemplate("template:foo_bar_baz_qux", undefined, "but not for subdirs defined by more than one underscore"); - lookupTemplate("template:foo.bar.bazQux", undefined, "but not for subdirs defined by dots plus one camel case"); - lookupTemplate("template:foo.bar.baz_qux", undefined, "but not for subdirs defined by dots plus one underscore"); + lookupTemplate(assert, "template:fooBarBazQux", undefined, "but not for subdirs defined by more than one camel case"); + lookupTemplate(assert, "template:foo_bar_baz_qux", undefined, "but not for subdirs defined by more than one underscore"); + lookupTemplate(assert, "template:foo.bar.bazQux", undefined, "but not for subdirs defined by dots plus one camel case"); + lookupTemplate(assert, "template:foo.bar.baz_qux", undefined, "but not for subdirs defined by dots plus one underscore"); }); -test("resolves mobile templates to 'mobile/' namespace", function() { +QUnit.test("resolves mobile templates to 'mobile/' namespace", assert => { setTemplates([ "mobile/foo", "bar", @@ -94,12 +94,12 @@ test("resolves mobile templates to 'mobile/' namespace", function() { setResolverOption('mobileView', true); - lookupTemplate("template:foo", "mobile/foo", "finding mobile version even if normal one is not present"); - lookupTemplate("template:bar", "mobile/bar", "preferring mobile version when both mobile and normal versions are present"); - lookupTemplate("template:baz", "baz", "falling back to a normal version when mobile version is not present"); + lookupTemplate(assert, "template:foo", "mobile/foo", "finding mobile version even if normal one is not present"); + lookupTemplate(assert, "template:bar", "mobile/bar", "preferring mobile version when both mobile and normal versions are present"); + lookupTemplate(assert, "template:baz", "baz", "falling back to a normal version when mobile version is not present"); }); -test("resolves plugin templates to 'javascripts/' namespace", function() { +QUnit.test("resolves plugin templates to 'javascripts/' namespace", assert => { setTemplates([ "javascripts/foo", "bar", @@ -107,12 +107,12 @@ test("resolves plugin templates to 'javascripts/' namespace", function() { "baz" ]); - lookupTemplate("template:foo", "javascripts/foo", "finding plugin version even if normal one is not present"); - lookupTemplate("template:bar", "javascripts/bar", "preferring plugin version when both versions are present"); - lookupTemplate("template:baz", "baz", "falling back to a normal version when plugin version is not present"); + lookupTemplate(assert, "template:foo", "javascripts/foo", "finding plugin version even if normal one is not present"); + lookupTemplate(assert, "template:bar", "javascripts/bar", "preferring plugin version when both versions are present"); + lookupTemplate(assert, "template:baz", "baz", "falling back to a normal version when plugin version is not present"); }); -test("resolves templates with 'admin' prefix to 'admin/templates/' namespace", function() { +QUnit.test("resolves templates with 'admin' prefix to 'admin/templates/' namespace", assert => { setTemplates([ "admin/templates/foo", "adminBar", @@ -121,20 +121,20 @@ test("resolves templates with 'admin' prefix to 'admin/templates/' namespace", f "admin/templates/bar" ]); - lookupTemplate("template:adminFoo", "admin/templates/foo", "when prefix is separated by camel case"); - lookupTemplate("template:admin_foo", "admin/templates/foo", "when prefix is separated by underscore"); - lookupTemplate("template:admin.foo", "admin/templates/foo", "when prefix is separated by dot"); + lookupTemplate(assert, "template:adminFoo", "admin/templates/foo", "when prefix is separated by camel case"); + lookupTemplate(assert, "template:admin_foo", "admin/templates/foo", "when prefix is separated by underscore"); + lookupTemplate(assert, "template:admin.foo", "admin/templates/foo", "when prefix is separated by dot"); - lookupTemplate("template:adminfoo", undefined, "but not when prefix is not separated in any way"); - lookupTemplate("template:adminBar", "adminBar", "but not when template with the exact camel cased name exists"); - lookupTemplate("template:admin_bar", "admin_bar", "but not when template with the exact underscored name exists"); - lookupTemplate("template:admin.bar", "admin.bar", "but not when template with the exact dotted name exists"); + lookupTemplate(assert, "template:adminfoo", undefined, "but not when prefix is not separated in any way"); + lookupTemplate(assert, "template:adminBar", "adminBar", "but not when template with the exact camel cased name exists"); + lookupTemplate(assert, "template:admin_bar", "admin_bar", "but not when template with the exact underscored name exists"); + lookupTemplate(assert, "template:admin.bar", "admin.bar", "but not when template with the exact dotted name exists"); }); -test("returns 'not_found' template when template name cannot be resolved", function() { +QUnit.test("returns 'not_found' template when template name cannot be resolved", assert => { setTemplates([ "not_found" ]); - lookupTemplate("template:foo/bar/baz", "not_found", ""); + lookupTemplate(assert, "template:foo/bar/baz", "not_found", ""); }); diff --git a/test/javascripts/helpers/assertions.js b/test/javascripts/helpers/assertions.js index 66b6fc8f846..4e6b53b5d16 100644 --- a/test/javascripts/helpers/assertions.js +++ b/test/javascripts/helpers/assertions.js @@ -8,14 +8,6 @@ function count(selector) { return find(selector).length; } -function containsInstance(collection, klass, text) { - ok(klass.detectInstance(_.first(collection)), text); -} - -function not(state, message) { - ok(!state, message); -} - function visible(selector) { return find(selector + ":visible").length > 0; } diff --git a/test/javascripts/helpers/component-test.js.es6 b/test/javascripts/helpers/component-test.js.es6 index 341c106b33a..4154a461219 100644 --- a/test/javascripts/helpers/component-test.js.es6 +++ b/test/javascripts/helpers/component-test.js.es6 @@ -35,8 +35,8 @@ export default function(name, opts) { this.registry.register('store:main', store, { instantiate: false }); - if (opts.setup) { - opts.setup.call(this, store); + if (opts.beforeEach) { + opts.beforeEach.call(this, store); } andThen(() => { diff --git a/test/javascripts/helpers/create-pretender.js.es6 b/test/javascripts/helpers/create-pretender.js.es6 index 85d171a37f0..bfa32ba4af4 100644 --- a/test/javascripts/helpers/create-pretender.js.es6 +++ b/test/javascripts/helpers/create-pretender.js.es6 @@ -379,4 +379,4 @@ export default function() { server.checkPassthrough = request => request.requestHeaders['Discourse-Script']; return server; -} +} \ No newline at end of file diff --git a/test/javascripts/helpers/create-store.js.es6 b/test/javascripts/helpers/create-store.js.es6 index 9ad8d169c51..a1ab5351a81 100644 --- a/test/javascripts/helpers/create-store.js.es6 +++ b/test/javascripts/helpers/create-store.js.es6 @@ -11,8 +11,11 @@ export default function() { register: { lookup(type) { if (type === "adapter:rest") { - this._restAdapter = this._restAdapter || RestAdapter.create({ container: this }); - return (this._restAdapter); + if (!this._restAdapter) { + this._restAdapter = RestAdapter.create({ owner: this }); + // this._restAdapter.container = this; + } + return this._restAdapter; } if (type === "key-value-store:main") { this._kvs = this._kvs || new KeyValueStore(); @@ -34,5 +37,4 @@ export default function() { }, } }); -} - +} \ No newline at end of file diff --git a/test/javascripts/helpers/parse-html.js.es6 b/test/javascripts/helpers/parse-html.js.es6 index c9469fa6b9f..0d3bab90d56 100644 --- a/test/javascripts/helpers/parse-html.js.es6 +++ b/test/javascripts/helpers/parse-html.js.es6 @@ -5,4 +5,4 @@ export default function parseHTML(rawHtml) { parser.parseComplete(rawHtml); return builder.dom; -} +} \ No newline at end of file diff --git a/test/javascripts/helpers/qunit-helpers.js.es6 b/test/javascripts/helpers/qunit-helpers.js.es6 index bb296f0d776..2640e806b34 100644 --- a/test/javascripts/helpers/qunit-helpers.js.es6 +++ b/test/javascripts/helpers/qunit-helpers.js.es6 @@ -1,4 +1,4 @@ -/* global asyncTest, fixtures */ +/* global QUnit, fixtures */ import sessionFixtures from 'fixtures/session-fixtures'; import siteFixtures from 'fixtures/site-fixtures'; @@ -41,7 +41,7 @@ $.fn.modal = AcceptanceModal; function acceptance(name, options) { module("Acceptance: " + name, { - setup() { + beforeEach() { resetMobile(); // For now don't do scrolling stuff in Test Mode @@ -50,8 +50,8 @@ function acceptance(name, options) { resetExtraClasses(); const siteJson = siteFixtures['site.json'].site; if (options) { - if (options.setup) { - options.setup.call(this); + if (options.beforeEach) { + options.beforeEach.call(this); } if (options.mobileView) { @@ -77,9 +77,9 @@ function acceptance(name, options) { Discourse.reset(); }, - teardown() { - if (options && options.teardown) { - options.teardown.call(this); + afterEach() { + if (options && options.afterEach) { + options.afterEach.call(this); } flushMap(); Discourse.User.resetCurrent(); @@ -102,10 +102,11 @@ function controllerFor(controller, model) { } function asyncTestDiscourse(text, func) { - asyncTest(text, function () { - var self = this; - Ember.run(function () { - func.call(self); + QUnit.test(text, function(assert) { + const done = assert.async(); + Ember.run(() => { + func.call(this, assert); + done(); }); }); } @@ -117,20 +118,46 @@ function fixture(selector) { return $("#qunit-fixture"); } -function present(obj, text) { - ok(!Ember.isEmpty(obj), text); -} +QUnit.assert.not = function(actual, message) { + this.pushResult({ + result: !actual, + actual, + expected: !actual, + message + }); +}; -function blank(obj, text) { - ok(Ember.isEmpty(obj), text); -} +QUnit.assert.blank = function(actual, message) { + this.pushResult({ + result: Ember.isEmpty(actual), + actual, + message + }); +}; -function waitFor(callback, timeout) { +QUnit.assert.present = function(actual, message) { + this.pushResult({ + result: !Ember.isEmpty(actual), + actual, + message + }); +}; + +QUnit.assert.containsInstance = function(collection, klass, message) { + const result = klass.detectInstance(_.first(collection)); + this.pushResult({ + result, + message + }); +}; + +function waitFor(assert, callback, timeout) { timeout = timeout || 500; - stop(); + + const done = assert.async(); Ember.run.later(() => { callback(); - start(); + done(); }, timeout); } @@ -140,6 +167,4 @@ export { acceptance, fixture, logIn, currentUser, - blank, - present, waitFor }; diff --git a/test/javascripts/helpers/site.js.es6 b/test/javascripts/helpers/site.js.es6 index d8ab85a4861..a477be1859c 100644 --- a/test/javascripts/helpers/site.js.es6 +++ b/test/javascripts/helpers/site.js.es6 @@ -1,4 +1,4 @@ import PreloadStore from 'preload-store'; /*jshint maxlen:10000000 */ -PreloadStore.store("site",{"default_archetype":"regular","notification_types":{"mentioned":1,"replied":2,"quoted":3,"edited":4,"liked":5,"private_message":6,"invited_to_private_message":7,"invitee_accepted":8,"posted":9,"moved_post":10},"post_types":{"regular":1,"moderator_action":2},"groups":[{"id":0,"name":"everyone"},{"id":1,"name":"admins"},{"id":2,"name":"moderators"},{"id":3,"name":"staff"},{"id":10,"name":"trust_level_0"},{"id":11,"name":"trust_level_1"},{"id":12,"name":"trust_level_2"},{"id":13,"name":"trust_level_3"},{"id":14,"name":"trust_level_4"},{"id":20,"name":"ubuntu"},{"id":21,"name":"test"}],"filters":["latest","unread","new","starred","read","posted"],"periods":["yearly","monthly","weekly","daily"],"top_menu_items":["latest","unread","new","starred","read","posted","category","categories","top"],"anonymous_top_menu_items":["latest","category","categories","top"],"uncategorized_category_id":17,"categories":[{"id":5,"name":"extensibility","color":"FE8432","text_color":"FFFFFF","slug":"extensibility","topic_count":102,"description":"Topics about extending the functionality of Discourse with plugins, themes, add-ons, or other mechanisms for extensibility. ","topic_url":"/t/category-definition-for-extensibility/28","hotness":5.0,"read_restricted":false,"permission":null},{"id":7,"name":"dev","color":"000","text_color":"FFFFFF","slug":"dev","topic_count":284,"description":"This category is for topics related to hacking on Discourse: submitting pull requests, configuring development environments, coding conventions, and so forth.","topic_url":"/t/category-definition-for-dev/1026","hotness":5.0,"read_restricted":false,"permission":null},{"id":1,"name":"bug","color":"e9dd00","text_color":"000000","slug":"bug","topic_count":660,"description":"Bug reports on Discourse. Do be sure to search prior to submitting bugs. Include repro steps, and only describe one bug per topic please.","topic_url":"/t/category-definition-for-bug/2","hotness":5.0,"read_restricted":false,"permission":null},{"id":8,"name":"hosting","color":"74CCED","text_color":"FFFFFF","slug":"hosting","topic_count":69,"description":"Topics about hosting Discourse, either on your own servers, in the cloud, or with specific hosting services.","topic_url":"/t/category-definition-for-hosting/2626","hotness":5.0,"read_restricted":false,"permission":null},{"id":6,"name":"support","color":"b99","text_color":"FFFFFF","slug":"support","topic_count":782,"description":"Support on configuring, using, and installing Discourse. Not for software development related topics, but for admins and end users configuring and using Discourse.","topic_url":"/t/category-definition-for-support/389","hotness":5.0,"read_restricted":false,"permission":null},{"id":2,"name":"feature","color":"0E76BD","text_color":"FFFFFF","slug":"feature","topic_count":727,"description":"Discussion about features or potential features of Discourse: how they work, why they work, etc.","topic_url":"/t/category-definition-for-feature/11","hotness":5.0,"read_restricted":false,"permission":null},{"id":13,"name":"blog","color":"ED207B","text_color":"FFFFFF","slug":"blog","topic_count":14,"description":"Discussion topics generated from the official Discourse Blog. These topics are linked from the bottom of each blog entry where the blog comments would normally be.","topic_url":"/t/category-definition-for-blog/5250","hotness":5.0,"read_restricted":false,"permission":null},{"id":12,"name":"discourse hub","color":"b2c79f","text_color":"FFFFFF","slug":"discourse-hub","topic_count":4,"description":"Topics about current or future Discourse Hub functionality at discourse.org including nickname registration, global user pages, and the site directory.","topic_url":"/t/category-definition-for-discourse-hub/3038","hotness":5.0,"read_restricted":false,"permission":null},{"id":11,"name":"login","color":"edb400","text_color":"FFFFFF","slug":"login","topic_count":27,"description":"Topics about logging in to Discourse, using any standard third party provider (Twitter, Facebook, Google), traditional username and password, or with a custom plugin.","topic_url":"/t/category-definition-for-login/2828","hotness":5.0,"read_restricted":false,"permission":null},{"id":3,"name":"meta","color":"aaa","text_color":"FFFFFF","slug":"meta","topic_count":79,"description":"Discussion about meta.discourse.org itself, the organization of this forum about Discourse, how it works, and how we can improve this site.","topic_url":"/t/category-definition-for-meta/24","hotness":5.0,"read_restricted":false,"permission":null},{"id":10,"name":"howto","color":"76923C","text_color":"FFFFFF","slug":"howto","topic_count":58,"description":"Tutorial topics that describe how to set up, configure, or install Discourse using a specific platform or environment. Topics in this category may only be created by trust level 2 and up. ","topic_url":"/t/category-definition-for-howto/2629","hotness":5.0,"read_restricted":false,"permission":null},{"id":14,"name":"marketplace","color":"8C6238","text_color":"FFFFFF","slug":"marketplace","topic_count":24,"description":"About commercial Discourse related stuff: jobs or paid gigs, plugins, themes, hosting, etc.","topic_url":"/t/category-definition-for-marketplace/5425","hotness":5.0,"read_restricted":false,"permission":null},{"id":17,"name":"uncategorized","color":"AB9364","text_color":"FFFFFF","slug":"uncategorized","topic_count":229,"description":"","topic_url":null,"hotness":5.0,"read_restricted":false,"permission":null},{"id":9,"name":"ux","color":"5F497A","text_color":"FFFFFF","slug":"ux","topic_count":184,"description":"Discussion about the user interface of Discourse, how features are presented to the user in the client, including language and UI elements.","topic_url":"/t/category-definition-for-ux/2628","hotness":5.0,"read_restricted":false,"permission":null},{"id":4,"name":"faq","color":"33b","text_color":"FFFFFF","slug":"faq","topic_count":49,"description":"Topics that come up very often when discussing Discourse will eventually be classified into this Frequently Asked Questions category. Should only be added to popular topics.","topic_url":"/t/category-definition-for-faq/25","hotness":5.0,"read_restricted":false,"permission":null}],"post_action_types":[{"name_key":"bookmark","name":"Bookmark","description":"Bookmark this post","long_form":"bookmarked this post","is_flag":false,"icon":null,"id":1,"is_custom_flag":false},{"name_key":"like","name":"Like","description":"Like this post","long_form":"liked this","is_flag":false,"icon":"heart","id":2,"is_custom_flag":false},{"name_key":"off_topic","name":"Off-Topic","description":"This post is radically off-topic in the current conversation, and should probably be moved to a different topic. If this is a topic, perhaps it does not belong here.","long_form":"flagged this as off-topic","is_flag":true,"icon":null,"id":3,"is_custom_flag":false},{"name_key":"inappropriate","name":"Inappropriate","description":"This post contains content that a reasonable person would consider offensive, abusive, or a violation of our community guidelines<\/a>.","long_form":"flagged this as inappropriate","is_flag":true,"icon":null,"id":4,"is_custom_flag":false},{"name_key":"vote","name":"Vote","description":"Vote for this post","long_form":"voted for this post","is_flag":false,"icon":null,"id":5,"is_custom_flag":false},{"name_key":"spam","name":"Spam","description":"This post is an advertisement. It is not useful or relevant to the current conversation, but promotional in nature.","long_form":"flagged this as spam","is_flag":true,"icon":null,"id":8,"is_custom_flag":false},{"name_key":"notify_user","name":"Notify {{username}}","description":"This post contains something I want to talk to this person directly and privately about.","long_form":"notified user","is_flag":true,"icon":null,"id":6,"is_custom_flag":true},{"name_key":"notify_moderators","name":"Notify moderators","description":"This post requires general moderator attention based on the FAQ<\/a>, TOS<\/a>, or for another reason not listed above.","long_form":"notified moderators","is_flag":true,"icon":null,"id":7,"is_custom_flag":true}],"trust_levels":[{"id":0,"name":"new user"},{"id":1,"name":"basic user"},{"id":2,"name":"member"},{"id":3,"name":"regular"},{"id":4,"name":"leader"}],"archetypes":[{"id":"regular","name":"Regular Topic","options":[]}]}); +PreloadStore.store("site",{"default_archetype":"regular","notification_types":{"mentioned":1,"replied":2,"quoted":3,"edited":4,"liked":5,"private_message":6,"invited_to_private_message":7,"invitee_accepted":8,"posted":9,"moved_post":10},"post_types":{"regular":1,"moderator_action":2},"groups":[{"id":0,"name":"everyone"},{"id":1,"name":"admins"},{"id":2,"name":"moderators"},{"id":3,"name":"staff"},{"id":10,"name":"trust_level_0"},{"id":11,"name":"trust_level_1"},{"id":12,"name":"trust_level_2"},{"id":13,"name":"trust_level_3"},{"id":14,"name":"trust_level_4"},{"id":20,"name":"ubuntu"},{"id":21,"name":"test"}],"filters":["latest","unread","new","starred","read","posted"],"periods":["yearly","monthly","weekly","daily"],"top_menu_items":["latest","unread","new","starred","read","posted","category","categories","top"],"anonymous_top_menu_items":["latest","category","categories","top"],"uncategorized_category_id":17,"categories":[{"id":5,"name":"extensibility","color":"FE8432","text_color":"FFFFFF","slug":"extensibility","topic_count":102,"description":"Topics about extending the functionality of Discourse with plugins, themes, add-ons, or other mechanisms for extensibility. ","topic_url":"/t/category-definition-for-extensibility/28","hotness":5.0,"read_restricted":false,"permission":null},{"id":7,"name":"dev","color":"000","text_color":"FFFFFF","slug":"dev","topic_count":284,"description":"This category is for topics related to hacking on Discourse: submitting pull requests, configuring development environments, coding conventions, and so forth.","topic_url":"/t/category-definition-for-dev/1026","hotness":5.0,"read_restricted":false,"permission":null},{"id":1,"name":"bug","color":"e9dd00","text_color":"000000","slug":"bug","topic_count":660,"description":"Bug reports on Discourse. Do be sure to search prior to submitting bugs. Include repro steps, and only describe one bug per topic please.","topic_url":"/t/category-definition-for-bug/2","hotness":5.0,"read_restricted":false,"permission":null},{"id":8,"name":"hosting","color":"74CCED","text_color":"FFFFFF","slug":"hosting","topic_count":69,"description":"Topics about hosting Discourse, either on your own servers, in the cloud, or with specific hosting services.","topic_url":"/t/category-definition-for-hosting/2626","hotness":5.0,"read_restricted":false,"permission":null},{"id":6,"name":"support","color":"b99","text_color":"FFFFFF","slug":"support","topic_count":782,"description":"Support on configuring, using, and installing Discourse. Not for software development related topics, but for admins and end users configuring and using Discourse.","topic_url":"/t/category-definition-for-support/389","hotness":5.0,"read_restricted":false,"permission":null},{"id":2,"name":"feature","color":"0E76BD","text_color":"FFFFFF","slug":"feature","topic_count":727,"description":"Discussion about features or potential features of Discourse: how they work, why they work, etc.","topic_url":"/t/category-definition-for-feature/11","hotness":5.0,"read_restricted":false,"permission":null},{"id":13,"name":"blog","color":"ED207B","text_color":"FFFFFF","slug":"blog","topic_count":14,"description":"Discussion topics generated from the official Discourse Blog. These topics are linked from the bottom of each blog entry where the blog comments would normally be.","topic_url":"/t/category-definition-for-blog/5250","hotness":5.0,"read_restricted":false,"permission":null},{"id":12,"name":"discourse hub","color":"b2c79f","text_color":"FFFFFF","slug":"discourse-hub","topic_count":4,"description":"Topics about current or future Discourse Hub functionality at discourse.org including nickname registration, global user pages, and the site directory.","topic_url":"/t/category-definition-for-discourse-hub/3038","hotness":5.0,"read_restricted":false,"permission":null},{"id":11,"name":"login","color":"edb400","text_color":"FFFFFF","slug":"login","topic_count":27,"description":"Topics about logging in to Discourse, using any standard third party provider (Twitter, Facebook, Google), traditional username and password, or with a custom plugin.","topic_url":"/t/category-definition-for-login/2828","hotness":5.0,"read_restricted":false,"permission":null},{"id":3,"name":"meta","color":"aaa","text_color":"FFFFFF","slug":"meta","topic_count":79,"description":"Discussion about meta.discourse.org itself, the organization of this forum about Discourse, how it works, and how we can improve this site.","topic_url":"/t/category-definition-for-meta/24","hotness":5.0,"read_restricted":false,"permission":null},{"id":10,"name":"howto","color":"76923C","text_color":"FFFFFF","slug":"howto","topic_count":58,"description":"Tutorial topics that describe how to set up, configure, or install Discourse using a specific platform or environment. Topics in this category may only be created by trust level 2 and up. ","topic_url":"/t/category-definition-for-howto/2629","hotness":5.0,"read_restricted":false,"permission":null},{"id":14,"name":"marketplace","color":"8C6238","text_color":"FFFFFF","slug":"marketplace","topic_count":24,"description":"About commercial Discourse related stuff: jobs or paid gigs, plugins, themes, hosting, etc.","topic_url":"/t/category-definition-for-marketplace/5425","hotness":5.0,"read_restricted":false,"permission":null},{"id":17,"name":"uncategorized","color":"AB9364","text_color":"FFFFFF","slug":"uncategorized","topic_count":229,"description":"","topic_url":null,"hotness":5.0,"read_restricted":false,"permission":null},{"id":9,"name":"ux","color":"5F497A","text_color":"FFFFFF","slug":"ux","topic_count":184,"description":"Discussion about the user interface of Discourse, how features are presented to the user in the client, including language and UI elements.","topic_url":"/t/category-definition-for-ux/2628","hotness":5.0,"read_restricted":false,"permission":null},{"id":4,"name":"faq","color":"33b","text_color":"FFFFFF","slug":"faq","topic_count":49,"description":"Topics that come up very often when discussing Discourse will eventually be classified into this Frequently Asked Questions category. Should only be added to popular topics.","topic_url":"/t/category-definition-for-faq/25","hotness":5.0,"read_restricted":false,"permission":null}],"post_action_types":[{"name_key":"bookmark","name":"Bookmark","description":"Bookmark this post","long_form":"bookmarked this post","is_flag":false,"icon":null,"id":1,"is_custom_flag":false},{"name_key":"like","name":"Like","description":"Like this post","long_form":"liked this","is_flag":false,"icon":"heart","id":2,"is_custom_flag":false},{"name_key":"off_topic","name":"Off-Topic","description":"This post is radically off-topic in the current conversation, and should probably be moved to a different topic. If this is a topic, perhaps it does not belong here.","long_form":"flagged this as off-topic","is_flag":true,"icon":null,"id":3,"is_custom_flag":false},{"name_key":"inappropriate","name":"Inappropriate","description":"This post contains content that a reasonable person would consider offensive, abusive, or a violation of our community guidelines<\/a>.","long_form":"flagged this as inappropriate","is_flag":true,"icon":null,"id":4,"is_custom_flag":false},{"name_key":"vote","name":"Vote","description":"Vote for this post","long_form":"voted for this post","is_flag":false,"icon":null,"id":5,"is_custom_flag":false},{"name_key":"spam","name":"Spam","description":"This post is an advertisement. It is not useful or relevant to the current conversation, but promotional in nature.","long_form":"flagged this as spam","is_flag":true,"icon":null,"id":8,"is_custom_flag":false},{"name_key":"notify_user","name":"Notify {{username}}","description":"This post contains something I want to talk to this person directly and privately about.","long_form":"notified user","is_flag":true,"icon":null,"id":6,"is_custom_flag":true},{"name_key":"notify_moderators","name":"Notify moderators","description":"This post requires general moderator attention based on the FAQ<\/a>, TOS<\/a>, or for another reason not listed above.","long_form":"notified moderators","is_flag":true,"icon":null,"id":7,"is_custom_flag":true}],"trust_levels":[{"id":0,"name":"new user"},{"id":1,"name":"basic user"},{"id":2,"name":"member"},{"id":3,"name":"regular"},{"id":4,"name":"leader"}],"archetypes":[{"id":"regular","name":"Regular Topic","options":[]}]}); \ No newline at end of file diff --git a/test/javascripts/helpers/store-pretender.js.es6 b/test/javascripts/helpers/store-pretender.js.es6 index de7ff6b27c8..c47dec3ab93 100644 --- a/test/javascripts/helpers/store-pretender.js.es6 +++ b/test/javascripts/helpers/store-pretender.js.es6 @@ -76,4 +76,4 @@ export default function(helpers) { }); this.delete('/widgets/:widget_id', success); -}; +}; \ No newline at end of file diff --git a/test/javascripts/helpers/widget-test.js.es6 b/test/javascripts/helpers/widget-test.js.es6 index d30170ff1db..15e43cbe32e 100644 --- a/test/javascripts/helpers/widget-test.js.es6 +++ b/test/javascripts/helpers/widget-test.js.es6 @@ -6,4 +6,4 @@ export function moduleForWidget(name) { export function widgetTest(name, opts) { return componentTest(name, opts); -} +} \ No newline at end of file diff --git a/test/javascripts/initializers/localization-test.js.es6 b/test/javascripts/initializers/localization-test.js.es6 index 4f6e0670e52..45f60724a52 100644 --- a/test/javascripts/initializers/localization-test.js.es6 +++ b/test/javascripts/initializers/localization-test.js.es6 @@ -1,11 +1,11 @@ import PreloadStore from 'preload-store'; import LocalizationInitializer from 'discourse/initializers/localization'; -module("initializer:localization", { +QUnit.module("initializer:localization", { _locale: I18n.locale, _translations: I18n.translations, - setup() { + beforeEach() { I18n.locale = "fr"; I18n.translations = { @@ -28,16 +28,16 @@ module("initializer:localization", { }; }, - teardown() { + afterEach() { I18n.locale = this._locale; I18n.translations = this._translations; } }); -test("translation overrides", function() { +QUnit.test("translation overrides", assert => { PreloadStore.store('translationOverrides', {"js.composer.reply":"WAT","js.topic.reply.help":"foobar"}); LocalizationInitializer.initialize(this.registry); - equal(I18n.t("composer.reply"), "WAT", "overrides existing translation in current locale"); - equal(I18n.t("topic.reply.help"), "foobar", "overrides translation in default locale"); -}); + assert.equal(I18n.t("composer.reply"), "WAT", "overrides existing translation in current locale"); + assert.equal(I18n.t("topic.reply.help"), "foobar", "overrides translation in default locale"); +}); \ No newline at end of file diff --git a/test/javascripts/lib/category-badge-test.js.es6 b/test/javascripts/lib/category-badge-test.js.es6 index 385d478c6ad..ffd837a5e61 100644 --- a/test/javascripts/lib/category-badge-test.js.es6 +++ b/test/javascripts/lib/category-badge-test.js.es6 @@ -1,16 +1,15 @@ import createStore from 'helpers/create-store'; -import { blank, present } from 'helpers/qunit-helpers'; -module("lib:category-link"); +QUnit.module("lib:category-link"); import parseHTML from 'helpers/parse-html'; import { categoryBadgeHTML } from "discourse/helpers/category-link"; -test("categoryBadge without a category", function() { - blank(categoryBadgeHTML(), "it returns no HTML"); +QUnit.test("categoryBadge without a category", assert => { + assert.blank(categoryBadgeHTML(), "it returns no HTML"); }); -test("Regular categoryBadge", function() { +QUnit.test("Regular categoryBadge", assert => { const store = createStore(); const category = store.createRecord('category', { name: 'hello', @@ -21,28 +20,28 @@ test("Regular categoryBadge", function() { }); const tag = parseHTML(categoryBadgeHTML(category))[0]; - equal(tag.name, 'a', 'it creates a `a` wrapper tag'); - equal(tag.attributes['class'].trim(), 'badge-wrapper', 'it has the correct class'); + assert.equal(tag.name, 'a', 'it creates a `a` wrapper tag'); + assert.equal(tag.attributes['class'].trim(), 'badge-wrapper', 'it has the correct class'); const label = tag.children[1]; - equal(label.attributes.title, 'cool description', 'it has the correct title'); + assert.equal(label.attributes.title, 'cool description', 'it has the correct title'); - equal(label.children[0].data, 'hello', 'it has the category name'); + assert.equal(label.children[0].data, 'hello', 'it has the category name'); }); -test("undefined color", function() { +QUnit.test("undefined color", assert => { const store = createStore(); const noColor = store.createRecord('category', { name: 'hello', id: 123 }); const tag = parseHTML(categoryBadgeHTML(noColor))[0]; - blank(tag.attributes.style, "it has no color style because there are no colors"); + assert.blank(tag.attributes.style, "it has no color style because there are no colors"); }); -test("allowUncategorized", function() { +QUnit.test("allowUncategorized", assert => { const store = createStore(); const uncategorized = store.createRecord('category', {name: 'uncategorized', id: 345}); sandbox.stub(Discourse.Site, 'currentProp').withArgs('uncategorized_category_id').returns(345); - blank(categoryBadgeHTML(uncategorized), "it doesn't return HTML for uncategorized by default"); - present(categoryBadgeHTML(uncategorized, {allowUncategorized: true}), "it returns HTML"); -}); + assert.blank(categoryBadgeHTML(uncategorized), "it doesn't return HTML for uncategorized by default"); + assert.present(categoryBadgeHTML(uncategorized, {allowUncategorized: true}), "it returns HTML"); +}); \ No newline at end of file diff --git a/test/javascripts/lib/click-track-edit-history-test.js.es6 b/test/javascripts/lib/click-track-edit-history-test.js.es6 index 4350ab6d22b..bf0c6abad94 100644 --- a/test/javascripts/lib/click-track-edit-history-test.js.es6 +++ b/test/javascripts/lib/click-track-edit-history-test.js.es6 @@ -1,4 +1,3 @@ -import { blank } from 'helpers/qunit-helpers'; import DiscourseURL from "discourse/lib/url"; import ClickTrack from "discourse/lib/click-track"; @@ -6,8 +5,8 @@ var windowOpen, win, redirectTo; -module("lib:click-track-edit-history", { - setup: function() { +QUnit.module("lib:click-track-edit-history", { + beforeEach() { // Prevent any of these tests from navigating away win = {focus: function() { } }; @@ -56,56 +55,57 @@ var generateClickEventOn = function(selector) { return $.Event("click", { currentTarget: fixture(selector)[0] }); }; -test("does not track clicks on lightboxes", function() { +QUnit.test("does not track clicks on lightboxes", assert => { var clickEvent = generateClickEventOn('.lightbox'); sandbox.stub(clickEvent, "preventDefault"); - ok(track(clickEvent)); - ok(!clickEvent.preventDefault.calledOnce); + assert.ok(track(clickEvent)); + assert.ok(!clickEvent.preventDefault.calledOnce); }); -test("it calls preventDefault when clicking on an a", function() { +QUnit.test("it calls preventDefault when clicking on an a", assert => { var clickEvent = generateClickEventOn('a'); sandbox.stub(clickEvent, "preventDefault"); track(clickEvent); - ok(clickEvent.preventDefault.calledOnce); - ok(DiscourseURL.redirectTo.calledOnce); + assert.ok(clickEvent.preventDefault.calledOnce); + assert.ok(DiscourseURL.redirectTo.calledOnce); }); -test("does not track clicks when forcibly disabled", function() { - ok(track(generateClickEventOn('.no-track-link'))); +QUnit.test("does not track clicks when forcibly disabled", assert => { + assert.ok(track(generateClickEventOn('.no-track-link'))); }); -test("does not track clicks on back buttons", function() { - ok(track(generateClickEventOn('.back'))); +QUnit.test("does not track clicks on back buttons", assert => { + assert.ok(track(generateClickEventOn('.back'))); }); -test("does not track clicks on quote buttons", function() { - ok(track(generateClickEventOn('.quote-other-topic'))); +QUnit.test("does not track clicks on quote buttons", assert => { + assert.ok(track(generateClickEventOn('.quote-other-topic'))); }); -test("does not track clicks on category badges", () => { - ok(track(generateClickEventOn('.hashtag'))); +QUnit.test("does not track clicks on category badges", assert => { + assert.ok(track(generateClickEventOn('.hashtag'))); }); -test("removes the href and put it as a data attribute", function() { +QUnit.test("removes the href and put it as a data attribute", assert => { track(generateClickEventOn('a')); var $link = fixture('a').first(); - ok($link.hasClass('no-href')); - equal($link.data('href'), 'http://www.google.com'); - blank($link.attr('href')); - ok($link.data('auto-route')); - ok(DiscourseURL.redirectTo.calledOnce); + assert.ok($link.hasClass('no-href')); + assert.equal($link.data('href'), 'http://www.google.com'); + assert.blank($link.attr('href')); + assert.ok($link.data('auto-route')); + assert.ok(DiscourseURL.redirectTo.calledOnce); }); -asyncTestDiscourse("restores the href after a while", function() { - expect(1); +asyncTestDiscourse("restores the href after a while", function(assert) { + assert.expect(1); track(generateClickEventOn('a')); + const done = assert.async(); setTimeout(function() { - start(); - equal(fixture('a').attr('href'), "http://www.google.com"); + done(); + assert.equal(fixture('a').attr('href'), "http://www.google.com"); }, 75); }); @@ -115,32 +115,32 @@ var trackRightClick = function(target) { return track(clickEvent); }; -test("right clicks change the href", function() { - ok(trackRightClick('a')); - equal(fixture('a').first().prop('href'), "http://www.google.com/"); +QUnit.test("right clicks change the href", assert => { + assert.ok(trackRightClick('a')); + assert.equal(fixture('a').first().prop('href'), "http://www.google.com/"); }); -test("right clicks are tracked", function() { +QUnit.test("right clicks are tracked", assert => { Discourse.SiteSettings.track_external_right_clicks = true; trackRightClick('a'); - equal(fixture('a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"); + assert.equal(fixture('a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"); }); -test("preventDefault is not called for right clicks", function() { +QUnit.test("preventDefault is not called for right clicks", assert => { var clickEvent = generateClickEventOn('a'); clickEvent.which = 3; sandbox.stub(clickEvent, "preventDefault"); - ok(track(clickEvent)); - ok(!clickEvent.preventDefault.calledOnce); + assert.ok(track(clickEvent)); + assert.ok(!clickEvent.preventDefault.calledOnce); }); var testOpenInANewTab = function(description, clickEventModifier) { - test(description, function() { + test(description, function(assert) { var clickEvent = generateClickEventOn('a'); clickEventModifier(clickEvent); sandbox.stub(clickEvent, "preventDefault"); - ok(track(clickEvent)); - ok(!clickEvent.preventDefault.calledOnce); + assert.ok(track(clickEvent)); + assert.ok(!clickEvent.preventDefault.calledOnce); }); }; @@ -160,31 +160,31 @@ testOpenInANewTab("it opens in a new tab on middle click", function(clickEvent) clickEvent.button = 2; }); -test("tracks via AJAX if we're on the same site", function() { +QUnit.test("tracks via AJAX if we're on the same site", assert => { sandbox.stub(DiscourseURL, "routeTo"); sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com"); - ok(!track(generateClickEventOn('#same-site'))); - ok(DiscourseURL.routeTo.calledOnce); + assert.ok(!track(generateClickEventOn('#same-site'))); + assert.ok(DiscourseURL.routeTo.calledOnce); }); -test("does not track via AJAX for attachments", function() { +QUnit.test("does not track via AJAX for attachments", assert => { sandbox.stub(DiscourseURL, "routeTo"); sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com"); - ok(!track(generateClickEventOn('.attachment'))); - ok(DiscourseURL.redirectTo.calledOnce); + assert.ok(!track(generateClickEventOn('.attachment'))); + assert.ok(DiscourseURL.redirectTo.calledOnce); }); -test("tracks custom urls when opening in another window", function() { +QUnit.test("tracks custom urls when opening in another window", assert => { var clickEvent = generateClickEventOn('a'); sandbox.stub(Discourse.User, "currentProp").withArgs('external_links_in_new_tab').returns(true); - ok(!track(clickEvent)); - ok(windowOpen.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337', '_blank')); + assert.ok(!track(clickEvent)); + assert.ok(windowOpen.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337', '_blank')); }); -test("tracks custom urls when opening in another window", function() { +QUnit.test("tracks custom urls when opening in another window", assert => { var clickEvent = generateClickEventOn('a'); - ok(!track(clickEvent)); - ok(redirectTo.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337')); + assert.ok(!track(clickEvent)); + assert.ok(redirectTo.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337')); }); diff --git a/test/javascripts/lib/click-track-profile-page-test.js.es6 b/test/javascripts/lib/click-track-profile-page-test.js.es6 index bc0b46e5595..9e91d6ea709 100644 --- a/test/javascripts/lib/click-track-profile-page-test.js.es6 +++ b/test/javascripts/lib/click-track-profile-page-test.js.es6 @@ -1,4 +1,3 @@ -import { blank } from 'helpers/qunit-helpers'; import DiscourseURL from "discourse/lib/url"; import ClickTrack from "discourse/lib/click-track"; @@ -6,8 +5,8 @@ var windowOpen, win, redirectTo; -module("lib:click-track-profile-page", { - setup: function() { +QUnit.module("lib:click-track-profile-page", { + beforeEach() { // Prevent any of these tests from navigating away win = {focus: function() { } }; @@ -50,56 +49,57 @@ var generateClickEventOn = function(selector) { return $.Event("click", { currentTarget: fixture(selector)[0] }); }; -test("does not track clicks on lightboxes", function() { +QUnit.test("does not track clicks on lightboxes", assert => { var clickEvent = generateClickEventOn('.lightbox'); sandbox.stub(clickEvent, "preventDefault"); - ok(track(clickEvent)); - ok(!clickEvent.preventDefault.calledOnce); + assert.ok(track(clickEvent)); + assert.ok(!clickEvent.preventDefault.calledOnce); }); -test("it calls preventDefault when clicking on an a", function() { +QUnit.test("it calls preventDefault when clicking on an a", assert => { var clickEvent = generateClickEventOn('a'); sandbox.stub(clickEvent, "preventDefault"); track(clickEvent); - ok(clickEvent.preventDefault.calledOnce); - ok(DiscourseURL.redirectTo.calledOnce); + assert.ok(clickEvent.preventDefault.calledOnce); + assert.ok(DiscourseURL.redirectTo.calledOnce); }); -test("does not track clicks when forcibly disabled", function() { - ok(track(generateClickEventOn('.no-track-link'))); +QUnit.test("does not track clicks when forcibly disabled", assert => { + assert.ok(track(generateClickEventOn('.no-track-link'))); }); -test("does not track clicks on back buttons", function() { - ok(track(generateClickEventOn('.back'))); +QUnit.test("does not track clicks on back buttons", assert => { + assert.ok(track(generateClickEventOn('.back'))); }); -test("does not track clicks on quote buttons", function() { - ok(track(generateClickEventOn('.quote-other-topic'))); +QUnit.test("does not track clicks on quote buttons", assert => { + assert.ok(track(generateClickEventOn('.quote-other-topic'))); }); -test("does not track clicks on category badges", () => { - ok(track(generateClickEventOn('.hashtag'))); +QUnit.test("does not track clicks on category badges", assert => { + assert.ok(track(generateClickEventOn('.hashtag'))); }); -test("removes the href and put it as a data attribute", function() { +QUnit.test("removes the href and put it as a data attribute", assert => { track(generateClickEventOn('a')); var $link = fixture('a').first(); - ok($link.hasClass('no-href')); - equal($link.data('href'), 'http://www.google.com'); - blank($link.attr('href')); - ok($link.data('auto-route')); - ok(DiscourseURL.redirectTo.calledOnce); + assert.ok($link.hasClass('no-href')); + assert.equal($link.data('href'), 'http://www.google.com'); + assert.blank($link.attr('href')); + assert.ok($link.data('auto-route')); + assert.ok(DiscourseURL.redirectTo.calledOnce); }); -asyncTestDiscourse("restores the href after a while", function() { - expect(1); +asyncTestDiscourse("restores the href after a while", function(assert) { + assert.expect(1); track(generateClickEventOn('a')); + const done = assert.async(); setTimeout(function() { - start(); - equal(fixture('a').attr('href'), "http://www.google.com"); + done(); + assert.equal(fixture('a').attr('href'), "http://www.google.com"); }, 75); }); @@ -109,38 +109,38 @@ var trackRightClick = function(target) { return track(clickEvent); }; -test("right clicks change the href", function() { - ok(trackRightClick('a')); - equal(fixture('a').first().prop('href'), "http://www.google.com/"); +QUnit.test("right clicks change the href", assert => { + assert.ok(trackRightClick('a')); + assert.equal(fixture('a').first().prop('href'), "http://www.google.com/"); }); -test("right clicks are tracked", function() { +QUnit.test("right clicks are tracked", assert => { Discourse.SiteSettings.track_external_right_clicks = true; trackRightClick('a'); - equal(fixture('.first a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"); + assert.equal(fixture('.first a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"); }); -test("right clicks are tracked for second excerpt", function() { +QUnit.test("right clicks are tracked for second excerpt", assert => { Discourse.SiteSettings.track_external_right_clicks = true; trackRightClick('.second a'); - equal(fixture('.second a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=24&topic_id=7331"); + assert.equal(fixture('.second a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=24&topic_id=7331"); }); -test("preventDefault is not called for right clicks", function() { +QUnit.test("preventDefault is not called for right clicks", assert => { var clickEvent = generateClickEventOn('a'); clickEvent.which = 3; sandbox.stub(clickEvent, "preventDefault"); - ok(track(clickEvent)); - ok(!clickEvent.preventDefault.calledOnce); + assert.ok(track(clickEvent)); + assert.ok(!clickEvent.preventDefault.calledOnce); }); var testOpenInANewTab = function(description, clickEventModifier) { - test(description, function() { + test(description, function(assert) { var clickEvent = generateClickEventOn('a'); clickEventModifier(clickEvent); sandbox.stub(clickEvent, "preventDefault"); - ok(track(clickEvent)); - ok(!clickEvent.preventDefault.calledOnce); + assert.ok(track(clickEvent)); + assert.ok(!clickEvent.preventDefault.calledOnce); }); }; @@ -160,44 +160,44 @@ testOpenInANewTab("it opens in a new tab on middle click", function(clickEvent) clickEvent.button = 2; }); -test("tracks via AJAX if we're on the same site", function() { +QUnit.test("tracks via AJAX if we're on the same site", assert => { sandbox.stub(DiscourseURL, "routeTo"); sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com"); - ok(!track(generateClickEventOn('#same-site'))); - ok(DiscourseURL.routeTo.calledOnce); + assert.ok(!track(generateClickEventOn('#same-site'))); + assert.ok(DiscourseURL.routeTo.calledOnce); }); -test("does not track via AJAX for attachments", function() { +QUnit.test("does not track via AJAX for attachments", assert => { sandbox.stub(DiscourseURL, "routeTo"); sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com"); - ok(!track(generateClickEventOn('.attachment'))); - ok(DiscourseURL.redirectTo.calledOnce); + assert.ok(!track(generateClickEventOn('.attachment'))); + assert.ok(DiscourseURL.redirectTo.calledOnce); }); -test("tracks custom urls when opening in another window", function() { +QUnit.test("tracks custom urls when opening in another window", assert => { var clickEvent = generateClickEventOn('a'); sandbox.stub(Discourse.User, "currentProp").withArgs('external_links_in_new_tab').returns(true); - ok(!track(clickEvent)); - ok(windowOpen.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337', '_blank')); + assert.ok(!track(clickEvent)); + assert.ok(windowOpen.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337', '_blank')); }); -test("tracks custom urls on second excerpt when opening in another window", function() { +QUnit.test("tracks custom urls on second excerpt when opening in another window", assert => { var clickEvent = generateClickEventOn('.second a'); sandbox.stub(Discourse.User, "currentProp").withArgs('external_links_in_new_tab').returns(true); - ok(!track(clickEvent)); - ok(windowOpen.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=24&topic_id=7331', '_blank')); + assert.ok(!track(clickEvent)); + assert.ok(windowOpen.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=24&topic_id=7331', '_blank')); }); -test("tracks custom urls when opening in another window", function() { +QUnit.test("tracks custom urls when opening in another window", assert => { var clickEvent = generateClickEventOn('a'); - ok(!track(clickEvent)); - ok(redirectTo.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337')); + assert.ok(!track(clickEvent)); + assert.ok(redirectTo.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337')); }); -test("tracks custom urls on second excerpt when opening in another window", function() { +QUnit.test("tracks custom urls on second excerpt when opening in another window", assert => { var clickEvent = generateClickEventOn('.second a'); - ok(!track(clickEvent)); - ok(redirectTo.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=24&topic_id=7331')); + assert.ok(!track(clickEvent)); + assert.ok(redirectTo.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=24&topic_id=7331')); }); diff --git a/test/javascripts/lib/click-track-test.js.es6 b/test/javascripts/lib/click-track-test.js.es6 index cb05ba7e565..5f33e03374b 100644 --- a/test/javascripts/lib/click-track-test.js.es6 +++ b/test/javascripts/lib/click-track-test.js.es6 @@ -1,4 +1,3 @@ -import { blank } from 'helpers/qunit-helpers'; import DiscourseURL from "discourse/lib/url"; import ClickTrack from "discourse/lib/click-track"; @@ -6,8 +5,8 @@ var windowOpen, win, redirectTo; -module("lib:click-track", { - setup: function() { +QUnit.module("lib:click-track", { + beforeEach() { // Prevent any of these tests from navigating away win = {focus: function() { } }; redirectTo = sandbox.stub(DiscourseURL, "redirectTo"); @@ -47,87 +46,88 @@ var generateClickEventOn = function(selector) { return $.Event("click", { currentTarget: fixture(selector)[0] }); }; -test("does not track clicks on lightboxes", function() { +QUnit.test("does not track clicks on lightboxes", function(assert) { var clickEvent = generateClickEventOn('.lightbox'); sandbox.stub(clickEvent, "preventDefault"); - ok(track(clickEvent)); - ok(!clickEvent.preventDefault.calledOnce); + assert.ok(track(clickEvent)); + assert.ok(!clickEvent.preventDefault.calledOnce); }); -test("it calls preventDefault when clicking on an a", function() { +QUnit.test("it calls preventDefault when clicking on an a", function(assert) { var clickEvent = generateClickEventOn('a'); sandbox.stub(clickEvent, "preventDefault"); track(clickEvent); - ok(clickEvent.preventDefault.calledOnce); - ok(DiscourseURL.redirectTo.calledOnce); + assert.ok(clickEvent.preventDefault.calledOnce); + assert.ok(DiscourseURL.redirectTo.calledOnce); }); -test("does not track clicks when forcibly disabled", function() { - ok(track(generateClickEventOn('.no-track-link'))); +QUnit.test("does not track clicks when forcibly disabled", function(assert) { + assert.ok(track(generateClickEventOn('.no-track-link'))); }); -test("does not track clicks on back buttons", function() { - ok(track(generateClickEventOn('.back'))); +QUnit.test("does not track clicks on back buttons", function(assert) { + assert.ok(track(generateClickEventOn('.back'))); }); -test("does not track clicks in quotes", function() { - ok(track(generateClickEventOn('.inside-quote'))); +QUnit.test("does not track clicks in quotes", function(assert) { + assert.ok(track(generateClickEventOn('.inside-quote'))); }); -test("does not track clicks on quote buttons", function() { - ok(track(generateClickEventOn('.quote-other-topic'))); +QUnit.test("does not track clicks on quote buttons", function(assert) { + assert.ok(track(generateClickEventOn('.quote-other-topic'))); }); -test("does not track clicks on category badges", () => { - ok(track(generateClickEventOn('.hashtag'))); +QUnit.test("does not track clicks on category badges", assert => { + assert.ok(track(generateClickEventOn('.hashtag'))); }); -test("does not track clicks on mailto", function() { - ok(track(generateClickEventOn('.mailto'))); +QUnit.test("does not track clicks on mailto", function(assert) { + assert.ok(track(generateClickEventOn('.mailto'))); }); -test("removes the href and put it as a data attribute", function() { +QUnit.test("removes the href and put it as a data attribute", function(assert) { track(generateClickEventOn('a')); var $link = fixture('a').first(); - ok($link.hasClass('no-href')); - equal($link.data('href'), 'http://www.google.com'); - blank($link.attr('href')); - ok($link.data('auto-route')); - ok(DiscourseURL.redirectTo.calledOnce); + assert.ok($link.hasClass('no-href')); + assert.equal($link.data('href'), 'http://www.google.com'); + assert.blank($link.attr('href')); + assert.ok($link.data('auto-route')); + assert.ok(DiscourseURL.redirectTo.calledOnce); }); -asyncTestDiscourse("restores the href after a while", function() { - expect(1); +asyncTestDiscourse("restores the href after a while", function(assert) { + assert.expect(1); track(generateClickEventOn('a')); + const done = assert.async(); setTimeout(function() { - start(); - equal(fixture('a').attr('href'), "http://www.google.com"); + done(); + assert.equal(fixture('a').attr('href'), "http://www.google.com"); }, 75); }); -var badgeClickCount = function(id, expected) { +var badgeClickCount = function(assert, id, expected) { track(generateClickEventOn('#' + id)); var $badge = $('span.badge', fixture('#' + id).first()); - equal(parseInt($badge.html(), 10), expected); + assert.equal(parseInt($badge.html(), 10), expected); }; -test("does not update badge clicks on my own link", function() { +QUnit.test("does not update badge clicks on my own link", function(assert) { sandbox.stub(Discourse.User, 'currentProp').withArgs('id').returns(314); - badgeClickCount('with-badge', 1); + badgeClickCount(assert, 'with-badge', 1); }); -test("does not update badge clicks in my own post", function() { +QUnit.test("does not update badge clicks in my own post", function(assert) { sandbox.stub(Discourse.User, 'currentProp').withArgs('id').returns(3141); - badgeClickCount('with-badge-but-not-mine', 1); + badgeClickCount(assert, 'with-badge-but-not-mine', 1); }); -test("updates badge counts correctly", function() { - badgeClickCount('inside-onebox', 1); - badgeClickCount('inside-onebox-forced', 2); - badgeClickCount('with-badge', 2); +QUnit.test("updates badge counts correctly", function(assert) { + badgeClickCount(assert, 'inside-onebox', 1); + badgeClickCount(assert, 'inside-onebox-forced', 2); + badgeClickCount(assert, 'with-badge', 2); }); var trackRightClick = function() { @@ -136,32 +136,32 @@ var trackRightClick = function() { return track(clickEvent); }; -test("right clicks change the href", function() { - ok(trackRightClick()); - equal(fixture('a').first().prop('href'), "http://www.google.com/"); +QUnit.test("right clicks change the href", function(assert) { + assert.ok(trackRightClick()); + assert.equal(fixture('a').first().prop('href'), "http://www.google.com/"); }); -test("right clicks are tracked", function() { +QUnit.test("right clicks are tracked", function(assert) { Discourse.SiteSettings.track_external_right_clicks = true; trackRightClick(); - equal(fixture('a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"); + assert.equal(fixture('a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"); }); -test("preventDefault is not called for right clicks", function() { +QUnit.test("preventDefault is not called for right clicks", function(assert) { var clickEvent = generateClickEventOn('a'); clickEvent.which = 3; sandbox.stub(clickEvent, "preventDefault"); - ok(track(clickEvent)); - ok(!clickEvent.preventDefault.calledOnce); + assert.ok(track(clickEvent)); + assert.ok(!clickEvent.preventDefault.calledOnce); }); var testOpenInANewTab = function(description, clickEventModifier) { - test(description, function() { + test(description, function(assert) { var clickEvent = generateClickEventOn('a'); clickEventModifier(clickEvent); sandbox.stub(clickEvent, "preventDefault"); - ok(track(clickEvent)); - ok(!clickEvent.preventDefault.calledOnce); + assert.ok(track(clickEvent)); + assert.ok(!clickEvent.preventDefault.calledOnce); }); }; @@ -181,31 +181,31 @@ testOpenInANewTab("it opens in a new tab on middle click", function(clickEvent) clickEvent.button = 2; }); -test("tracks via AJAX if we're on the same site", function() { +QUnit.test("tracks via AJAX if we're on the same site", function(assert) { sandbox.stub(DiscourseURL, "routeTo"); sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com"); - ok(!track(generateClickEventOn('#same-site'))); - ok(DiscourseURL.routeTo.calledOnce); + assert.ok(!track(generateClickEventOn('#same-site'))); + assert.ok(DiscourseURL.routeTo.calledOnce); }); -test("does not track via AJAX for attachments", function() { +QUnit.test("does not track via AJAX for attachments", function(assert) { sandbox.stub(DiscourseURL, "routeTo"); sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com"); - ok(!track(generateClickEventOn('.attachment'))); - ok(DiscourseURL.redirectTo.calledOnce); + assert.ok(!track(generateClickEventOn('.attachment'))); + assert.ok(DiscourseURL.redirectTo.calledOnce); }); -test("tracks custom urls when opening in another window", function() { +QUnit.test("tracks custom urls when opening in another window", function(assert) { var clickEvent = generateClickEventOn('a'); sandbox.stub(Discourse.User, "currentProp").withArgs('external_links_in_new_tab').returns(true); - ok(!track(clickEvent)); - ok(windowOpen.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337', '_blank')); + assert.ok(!track(clickEvent)); + assert.ok(windowOpen.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337', '_blank')); }); -test("tracks custom urls when opening in another window", function() { +QUnit.test("tracks custom urls when opening in another window", function(assert) { var clickEvent = generateClickEventOn('a'); - ok(!track(clickEvent)); - ok(redirectTo.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337')); + assert.ok(!track(clickEvent)); + assert.ok(redirectTo.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337')); }); diff --git a/test/javascripts/lib/computed-test.js.es6 b/test/javascripts/lib/computed-test.js.es6 index 658f35e6757..5c29a3adba0 100644 --- a/test/javascripts/lib/computed-test.js.es6 +++ b/test/javascripts/lib/computed-test.js.es6 @@ -1,29 +1,29 @@ import { setting, propertyEqual, propertyNotEqual, fmt, i18n, url } from 'discourse/lib/computed'; -module("lib:computed", { - setup: function() { +QUnit.module("lib:computed", { + beforeEach() { sandbox.stub(I18n, "t", function(scope) { return "%@ translated: " + scope; }); }, - teardown: function() { + afterEach() { I18n.t.restore(); } }); -test("setting", function() { +QUnit.test("setting", assert => { var t = Em.Object.extend({ vehicle: setting('vehicle'), missingProp: setting('madeUpThing') }).create(); Discourse.SiteSettings.vehicle = "airplane"; - equal(t.get('vehicle'), "airplane", "it has the value of the site setting"); - ok(!t.get('missingProp'), "it is falsy when the site setting is not defined"); + assert.equal(t.get('vehicle'), "airplane", "it has the value of the site setting"); + assert.ok(!t.get('missingProp'), "it is falsy when the site setting is not defined"); }); -test("propertyEqual", function() { +QUnit.test("propertyEqual", assert => { var t = Em.Object.extend({ same: propertyEqual('cookies', 'biscuits') }).create({ @@ -31,12 +31,12 @@ test("propertyEqual", function() { biscuits: 10 }); - ok(t.get('same'), "it is true when the properties are the same"); + assert.ok(t.get('same'), "it is true when the properties are the same"); t.set('biscuits', 9); - ok(!t.get('same'), "it isn't true when one property is different"); + assert.ok(!t.get('same'), "it isn't true when one property is different"); }); -test("propertyNotEqual", function() { +QUnit.test("propertyNotEqual", assert => { var t = Em.Object.extend({ diff: propertyNotEqual('cookies', 'biscuits') }).create({ @@ -44,13 +44,13 @@ test("propertyNotEqual", function() { biscuits: 10 }); - ok(!t.get('diff'), "it isn't true when the properties are the same"); + assert.ok(!t.get('diff'), "it isn't true when the properties are the same"); t.set('biscuits', 9); - ok(t.get('diff'), "it is true when one property is different"); + assert.ok(t.get('diff'), "it is true when one property is different"); }); -test("fmt", function() { +QUnit.test("fmt", assert => { var t = Em.Object.extend({ exclaimyUsername: fmt('username', "!!! %@ !!!"), multiple: fmt('username', 'mood', "%@ is %@") @@ -59,17 +59,17 @@ test("fmt", function() { mood: "happy" }); - equal(t.get('exclaimyUsername'), '!!! eviltrout !!!', "it inserts the string"); - equal(t.get('multiple'), "eviltrout is happy", "it inserts multiple strings"); + assert.equal(t.get('exclaimyUsername'), '!!! eviltrout !!!', "it inserts the string"); + assert.equal(t.get('multiple'), "eviltrout is happy", "it inserts multiple strings"); t.set('username', 'codinghorror'); - equal(t.get('multiple'), "codinghorror is happy", "it supports changing properties"); + assert.equal(t.get('multiple'), "codinghorror is happy", "it supports changing properties"); t.set('mood', 'ecstatic'); - equal(t.get('multiple'), "codinghorror is ecstatic", "it supports changing another property"); + assert.equal(t.get('multiple'), "codinghorror is ecstatic", "it supports changing another property"); }); -test("i18n", function() { +QUnit.test("i18n", assert => { var t = Em.Object.extend({ exclaimyUsername: i18n('username', "!!! %@ !!!"), multiple: i18n('username', 'mood', "%@ is %@") @@ -78,17 +78,17 @@ test("i18n", function() { mood: "happy" }); - equal(t.get('exclaimyUsername'), '%@ translated: !!! eviltrout !!!', "it inserts the string and then translates"); - equal(t.get('multiple'), "%@ translated: eviltrout is happy", "it inserts multiple strings and then translates"); + assert.equal(t.get('exclaimyUsername'), '%@ translated: !!! eviltrout !!!', "it inserts the string and then translates"); + assert.equal(t.get('multiple'), "%@ translated: eviltrout is happy", "it inserts multiple strings and then translates"); t.set('username', 'codinghorror'); - equal(t.get('multiple'), "%@ translated: codinghorror is happy", "it supports changing properties"); + assert.equal(t.get('multiple'), "%@ translated: codinghorror is happy", "it supports changing properties"); t.set('mood', 'ecstatic'); - equal(t.get('multiple'), "%@ translated: codinghorror is ecstatic", "it supports changing another property"); + assert.equal(t.get('multiple'), "%@ translated: codinghorror is ecstatic", "it supports changing another property"); }); -test("url", function() { +QUnit.test("url", assert => { var t, testClass; testClass = Em.Object.extend({ @@ -96,9 +96,9 @@ test("url", function() { }); t = testClass.create({ username: 'eviltrout' }); - equal(t.get('userUrl'), "/u/eviltrout", "it supports urls without a prefix"); + assert.equal(t.get('userUrl'), "/u/eviltrout", "it supports urls without a prefix"); Discourse.BaseUri = "/prefixed"; t = testClass.create({ username: 'eviltrout' }); - equal(t.get('userUrl'), "/prefixed/u/eviltrout", "it supports urls with a prefix"); + assert.equal(t.get('userUrl'), "/prefixed/u/eviltrout", "it supports urls with a prefix"); }); diff --git a/test/javascripts/lib/discourse-test.js.es6 b/test/javascripts/lib/discourse-test.js.es6 index a6547741238..4bafe429abb 100644 --- a/test/javascripts/lib/discourse-test.js.es6 +++ b/test/javascripts/lib/discourse-test.js.es6 @@ -1,7 +1,7 @@ -module("lib:discourse"); +QUnit.module("lib:discourse"); -test("getURL on subfolder install", function() { +QUnit.test("getURL on subfolder install", assert => { Discourse.BaseUri = "/forum"; - equal(Discourse.getURL("/"), "/forum/", "root url has subfolder"); - equal(Discourse.getURL("/u/neil"), "/forum/u/neil", "relative url has subfolder"); -}); + assert.equal(Discourse.getURL("/"), "/forum/", "root url has subfolder"); + assert.equal(Discourse.getURL("/u/neil"), "/forum/u/neil", "relative url has subfolder"); +}); \ No newline at end of file diff --git a/test/javascripts/lib/emoji-test.js.es6 b/test/javascripts/lib/emoji-test.js.es6 index a9293235371..8512b9f05ce 100644 --- a/test/javascripts/lib/emoji-test.js.es6 +++ b/test/javascripts/lib/emoji-test.js.es6 @@ -1,13 +1,13 @@ import { emojiSearch, IMAGE_VERSION as v } from 'pretty-text/emoji'; import { emojiUnescape } from 'discourse/lib/text'; -module('lib:emoji'); +QUnit.module('lib:emoji'); -function testUnescape(input, expected, description) { - equal(emojiUnescape(input), expected, description); -}; +QUnit.test("emojiUnescape", assert => { + const testUnescape = (input, expected, description) => { + assert.equal(emojiUnescape(input), expected, description); + }; -test("emojiUnescape", () => { testUnescape("Not emoji :O) :frog) :smile)", "Not emoji :O) :frog) :smile)", "title without emoji"); testUnescape("Not emoji :frog :smile", "Not emoji :frog :smile", "end colon is not optional"); testUnescape("emoticons :)", `emoticons `, "emoticons are still supported"); @@ -24,11 +24,11 @@ test("emojiUnescape", () => { }); -test("Emoji search", () => { +QUnit.test("Emoji search", assert => { // able to find an alias - equal(emojiSearch("+1").length, 1); + assert.equal(emojiSearch("+1").length, 1); // able to find middle of line search - equal(emojiSearch("check", {maxResults: 3}).length, 3); + assert.equal(emojiSearch("check", {maxResults: 3}).length, 3); }); diff --git a/test/javascripts/lib/formatter-test.js.es6 b/test/javascripts/lib/formatter-test.js.es6 index 31be0668ad8..9e929e1853e 100644 --- a/test/javascripts/lib/formatter-test.js.es6 +++ b/test/javascripts/lib/formatter-test.js.es6 @@ -2,12 +2,12 @@ var clock; import { relativeAge, autoUpdatingRelativeAge, updateRelativeAge, breakUp, number, longDate } from 'discourse/lib/formatter'; -module("lib:formatter", { - setup: function() { +QUnit.module("lib:formatter", { + beforeEach() { clock = sinon.useFakeTimers(new Date(2012,11,31,12,0).getTime()); }, - teardown: function() { + afterEach() { clock.restore(); } }); @@ -34,7 +34,7 @@ var shortDate = function(days){ return moment().subtract(days, 'days').format('MMM D'); }; -test("formating medium length dates", function() { +QUnit.test("formating medium length dates", assert => { format = "medium"; var strip = function(html){ @@ -46,133 +46,133 @@ test("formating medium length dates", function() { }; leaveAgo = true; - equal(strip(formatMins(1.4)), "1 min ago"); - equal(strip(formatMins(2)), "2 mins ago"); - equal(strip(formatMins(55)), "55 mins ago"); - equal(strip(formatMins(56)), "1 hour ago"); - equal(strip(formatHours(4)), "4 hours ago"); - equal(strip(formatHours(22)), "22 hours ago"); - equal(strip(formatHours(23)), "23 hours ago"); - equal(strip(formatHours(23.5)), "1 day ago"); - equal(strip(formatDays(4.85)), "4 days ago"); + assert.equal(strip(formatMins(1.4)), "1 min ago"); + assert.equal(strip(formatMins(2)), "2 mins ago"); + assert.equal(strip(formatMins(55)), "55 mins ago"); + assert.equal(strip(formatMins(56)), "1 hour ago"); + assert.equal(strip(formatHours(4)), "4 hours ago"); + assert.equal(strip(formatHours(22)), "22 hours ago"); + assert.equal(strip(formatHours(23)), "23 hours ago"); + assert.equal(strip(formatHours(23.5)), "1 day ago"); + assert.equal(strip(formatDays(4.85)), "4 days ago"); leaveAgo = false; - equal(strip(formatMins(0)), "just now"); - equal(strip(formatMins(1.4)), "1 min"); - equal(strip(formatMins(2)), "2 mins"); - equal(strip(formatMins(55)), "55 mins"); - equal(strip(formatMins(56)), "1 hour"); - equal(strip(formatHours(4)), "4 hours"); - equal(strip(formatHours(22)), "22 hours"); - equal(strip(formatHours(23)), "23 hours"); - equal(strip(formatHours(23.5)), "1 day"); - equal(strip(formatDays(4.85)), "4 days"); + assert.equal(strip(formatMins(0)), "just now"); + assert.equal(strip(formatMins(1.4)), "1 min"); + assert.equal(strip(formatMins(2)), "2 mins"); + assert.equal(strip(formatMins(55)), "55 mins"); + assert.equal(strip(formatMins(56)), "1 hour"); + assert.equal(strip(formatHours(4)), "4 hours"); + assert.equal(strip(formatHours(22)), "22 hours"); + assert.equal(strip(formatHours(23)), "23 hours"); + assert.equal(strip(formatHours(23.5)), "1 day"); + assert.equal(strip(formatDays(4.85)), "4 days"); - equal(strip(formatDays(6)), shortDate(6)); - equal(strip(formatDays(100)), shortDate(100)); // eg: Jan 23 - equal(strip(formatDays(500)), shortDateYear(500)); + assert.equal(strip(formatDays(6)), shortDate(6)); + assert.equal(strip(formatDays(100)), shortDate(100)); // eg: Jan 23 + assert.equal(strip(formatDays(500)), shortDateYear(500)); - equal($(formatDays(0)).attr("title"), longDate(new Date())); - equal($(formatDays(0)).attr("class"), "date"); + assert.equal($(formatDays(0)).attr("title"), longDate(new Date())); + assert.equal($(formatDays(0)).attr("class"), "date"); clock.restore(); clock = sinon.useFakeTimers(new Date(2012,0,9,12,0).getTime()); // Jan 9, 2012 - equal(strip(formatDays(8)), shortDate(8)); - equal(strip(formatDays(10)), shortDateYear(10)); + assert.equal(strip(formatDays(8)), shortDate(8)); + assert.equal(strip(formatDays(10)), shortDateYear(10)); }); -test("formating tiny dates", function() { +QUnit.test("formating tiny dates", assert => { var shortDateYear = function(days){ return moment().subtract(days, 'days').format("MMM 'YY"); }; format = "tiny"; - equal(formatMins(0), "1m"); - equal(formatMins(1), "1m"); - equal(formatMins(2), "2m"); - equal(formatMins(60), "1h"); - equal(formatHours(4), "4h"); - equal(formatHours(23), "23h"); - equal(formatHours(23.5), "1d"); - equal(formatDays(1), "1d"); - equal(formatDays(14), "14d"); - equal(formatDays(15), shortDate(15)); - equal(formatDays(92), shortDate(92)); - equal(formatDays(364), shortDate(364)); - equal(formatDays(365), shortDate(365)); - equal(formatDays(366), shortDateYear(366)); // leap year - equal(formatDays(500), shortDateYear(500)); - equal(formatDays(365*2 + 1), shortDateYear(365*2 + 1)); // one leap year + assert.equal(formatMins(0), "1m"); + assert.equal(formatMins(1), "1m"); + assert.equal(formatMins(2), "2m"); + assert.equal(formatMins(60), "1h"); + assert.equal(formatHours(4), "4h"); + assert.equal(formatHours(23), "23h"); + assert.equal(formatHours(23.5), "1d"); + assert.equal(formatDays(1), "1d"); + assert.equal(formatDays(14), "14d"); + assert.equal(formatDays(15), shortDate(15)); + assert.equal(formatDays(92), shortDate(92)); + assert.equal(formatDays(364), shortDate(364)); + assert.equal(formatDays(365), shortDate(365)); + assert.equal(formatDays(366), shortDateYear(366)); // leap year + assert.equal(formatDays(500), shortDateYear(500)); + assert.equal(formatDays(365*2 + 1), shortDateYear(365*2 + 1)); // one leap year var originalValue = Discourse.SiteSettings.relative_date_duration; Discourse.SiteSettings.relative_date_duration = 7; - equal(formatDays(7), "7d"); - equal(formatDays(8), shortDate(8)); + assert.equal(formatDays(7), "7d"); + assert.equal(formatDays(8), shortDate(8)); Discourse.SiteSettings.relative_date_duration = 1; - equal(formatDays(1), "1d"); - equal(formatDays(2), shortDate(2)); + assert.equal(formatDays(1), "1d"); + assert.equal(formatDays(2), shortDate(2)); Discourse.SiteSettings.relative_date_duration = 0; - equal(formatMins(0), "1m"); - equal(formatMins(1), "1m"); - equal(formatMins(2), "2m"); - equal(formatMins(60), "1h"); - equal(formatDays(1), shortDate(1)); - equal(formatDays(2), shortDate(2)); - equal(formatDays(366), shortDateYear(366)); + assert.equal(formatMins(0), "1m"); + assert.equal(formatMins(1), "1m"); + assert.equal(formatMins(2), "2m"); + assert.equal(formatMins(60), "1h"); + assert.equal(formatDays(1), shortDate(1)); + assert.equal(formatDays(2), shortDate(2)); + assert.equal(formatDays(366), shortDateYear(366)); Discourse.SiteSettings.relative_date_duration = null; - equal(formatDays(1), '1d'); - equal(formatDays(14), '14d'); - equal(formatDays(15), shortDate(15)); + assert.equal(formatDays(1), '1d'); + assert.equal(formatDays(14), '14d'); + assert.equal(formatDays(15), shortDate(15)); Discourse.SiteSettings.relative_date_duration = 14; clock.restore(); clock = sinon.useFakeTimers(new Date(2012,0,12,12,0).getTime()); // Jan 12, 2012 - equal(formatDays(11), "11d"); - equal(formatDays(14), "14d"); - equal(formatDays(15), shortDateYear(15)); - equal(formatDays(366), shortDateYear(366)); + assert.equal(formatDays(11), "11d"); + assert.equal(formatDays(14), "14d"); + assert.equal(formatDays(15), shortDateYear(15)); + assert.equal(formatDays(366), shortDateYear(366)); clock.restore(); clock = sinon.useFakeTimers(new Date(2012,0,20,12,0).getTime()); // Jan 20, 2012 - equal(formatDays(14), "14d"); - equal(formatDays(15), shortDate(15)); - equal(formatDays(20), shortDateYear(20)); + assert.equal(formatDays(14), "14d"); + assert.equal(formatDays(15), shortDate(15)); + assert.equal(formatDays(20), shortDateYear(20)); Discourse.SiteSettings.relative_date_duration = originalValue; }); -test("autoUpdatingRelativeAge", function() { +QUnit.test("autoUpdatingRelativeAge", assert => { var d = moment().subtract(1, 'day').toDate(); var $elem = $(autoUpdatingRelativeAge(d)); - equal($elem.data('format'), "tiny"); - equal($elem.data('time'), d.getTime()); - equal($elem.attr('title'), undefined); + assert.equal($elem.data('format'), "tiny"); + assert.equal($elem.data('time'), d.getTime()); + assert.equal($elem.attr('title'), undefined); $elem = $(autoUpdatingRelativeAge(d, {title: true})); - equal($elem.attr('title'), longDate(d)); + assert.equal($elem.attr('title'), longDate(d)); $elem = $(autoUpdatingRelativeAge(d,{format: 'medium', title: true, leaveAgo: true})); - equal($elem.data('format'), "medium-with-ago"); - equal($elem.data('time'), d.getTime()); - equal($elem.attr('title'), longDate(d)); - equal($elem.html(), '1 day ago'); + assert.equal($elem.data('format'), "medium-with-ago"); + assert.equal($elem.data('time'), d.getTime()); + assert.equal($elem.attr('title'), longDate(d)); + assert.equal($elem.html(), '1 day ago'); $elem = $(autoUpdatingRelativeAge(d,{format: 'medium'})); - equal($elem.data('format'), "medium"); - equal($elem.data('time'), d.getTime()); - equal($elem.attr('title'), undefined); - equal($elem.html(), '1 day'); + assert.equal($elem.data('format'), "medium"); + assert.equal($elem.data('time'), d.getTime()); + assert.equal($elem.attr('title'), undefined); + assert.equal($elem.html(), '1 day'); }); -test("updateRelativeAge", function(){ +QUnit.test("updateRelativeAge", assert =>{ var d = new Date(); var $elem = $(autoUpdatingRelativeAge(d)); @@ -180,7 +180,7 @@ test("updateRelativeAge", function(){ updateRelativeAge($elem); - equal($elem.html(), "2m"); + assert.equal($elem.html(), "2m"); d = new Date(); $elem = $(autoUpdatingRelativeAge(d, {format: 'medium', leaveAgo: true})); @@ -188,27 +188,27 @@ test("updateRelativeAge", function(){ updateRelativeAge($elem); - equal($elem.html(), "2 mins ago"); + assert.equal($elem.html(), "2 mins ago"); }); -test("breakUp", function(){ +QUnit.test("breakUp", assert =>{ var b = function(s,hint){ return breakUp(s,hint); }; - equal(b("hello"), "hello"); - equal(b("helloworld"), "helloworld"); - equal(b("HeMans11"), "He${expected}
`, text); +QUnit.assert.cookedPara = function(input, expected, message) { + QUnit.assert.cooked(input, `${expected}
`, message); }; -test("buildOptions", () => { - ok(buildOptions({ siteSettings: { allow_html_tables: true } }).features.table, 'tables enabled'); - ok(!buildOptions({ siteSettings: { allow_html_tables: false } }).features.table, 'tables disabled'); +QUnit.test("buildOptions", assert => { + assert.ok(buildOptions({ siteSettings: { allow_html_tables: true } }).features.table, 'tables enabled'); + assert.ok(!buildOptions({ siteSettings: { allow_html_tables: false } }).features.table, 'tables disabled'); - ok(buildOptions({ siteSettings: { enable_emoji: true } }).features.emoji, 'emoji enabled'); - ok(!buildOptions({ siteSettings: { enable_emoji: false } }).features.emoji, 'emoji disabled'); + assert.ok(buildOptions({ siteSettings: { enable_emoji: true } }).features.emoji, 'emoji enabled'); + assert.ok(!buildOptions({ siteSettings: { enable_emoji: false } }).features.emoji, 'emoji disabled'); }); -test("basic cooking", function() { - cooked("hello", "hello
", "surrounds text with paragraphs"); - cooked("**evil**", "evil
", "it bolds text."); - cooked("__bold__", "bold
", "it bolds text."); - cooked("*trout*", "trout
", "it italicizes text."); - cooked("_trout_", "trout
", "it italicizes text."); - cooked("***hello***", "hello
", "it can do bold and italics at once."); - cooked("word_with_underscores", "word_with_underscores
", "it doesn't do intraword italics"); - cooked("common/_special_font_face.html.erb", "common/_special_font_face.html.erb
", "it doesn't intraword with a slash"); - cooked("hello \\*evil\\*", "hello *evil*
", "it supports escaping of asterisks"); - cooked("hello \\_evil\\_", "hello _evil_
", "it supports escaping of italics"); - cooked("brussels sprouts are *awful*.", "brussels sprouts are awful.
", "it doesn't swallow periods."); +QUnit.test("basic cooking", assert => { + assert.cooked("hello", "hello
", "surrounds text with paragraphs"); + assert.cooked("**evil**", "evil
", "it bolds text."); + assert.cooked("__bold__", "bold
", "it bolds text."); + assert.cooked("*trout*", "trout
", "it italicizes text."); + assert.cooked("_trout_", "trout
", "it italicizes text."); + assert.cooked("***hello***", "hello
", "it can do bold and italics at once."); + assert.cooked("word_with_underscores", "word_with_underscores
", "it doesn't do intraword italics"); + assert.cooked("common/_special_font_face.html.erb", "common/_special_font_face.html.erb
", "it doesn't intraword with a slash"); + assert.cooked("hello \\*evil\\*", "hello *evil*
", "it supports escaping of asterisks"); + assert.cooked("hello \\_evil\\_", "hello _evil_
", "it supports escaping of italics"); + assert.cooked("brussels sprouts are *awful*.", "brussels sprouts are awful.
", "it doesn't swallow periods."); }); -test("Nested bold and italics", function() { - cooked("*this is italic **with some bold** inside*", "this is italic with some bold inside
", "it handles nested bold in italics"); +QUnit.test("Nested bold and italics", assert => { + assert.cooked("*this is italic **with some bold** inside*", "this is italic with some bold inside
", "it handles nested bold in italics"); }); -test("Traditional Line Breaks", function() { +QUnit.test("Traditional Line Breaks", assert => { const input = "1\n2\n3"; - cooked(input, "1
2
3
1
2
3
1\n2\n3
"); + assert.equal(result, "1\n2\n3
"); }); -test("Unbalanced underscores", function() { - cooked("[evil_trout][1] hello_\n\n[1]: http://eviltrout.com", "evil_trout hello_
"); +QUnit.test("Unbalanced underscores", assert => { + assert.cooked("[evil_trout][1] hello_\n\n[1]: http://eviltrout.com", "evil_trout hello_
"); }); -test("Line Breaks", function() { - cooked("[] first choice\n[] second choice", +QUnit.test("Line Breaks", assert => { + assert.cooked("[] first choice\n[] second choice", "[] first choice
[] second choice
evil\ntrout", + assert.cooked("
evil\ntrout", "
evil\n\n
trout
", "it doesn't insertevil\ntrout", + assert.cooked("leading
evil\ntrout", "leading
evil\n\n
trout
", "it doesn't inserthello world
", "hello world
", "it doesn't surroundwith paragraphs"); - cooked("hello world", "
hello world
", "it surrounds inline html tags with paragraphs"); - cooked("hello world", "hello world
", "it surrounds inline html tags with paragraphs"); +QUnit.test("Paragraphs for HTML", assert => { + assert.cooked("hello world
", "hello world
", "it doesn't surroundwith paragraphs"); + assert.cooked("hello world", "
hello world
", "it surrounds inline html tags with paragraphs"); + assert.cooked("hello world", "hello world
", "it surrounds inline html tags with paragraphs"); }); -test("Links", function() { +QUnit.test("Links", assert => { - cooked("EvilTrout: http://eviltrout.com", + assert.cooked("EvilTrout: http://eviltrout.com", 'EvilTrout: http://eviltrout.com
', "autolinks a URL"); - cooked("Youtube: http://www.youtube.com/watch?v=1MrpeBRkM5A", + assert.cooked("Youtube: http://www.youtube.com/watch?v=1MrpeBRkM5A", 'Youtube: http://www.youtube.com/watch?v=1MrpeBRkM5A
', "allows links to contain query params"); - cooked("Derpy: http://derp.com?__test=1", + assert.cooked("Derpy: http://derp.com?__test=1", 'Derpy: http://derp.com?__test=1
', "works with double underscores in urls"); - cooked("Derpy: http://derp.com?_test_=1", + assert.cooked("Derpy: http://derp.com?_test_=1", 'Derpy: http://derp.com?_test_=1
', "works with underscores in urls"); - cooked("Atwood: www.codinghorror.com", + assert.cooked("Atwood: www.codinghorror.com", 'Atwood: www.codinghorror.com
', "autolinks something that begins with www"); - cooked("Atwood: http://www.codinghorror.com", + assert.cooked("Atwood: http://www.codinghorror.com", 'Atwood: http://www.codinghorror.com
', "autolinks a URL with http://www"); - cooked("EvilTrout: http://eviltrout.com hello", + assert.cooked("EvilTrout: http://eviltrout.com hello", 'EvilTrout: http://eviltrout.com hello
', "autolinks with trailing text"); - cooked("here is [an example](http://twitter.com)", + assert.cooked("here is [an example](http://twitter.com)", 'here is an example
', "supports markdown style links"); - cooked("Batman: http://en.wikipedia.org/wiki/The_Dark_Knight_(film)", + assert.cooked("Batman: http://en.wikipedia.org/wiki/The_Dark_Knight_(film)", 'Batman: http://en.wikipedia.org/wiki/The_Dark_Knight_(film)
', "autolinks a URL with parentheses (like Wikipedia)"); - cooked("Here's a tweet:\nhttps://twitter.com/evil_trout/status/345954894420787200", + assert.cooked("Here's a tweet:\nhttps://twitter.com/evil_trout/status/345954894420787200", "Here's a tweet:
https://twitter.com/evil_trout/status/345954894420787200
label: description
", "It doesn't accept BBCode as link references"); + assert.cooked("[b]label[/b]: description", "label: description
", "It doesn't accept BBCode as link references"); - cooked("http://discourse.org and http://discourse.org/another_url and http://www.imdb.com/name/nm2225369", + assert.cooked("http://discourse.org and http://discourse.org/another_url and http://www.imdb.com/name/nm2225369", "http://discourse.org and " + "http://discourse.org/another_url and " + "http://www.imdb.com/name/nm2225369
", 'allows multiple links on one line'); - cooked("* [Evil Trout][1]\n [1]: http://eviltrout.com", + assert.cooked("* [Evil Trout][1]\n [1]: http://eviltrout.com", "", "allows markdown link references in a list"); - cooked("User [MOD]: Hello!", + assert.cooked("User [MOD]: Hello!", "User [MOD]: Hello!
", "It does not consider references that are obviously not URLs"); - cooked("http://eviltrout.com", "", "Links within HTML tags"); + assert.cooked("http://eviltrout.com", "", "Links within HTML tags"); - cooked("[http://google.com ... wat](http://discourse.org)", + assert.cooked("[http://google.com ... wat](http://discourse.org)", "", "it supports links within links"); - cooked("[http://google.com](http://discourse.org)", + assert.cooked("[http://google.com](http://discourse.org)", "", "it supports markdown links where the name and link match"); - cooked("[Link](http://www.example.com) (with an outer \"description\")", + assert.cooked("[Link](http://www.example.com) (with an outer \"description\")", "Link (with an outer \"description\")
", "it doesn't consume closing parens as part of the url"); - cooked("A link inside parentheses (http://www.example.com)", + assert.cooked("A link inside parentheses (http://www.example.com)", "A link inside parentheses (http://www.example.com)
", "it auto-links a url within parentheses"); - cooked("[ul][1]\n\n[1]: http://eviltrout.com", + assert.cooked("[ul][1]\n\n[1]: http://eviltrout.com", "", "it can use `ul` as a link name"); }); -test("simple quotes", function() { - cooked("> nice!", "", "it supports simple quotes"); - cooked(" > nice!", "nice!
", "it allows quotes with preceding spaces"); - cooked("> level 1\n> > level 2", +QUnit.test("simple quotes", assert => { + assert.cooked("> nice!", "nice!
", "it supports simple quotes"); + assert.cooked(" > nice!", "nice!
", "it allows quotes with preceding spaces"); + assert.cooked("> level 1\n> > level 2", "nice!
", "it allows nesting of blockquotes"); - cooked("> level 1\n> > level 2", + assert.cooked("> level 1\n> > level 2", "level 1
level 2
", "it allows nesting of blockquotes with spaces"); - cooked("- hello\n\n > world\n > eviltrout", + assert.cooked("- hello\n\n > world\n > eviltrout", "level 1
level 2
", "it allows quotes within a list."); - cooked("-world
eviltrout
eviltrout
", + assert.cooked("-eviltrout
", "eviltrout
", "allow multiple spaces to indent"); + assert.cooked(" > indent 1\n > indent 2", "indent 1
indent 2
", "allow multiple spaces to indent"); }); -test("Quotes", function() { +QUnit.test("Quotes", assert => { - cookedOptions("[quote=\"eviltrout, post: 1\"]\na quote\n\nsecond line\n\nthird line[/quote]", + assert.cookedOptions("[quote=\"eviltrout, post: 1\"]\na quote\n\nsecond line\n\nthird line[/quote]", { topicId: 2 }, "", "works with multiple lines"); - cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2", + assert.cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2", { topicId: 2, lookupAvatar: function(name) { return "" + name; }, sanitize: true }, "indent 1
indent 2
1
\n\n\n\n2
", "handles quotes properly"); - cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2", + assert.cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2", { topicId: 2, lookupAvatar: function() { } }, "1
\n\n\n\n2
", "includes no avatar if none is found"); - cooked(`[quote]\na\n\n[quote]\nb\n[/quote]\n[/quote]`, + assert.cooked(`[quote]\na\n\n[quote]\nb\n[/quote]\n[/quote]`, "", "handles nested quotes properly"); }); -test("Mentions", function() { +QUnit.test("Mentions", assert => { const alwaysTrue = { mentionLookup: (function() { return "user"; }) }; - cookedOptions("Hello @sam", alwaysTrue, + assert.cookedOptions("Hello @sam", alwaysTrue, "Hello @sam
", "translates mentions to links"); - cooked("[@codinghorror](https://twitter.com/codinghorror)", + assert.cooked("[@codinghorror](https://twitter.com/codinghorror)", "", "it doesn't do mentions within links"); - cookedOptions("[@codinghorror](https://twitter.com/codinghorror)", alwaysTrue, + assert.cookedOptions("[@codinghorror](https://twitter.com/codinghorror)", alwaysTrue, "", "it doesn't do link mentions within links"); - cooked("Hello @EvilTrout", + assert.cooked("Hello @EvilTrout", "Hello @EvilTrout
", "adds a mention class"); - cooked("robin@email.host", + assert.cooked("robin@email.host", "robin@email.host
", "won't add mention class to an email address"); - cooked("hanzo55@yahoo.com", + assert.cooked("hanzo55@yahoo.com", "hanzo55@yahoo.com
", "won't be affected by email addresses that have a number before the @ symbol"); - cooked("@EvilTrout yo", + assert.cooked("@EvilTrout yo", "@EvilTrout yo
", "it handles mentions at the beginning of a string"); - cooked("yo\n@EvilTrout", + assert.cooked("yo\n@EvilTrout", "yo
@EvilTrout
evil
@EvilTrout trout
blocks");
- cooked("```\na @test\n```",
+ assert.cooked("```\na @test\n```",
"a @test
",
"should not do mentions within a code block.");
- cooked("> foo bar baz @eviltrout",
+ assert.cooked("> foo bar baz @eviltrout",
"foo bar baz @eviltrout
",
"handles mentions in simple quotes");
- cooked("> foo bar baz @eviltrout ohmagerd\nlook at this",
+ assert.cooked("> foo bar baz @eviltrout ohmagerd\nlook at this",
"foo bar baz @eviltrout ohmagerd
look at this
",
"does mentions properly with trailing text within a simple quote");
- cooked("`code` is okay before @mention",
+ assert.cooked("`code` is okay before @mention",
"code
is okay before @mention
",
"Does not mention in an inline code block");
- cooked("@mention is okay before `code`",
+ assert.cooked("@mention is okay before `code`",
"@mention is okay before code
",
"Does not mention in an inline code block");
- cooked("don't `@mention`",
+ assert.cooked("don't `@mention`",
"don't @mention
",
"Does not mention in an inline code block");
- cooked("Yes `@this` should be code @eviltrout",
+ assert.cooked("Yes `@this` should be code @eviltrout",
"Yes @this
should be code @eviltrout
",
"Does not mention in an inline code block");
- cooked("@eviltrout and `@eviltrout`",
+ assert.cooked("@eviltrout and `@eviltrout`",
"@eviltrout and @eviltrout
",
"you can have a mention in an inline code block following a real mention.");
- cooked("1. this is a list\n\n2. this is an @eviltrout mention\n",
+ assert.cooked("1. this is a list\n\n2. this is an @eviltrout mention\n",
"this is a list
this is an @eviltrout mention
",
"it mentions properly in a list.");
- cooked("Hello @foo/@bar",
+ assert.cooked("Hello @foo/@bar",
"Hello @foo/@bar
",
"handles mentions separated by a slash.");
- cookedOptions("@eviltrout", alwaysTrue,
+ assert.cookedOptions("@eviltrout", alwaysTrue,
"",
"it doesn't onebox mentions");
- cookedOptions("a @sam c", alwaysTrue,
+ assert.cookedOptions("a @sam c", alwaysTrue,
"a @sam c
",
"it allows mentions within HTML tags");
});
-test("Category hashtags", () => {
+QUnit.test("Category hashtags", assert => {
const alwaysTrue = { categoryHashtagLookup: (function() { return ["http://test.discourse.org/category-hashtag", "category-hashtag"]; }) };
- cookedOptions("Check out #category-hashtag", alwaysTrue,
+ assert.cookedOptions("Check out #category-hashtag", alwaysTrue,
"Check out #category-hashtag
",
"it translates category hashtag into links");
- cooked("Check out #category-hashtag",
+ assert.cooked("Check out #category-hashtag",
"Check out #category-hashtag
",
"it does not translate category hashtag into links if it is not a valid category hashtag");
- cookedOptions("[#category-hashtag](http://www.test.com)", alwaysTrue,
+ assert.cookedOptions("[#category-hashtag](http://www.test.com)", alwaysTrue,
"",
"it does not translate category hashtag within links");
- cooked("```\n# #category-hashtag\n```",
+ assert.cooked("```\n# #category-hashtag\n```",
"# #category-hashtag
",
"it does not translate category hashtags to links in code blocks");
- cooked("># #category-hashtag\n",
+ assert.cooked("># #category-hashtag\n",
"#category-hashtag
",
"it handles category hashtags in simple quotes");
- cooked("# #category-hashtag",
+ assert.cooked("# #category-hashtag",
"#category-hashtag
",
"it works within ATX-style headers");
- cooked("don't `#category-hashtag`",
+ assert.cooked("don't `#category-hashtag`",
"don't #category-hashtag
",
"it does not mention in an inline code block");
- cooked("test #hashtag1/#hashtag2",
+ assert.cooked("test #hashtag1/#hashtag2",
"test #hashtag1/#hashtag2
",
"it does not convert category hashtag not bounded by spaces");
- cooked("#category-hashtag",
+ assert.cooked("#category-hashtag",
"#category-hashtag
",
"it works between HTML tags");
});
-test("Heading", function() {
- cooked("**Bold**\n----------", "Bold
", "It will bold the heading");
+QUnit.test("Heading", assert => {
+ assert.cooked("**Bold**\n----------", "Bold
", "It will bold the heading");
});
-test("bold and italics", function() {
- cooked("a \"**hello**\"", "a \"hello\"
", "bolds in quotes");
- cooked("(**hello**)", "(hello)
", "bolds in parens");
- cooked("**hello**\nworld", "hello
world
", "allows newline after bold");
- cooked("**hello**\n**world**", "hello
world
", "newline between two bolds");
- cooked("**a*_b**", "a*_b
", "allows for characters within bold");
- cooked("** hello**", "** hello**
", "does not bold on a space boundary");
- cooked("**hello **", "**hello **
", "does not bold on a space boundary");
- cooked("你**hello**", "你**hello**
", "does not bold chinese intra word");
- cooked("**你hello**", "你hello
", "allows bolded chinese");
+QUnit.test("bold and italics", assert => {
+ assert.cooked("a \"**hello**\"", "a \"hello\"
", "bolds in quotes");
+ assert.cooked("(**hello**)", "(hello)
", "bolds in parens");
+ assert.cooked("**hello**\nworld", "hello
world
", "allows newline after bold");
+ assert.cooked("**hello**\n**world**", "hello
world
", "newline between two bolds");
+ assert.cooked("**a*_b**", "a*_b
", "allows for characters within bold");
+ assert.cooked("** hello**", "** hello**
", "does not bold on a space boundary");
+ assert.cooked("**hello **", "**hello **
", "does not bold on a space boundary");
+ assert.cooked("你**hello**", "你**hello**
", "does not bold chinese intra word");
+ assert.cooked("**你hello**", "你hello
", "allows bolded chinese");
});
-test("Escaping", function() {
- cooked("*\\*laughs\\**", "*laughs*
", "allows escaping strong");
- cooked("*\\_laughs\\_*", "_laughs_
", "allows escaping em");
+QUnit.test("Escaping", assert => {
+ assert.cooked("*\\*laughs\\**", "*laughs*
", "allows escaping strong");
+ assert.cooked("*\\_laughs\\_*", "_laughs_
", "allows escaping em");
});
-test("New Lines", function() {
+QUnit.test("New Lines", assert => {
// Note: This behavior was discussed and we determined it does not make sense to do this
// unless you're using traditional line breaks
- cooked("_abc\ndef_", "_abc
def_
", "it does not allow markup to span new lines");
- cooked("_abc\n\ndef_", "_abc
\n\ndef_
", "it does not allow markup to span new paragraphs");
+ assert.cooked("_abc\ndef_", "_abc
def_
", "it does not allow markup to span new lines");
+ assert.cooked("_abc\n\ndef_", "_abc
\n\ndef_
", "it does not allow markup to span new paragraphs");
});
-test("Oneboxing", function() {
+QUnit.test("Oneboxing", assert => {
function matches(input, regexp) {
return new PrettyText(defaultOpts).cook(input).match(regexp);
};
- ok(!matches("- http://www.textfiles.com/bbs/MINDVOX/FORUMS/ethics\n\n- http://drupal.org", /onebox/),
+ assert.ok(!matches("- http://www.textfiles.com/bbs/MINDVOX/FORUMS/ethics\n\n- http://drupal.org", /onebox/),
"doesn't onebox a link within a list");
- ok(matches("http://test.com", /onebox/), "adds a onebox class to a link on its own line");
- ok(matches("http://test.com\nhttp://test2.com", /onebox[\s\S]+onebox/m), "supports multiple links");
- ok(!matches("http://test.com bob", /onebox/), "doesn't onebox links that have trailing text");
+ assert.ok(matches("http://test.com", /onebox/), "adds a onebox class to a link on its own line");
+ assert.ok(matches("http://test.com\nhttp://test2.com", /onebox[\s\S]+onebox/m), "supports multiple links");
+ assert.ok(!matches("http://test.com bob", /onebox/), "doesn't onebox links that have trailing text");
- ok(!matches("[Tom Cruise](http://www.tomcruise.com/)", "onebox"), "Markdown links with labels are not oneboxed");
- ok(matches("[http://www.tomcruise.com/](http://www.tomcruise.com/)",
+ assert.ok(!matches("[Tom Cruise](http://www.tomcruise.com/)", "onebox"), "Markdown links with labels are not oneboxed");
+ assert.ok(matches("[http://www.tomcruise.com/](http://www.tomcruise.com/)",
"onebox"),
"Markdown links where the label is the same as the url are oneboxed");
- cooked("http://en.wikipedia.org/wiki/Homicide:_Life_on_the_Street",
+ assert.cooked("http://en.wikipedia.org/wiki/Homicide:_Life_on_the_Street",
"http://en.wikipedia.org/wiki/Homicide:_Life_on_the_Street
",
"works with links that have underscores in them");
});
-test("links with full urls", function() {
- cooked("[http://eviltrout.com][1] is a url\n\n[1]: http://eviltrout.com",
+QUnit.test("links with full urls", assert => {
+ assert.cooked("[http://eviltrout.com][1] is a url\n\n[1]: http://eviltrout.com",
"http://eviltrout.com is a url
",
"it supports links that are full URLs");
});
-test("Code Blocks", function() {
+QUnit.test("Code Blocks", assert => {
- cooked("\nhello\n
\n",
+ assert.cooked("\nhello\n
\n",
"hello
",
"pre blocks don't include extra lines");
- cooked("```\na\nb\nc\n\nd\n```",
+ assert.cooked("```\na\nb\nc\n\nd\n```",
"a\nb\nc\n\nd
",
"it treats new lines properly");
- cooked("```\ntest\n```",
+ assert.cooked("```\ntest\n```",
"test
",
"it supports basic code blocks");
- cooked("```json\n{hello: 'world'}\n```\ntrailing",
+ assert.cooked("```json\n{hello: 'world'}\n```\ntrailing",
"{hello: 'world'}
\n\ntrailing
",
"It does not truncate text after a code block.");
- cooked("```json\nline 1\n\nline 2\n\n\nline3\n```",
+ assert.cooked("```json\nline 1\n\nline 2\n\n\nline3\n```",
"line 1\n\nline 2\n\n\nline3
",
"it maintains new lines inside a code block.");
- cooked("hello\nworld\n```json\nline 1\n\nline 2\n\n\nline3\n```",
+ assert.cooked("hello\nworld\n```json\nline 1\n\nline 2\n\n\nline3\n```",
"hello
world
\n\nline 1\n\nline 2\n\n\nline3
",
"it maintains new lines inside a code block with leading content.");
- cooked("```ruby\nhello \n```",
+ assert.cooked("```ruby\nhello \n```",
"<header>hello</header>
",
"it escapes code in the code block");
- cooked("```text\ntext\n```",
+ assert.cooked("```text\ntext\n```",
"text
",
"handles text by adding nohighlight");
- cooked("```ruby\n# cool\n```",
+ assert.cooked("```ruby\n# cool\n```",
"# cool
",
"it supports changing the language");
- cooked(" ```\n hello\n ```",
+ assert.cooked(" ```\n hello\n ```",
"```\nhello\n```
",
"only detect ``` at the beginning of lines");
- cooked("```ruby\ndef self.parse(text)\n\n text\nend\n```",
+ assert.cooked("```ruby\ndef self.parse(text)\n\n text\nend\n```",
"def self.parse(text)\n\n text\nend
",
"it allows leading spaces on lines in a code block.");
- cooked("```ruby\nhello `eviltrout`\n```",
+ assert.cooked("```ruby\nhello `eviltrout`\n```",
"hello `eviltrout`
",
"it allows code with backticks in it");
- cooked("```eviltrout\nhello\n```",
+ assert.cooked("```eviltrout\nhello\n```",
"hello
",
"it doesn't not whitelist all classes");
- cooked("```\n[quote=\"sam, post:1, topic:9441, full:true\"]This is `` a bug.[/quote]\n```",
+ assert.cooked("```\n[quote=\"sam, post:1, topic:9441, full:true\"]This is `` a bug.[/quote]\n```",
"[quote="sam, post:1, topic:9441, full:true"]This is `<not>` a bug.[/quote]
",
"it allows code with backticks in it");
- cooked(" hello\ntest
",
+ assert.cooked(" hello\ntest
",
"hello
\n\ntest
",
"it allows an indented code block to by followed by a ``");
- cooked("``` foo bar ```",
+ assert.cooked("``` foo bar ```",
"foo bar
",
"it tolerates misuse of code block tags as inline code");
- cooked("```\nline1\n```\n```\nline2\n\nline3\n```",
+ assert.cooked("```\nline1\n```\n```\nline2\n\nline3\n```",
"line1
\n\nline2\n\nline3
",
"it does not consume next block's trailing newlines");
- cooked(" test
",
+ assert.cooked(" test
",
"<pre>test</pre>
",
"it does not parse other block types in markdown code blocks");
- cooked(" [quote]test[/quote]",
+ assert.cooked(" [quote]test[/quote]",
"[quote]test[/quote]
",
"it does not parse other block types in markdown code blocks");
- cooked("## a\nb\n```\nc\n```",
+ assert.cooked("## a\nb\n```\nc\n```",
"a
\n\nc
",
"it handles headings with code blocks after them.");
});
-test("URLs in BBCode tags", function() {
+QUnit.test("URLs in BBCode tags", assert => {
- cooked("[img]http://eviltrout.com/eviltrout.png[/img][img]http://samsaffron.com/samsaffron.png[/img]",
+ assert.cooked("[img]http://eviltrout.com/eviltrout.png[/img][img]http://samsaffron.com/samsaffron.png[/img]",
"",
"images are properly parsed");
- cooked("[url]http://discourse.org[/url]",
+ assert.cooked("[url]http://discourse.org[/url]",
"",
"links are properly parsed");
- cooked("[url=http://discourse.org]discourse[/url]",
+ assert.cooked("[url=http://discourse.org]discourse[/url]",
"",
"named links are properly parsed");
});
-test("images", function() {
- cooked("[![folksy logo](http://folksy.com/images/folksy-colour.png)](http://folksy.com/)",
+QUnit.test("images", assert => {
+ assert.cooked("[![folksy logo](http://folksy.com/images/folksy-colour.png)](http://folksy.com/)",
"",
"It allows images with links around them");
- cooked("",
+ assert.cooked("",
"",
"It allows data images");
});
-test("censoring", function() {
- cooked("aw shucks, golly gee whiz.",
+QUnit.test("censoring", assert => {
+ assert.cooked("aw shucks, golly gee whiz.",
"aw ■■■■■■, golly gee ■■■■.
",
"it censors words in the Site Settings");
- cooked("you are a whizzard! I love cheesewhiz. Whiz.",
+ assert.cooked("you are a whizzard! I love cheesewhiz. Whiz.",
"you are a whizzard! I love cheesewhiz. ■■■■.
",
"it doesn't censor words unless they have boundaries.");
- cooked("you are a whizzer! I love cheesewhiz. Whiz.",
+ assert.cooked("you are a whizzer! I love cheesewhiz. Whiz.",
"you are a ■■■■■■■! I love cheesewhiz. ■■■■.
",
"it censors words even if previous partial matches exist.");
- cooked("The link still works. [whiz](http://www.whiz.com)",
+ assert.cooked("The link still works. [whiz](http://www.whiz.com)",
"The link still works. ■■■■
",
"it won't break links by censoring them.");
- cooked("Call techapj the computer whiz at 555-555-1234 for free help.",
+ assert.cooked("Call techapj the computer whiz at 555-555-1234 for free help.",
"Call ■■■■■■■ the computer ■■■■ at 555-■■■■■■■■ for free help.
",
"uses both censored words and patterns from site settings");
- cooked("I have a pen, I have an a**le",
+ assert.cooked("I have a pen, I have an a**le",
"I have a pen, I have an ■■■■■
",
"it escapes regexp chars");
});
-test("code blocks/spans hoisting", function() {
- cooked("```\n\n some code\n```",
+QUnit.test("code blocks/spans hoisting", assert => {
+ assert.cooked("```\n\n some code\n```",
" some code
",
"it works when nesting standard markdown code blocks within a fenced code block");
- cooked("`$&`",
+ assert.cooked("`$&`",
"$&
",
"it works even when hoisting special replacement patterns");
});
-test('basic bbcode', function() {
- cookedPara("[b]strong[/b]", "strong", "bolds text");
- cookedPara("[i]emphasis[/i]", "emphasis", "italics text");
- cookedPara("[u]underlined[/u]", "underlined", "underlines text");
- cookedPara("[s]strikethrough[/s]", "strikethrough", "strikes-through text");
- cookedPara("[img]http://eviltrout.com/eviltrout.png[/img]", "", "links images");
- cookedPara("[email]eviltrout@mailinator.com[/email]", "eviltrout@mailinator.com", "supports [email] without a title");
- cookedPara("[b]evil [i]trout[/i][/b]",
+QUnit.test('basic bbcode', assert => {
+ assert.cookedPara("[b]strong[/b]", "strong", "bolds text");
+ assert.cookedPara("[i]emphasis[/i]", "emphasis", "italics text");
+ assert.cookedPara("[u]underlined[/u]", "underlined", "underlines text");
+ assert.cookedPara("[s]strikethrough[/s]", "strikethrough", "strikes-through text");
+ assert.cookedPara("[img]http://eviltrout.com/eviltrout.png[/img]", "", "links images");
+ assert.cookedPara("[email]eviltrout@mailinator.com[/email]", "eviltrout@mailinator.com", "supports [email] without a title");
+ assert.cookedPara("[b]evil [i]trout[/i][/b]",
"evil trout",
"allows embedding of tags");
- cookedPara("[EMAIL]eviltrout@mailinator.com[/EMAIL]", "eviltrout@mailinator.com", "supports upper case bbcode");
- cookedPara("[b]strong [b]stronger[/b][/b]", "strong stronger", "accepts nested bbcode tags");
+ assert.cookedPara("[EMAIL]eviltrout@mailinator.com[/EMAIL]", "eviltrout@mailinator.com", "supports upper case bbcode");
+ assert.cookedPara("[b]strong [b]stronger[/b][/b]", "strong stronger", "accepts nested bbcode tags");
});
-test('urls', function() {
- cookedPara("[url]not a url[/url]", "not a url", "supports [url] that isn't a url");
- cookedPara("[url]abc.com[/url]", "abc.com", "no error when a url has no protocol and begins with a");
- cookedPara("[url]http://bettercallsaul.com[/url]", "http://bettercallsaul.com", "supports [url] without parameter");
- cookedPara("[url=http://example.com]example[/url]", "example", "supports [url] with given href");
- cookedPara("[url=http://www.example.com][img]http://example.com/logo.png[/img][/url]",
+QUnit.test('urls', assert => {
+ assert.cookedPara("[url]not a url[/url]", "not a url", "supports [url] that isn't a url");
+ assert.cookedPara("[url]abc.com[/url]", "abc.com", "no error when a url has no protocol and begins with a");
+ assert.cookedPara("[url]http://bettercallsaul.com[/url]", "http://bettercallsaul.com", "supports [url] without parameter");
+ assert.cookedPara("[url=http://example.com]example[/url]", "example", "supports [url] with given href");
+ assert.cookedPara("[url=http://www.example.com][img]http://example.com/logo.png[/img][/url]",
"",
"supports [url] with an embedded [img]");
});
-test('invalid bbcode', function() {
+QUnit.test('invalid bbcode', assert => {
const result = new PrettyText({ lookupAvatar: false }).cook("[code]I am not closed\n\nThis text exists.");
- equal(result, "[code]I am not closed
\n\nThis text exists.
", "does not raise an error with an open bbcode tag.");
+ assert.equal(result, "[code]I am not closed
\n\nThis text exists.
", "does not raise an error with an open bbcode tag.");
});
-test('code', function() {
- cookedPara("[code]\nx++\n[/code]", "x++
", "makes code into pre");
- cookedPara("[code]\nx++\ny++\nz++\n[/code]", "x++\ny++\nz++
", "makes code into pre");
- cookedPara("[code]abc\n#def\n[/code]", 'abc\n#def
', 'it handles headings in a [code] block');
- cookedPara("[code]\n s[/code]",
+QUnit.test('code', assert => {
+ assert.cookedPara("[code]\nx++\n[/code]", "x++
", "makes code into pre");
+ assert.cookedPara("[code]\nx++\ny++\nz++\n[/code]", "x++\ny++\nz++
", "makes code into pre");
+ assert.cookedPara("[code]abc\n#def\n[/code]", 'abc\n#def
', 'it handles headings in a [code] block');
+ assert.cookedPara("[code]\n s[/code]",
" s
",
"it doesn't trim leading whitespace");
});
-test('lists', function() {
- cookedPara("[ul][li]option one[/li][/ul]", "- option one
", "creates an ul");
- cookedPara("[ol][li]option one[/li][/ol]", "- option one
", "creates an ol");
- cookedPara("[ul]\n[li]option one[/li]\n[li]option two[/li]\n[/ul]", "- option one
- option two
", "suppresses empty lines in lists");
+QUnit.test('lists', assert => {
+ assert.cookedPara("[ul][li]option one[/li][/ul]", "- option one
", "creates an ul");
+ assert.cookedPara("[ol][li]option one[/li][/ol]", "- option one
", "creates an ol");
+ assert.cookedPara("[ul]\n[li]option one[/li]\n[li]option two[/li]\n[/ul]", "- option one
- option two
", "suppresses empty lines in lists");
});
-test('tags with arguments', function() {
- cookedPara("[url=http://bettercallsaul.com]better call![/url]", "better call!", "supports [url] with a title");
- cookedPara("[email=eviltrout@mailinator.com]evil trout[/email]", "evil trout", "supports [email] with a title");
- cookedPara("[u][i]abc[/i][/u]", "abc", "can nest tags");
- cookedPara("[b]first[/b] [b]second[/b]", "first second", "can bold two things on the same line");
+QUnit.test('tags with arguments', assert => {
+ assert.cookedPara("[url=http://bettercallsaul.com]better call![/url]", "better call!", "supports [url] with a title");
+ assert.cookedPara("[email=eviltrout@mailinator.com]evil trout[/email]", "evil trout", "supports [email] with a title");
+ assert.cookedPara("[u][i]abc[/i][/u]", "abc", "can nest tags");
+ assert.cookedPara("[b]first[/b] [b]second[/b]", "first second", "can bold two things on the same line");
});
-test("quotes", function() {
+QUnit.test("quotes", assert => {
const post = Post.create({
cooked: "lorem ipsum
",
username: "eviltrout",
@@ -621,7 +633,7 @@ test("quotes", function() {
});
function formatQuote(val, expected, text) {
- equal(Quote.build(post, val), expected, text);
+ assert.equal(Quote.build(post, val), expected, text);
};
formatQuote(undefined, "", "empty string for undefined content");
@@ -646,80 +658,80 @@ test("quotes", function() {
"[quote=\"eviltrout, post:1, topic:2\"]\nthis is <not> a bug\n[/quote]\n\n",
"it escapes the contents of the quote");
- cookedPara("[quote]test[/quote]",
+ assert.cookedPara("[quote]test[/quote]",
"test
",
"it supports quotes without params");
- cookedPara("[quote]\n*test*\n[/quote]",
+ assert.cookedPara("[quote]\n*test*\n[/quote]",
"test
",
"it doesn't insert a new line for italics");
- cookedPara("[quote=,script='a'>
hello
hello
hello
hello
hello
", "it sanitizes while cooking"); cooked("disney reddit", @@ -32,11 +32,11 @@ test("sanitize", function() { "", "it allows iframe to OpenStreetMap"); - equal(pt.sanitize(""), "hullo"); - equal(pt.sanitize(""), "press me!"); - equal(pt.sanitize(""), "draw me!"); - equal(pt.sanitize("