Upgrade QUnit to latest version

This commit is contained in:
Robin Ward
2017-06-14 13:57:58 -04:00
parent 8ae445766f
commit cc525b1a8d
145 changed files with 7569 additions and 6763 deletions

View File

@@ -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="<b>wat</b>"}}',
test(assert) {
expect(1);
assert.expect(1);
assert.ok(this.$('.ace_editor').length, 'it renders the ace editor');
}
});

View File

@@ -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']);
},

View File

@@ -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 => {

View File

@@ -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);
});

View File

@@ -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");
});

View File

@@ -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);
},

View File

@@ -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']);
},