Upgrade QUnit to latest version
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -10,7 +10,7 @@ moduleFor("controller:poll-ui-builder", "controller:poll-ui-builder", {
|
||||
needs: ['controller:modal']
|
||||
});
|
||||
|
||||
test("isMultiple", function() {
|
||||
test("isMultiple", function(assert) {
|
||||
const controller = this.subject();
|
||||
|
||||
controller.setProperties({
|
||||
@@ -18,31 +18,31 @@ test("isMultiple", function() {
|
||||
pollOptionsCount: 1
|
||||
});
|
||||
|
||||
equal(controller.get("isMultiple"), true, "it should be true");
|
||||
assert.equal(controller.get("isMultiple"), true, "it should be true");
|
||||
|
||||
controller.set("pollOptionsCount", 0);
|
||||
|
||||
equal(controller.get("isMultiple"), false, "it should be false");
|
||||
assert.equal(controller.get("isMultiple"), false, "it should be false");
|
||||
|
||||
controller.setProperties({ pollType: "random", pollOptionsCount: 1 });
|
||||
|
||||
equal(controller.get("isMultiple"), false, "it should be false");
|
||||
assert.equal(controller.get("isMultiple"), false, "it should be false");
|
||||
});
|
||||
|
||||
test("isNumber", function() {
|
||||
test("isNumber", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
|
||||
controller.set("pollType", "random");
|
||||
|
||||
equal(controller.get("isNumber"), false, "it should be false");
|
||||
assert.equal(controller.get("isNumber"), false, "it should be false");
|
||||
|
||||
controller.set("pollType", controller.get("numberPollType"));
|
||||
|
||||
equal(controller.get("isNumber"), true, "it should be true");
|
||||
assert.equal(controller.get("isNumber"), true, "it should be true");
|
||||
});
|
||||
|
||||
test("showMinMax", function() {
|
||||
test("showMinMax", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
|
||||
@@ -51,14 +51,14 @@ test("showMinMax", function() {
|
||||
isMultiple: false
|
||||
});
|
||||
|
||||
equal(controller.get("showMinMax"), true, "it should be true");
|
||||
assert.equal(controller.get("showMinMax"), true, "it should be true");
|
||||
|
||||
controller.setProperties({
|
||||
isNumber: false,
|
||||
isMultiple: true
|
||||
});
|
||||
|
||||
equal(controller.get("showMinMax"), true, "it should be true");
|
||||
assert.equal(controller.get("showMinMax"), true, "it should be true");
|
||||
|
||||
controller.setProperties({
|
||||
isNumber: false,
|
||||
@@ -66,23 +66,23 @@ test("showMinMax", function() {
|
||||
isRegular: true
|
||||
});
|
||||
|
||||
equal(controller.get("showMinMax"), false, "it should be false");
|
||||
assert.equal(controller.get("showMinMax"), false, "it should be false");
|
||||
});
|
||||
|
||||
test("pollOptionsCount", function() {
|
||||
test("pollOptionsCount", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
|
||||
controller.set("pollOptions", "1\n2\n");
|
||||
|
||||
equal(controller.get("pollOptionsCount"), 2, "it should equal 2");
|
||||
assert.equal(controller.get("pollOptionsCount"), 2, "it should equal 2");
|
||||
|
||||
controller.set("pollOptions", "");
|
||||
|
||||
equal(controller.get("pollOptionsCount"), 0, "it should equal 0");
|
||||
assert.equal(controller.get("pollOptionsCount"), 0, "it should equal 0");
|
||||
});
|
||||
|
||||
test("pollMinOptions", function() {
|
||||
test("pollMinOptions", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
|
||||
@@ -91,40 +91,40 @@ test("pollMinOptions", function() {
|
||||
pollOptionsCount: 1
|
||||
});
|
||||
|
||||
deepEqual(controller.get("pollMinOptions"), [{ name: 1, value: 1 }], "it should return the right options");
|
||||
assert.deepEqual(controller.get("pollMinOptions"), [{ name: 1, value: 1 }], "it should return the right options");
|
||||
|
||||
controller.set("pollOptionsCount", 2);
|
||||
|
||||
deepEqual(controller.get("pollMinOptions"), [
|
||||
assert.deepEqual(controller.get("pollMinOptions"), [
|
||||
{ name: 1, value: 1 }, { name: 2, value: 2 }
|
||||
], "it should return the right options");
|
||||
|
||||
controller.set("isNumber", true);
|
||||
controller.siteSettings.poll_maximum_options = 2;
|
||||
|
||||
deepEqual(controller.get("pollMinOptions"), [
|
||||
assert.deepEqual(controller.get("pollMinOptions"), [
|
||||
{ name: 1, value: 1 }, { name: 2, value: 2 }
|
||||
], "it should return the right options");
|
||||
});
|
||||
|
||||
test("pollMaxOptions", function() {
|
||||
test("pollMaxOptions", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
|
||||
controller.setProperties({ isMultiple: true, pollOptionsCount: 1, pollMin: 1 });
|
||||
|
||||
deepEqual(controller.get("pollMaxOptions"), [], "it should return the right options");
|
||||
assert.deepEqual(controller.get("pollMaxOptions"), [], "it should return the right options");
|
||||
|
||||
controller.set("pollOptionsCount", 2);
|
||||
|
||||
deepEqual(controller.get("pollMaxOptions"), [
|
||||
assert.deepEqual(controller.get("pollMaxOptions"), [
|
||||
{ name: 2, value: 2 }
|
||||
], "it should return the right options");
|
||||
|
||||
controller.siteSettings.poll_maximum_options = 3;
|
||||
controller.setProperties({ isMultiple: false, isNumber: true, pollStep: 2, pollMin: 1 });
|
||||
|
||||
deepEqual(controller.get("pollMaxOptions"), [
|
||||
assert.deepEqual(controller.get("pollMaxOptions"), [
|
||||
{ name: 2, value: 2 },
|
||||
{ name: 3, value: 3 },
|
||||
{ name: 4, value: 4 },
|
||||
@@ -133,50 +133,50 @@ test("pollMaxOptions", function() {
|
||||
], "it should return the right options");
|
||||
});
|
||||
|
||||
test("pollStepOptions", function() {
|
||||
test("pollStepOptions", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
controller.siteSettings.poll_maximum_options = 3;
|
||||
|
||||
controller.set("isNumber", false);
|
||||
|
||||
equal(controller.get("pollStepOptions"), null, "is should return null");
|
||||
assert.equal(controller.get("pollStepOptions"), null, "is should return null");
|
||||
|
||||
controller.setProperties({ isNumber: true });
|
||||
|
||||
deepEqual(controller.get("pollStepOptions"), [
|
||||
assert.deepEqual(controller.get("pollStepOptions"), [
|
||||
{ name: 1, value: 1 },
|
||||
{ name: 2, value: 2 },
|
||||
{ name: 3, value: 3 }
|
||||
], "it should return the right options");
|
||||
});
|
||||
|
||||
test("disableInsert", function() {
|
||||
test("disableInsert", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
|
||||
controller.setProperties({ isRegular: true });
|
||||
|
||||
equal(controller.get("disableInsert"), true, "it should be true");
|
||||
assert.equal(controller.get("disableInsert"), true, "it should be true");
|
||||
|
||||
controller.setProperties({ isRegular: true, pollOptionsCount: 2 });
|
||||
|
||||
equal(controller.get("disableInsert"), false, "it should be false");
|
||||
assert.equal(controller.get("disableInsert"), false, "it should be false");
|
||||
|
||||
controller.setProperties({ isNumber: true });
|
||||
|
||||
equal(controller.get("disableInsert"), false, "it should be false");
|
||||
assert.equal(controller.get("disableInsert"), false, "it should be false");
|
||||
|
||||
controller.setProperties({ isNumber: false, pollOptionsCount: 3 });
|
||||
|
||||
equal(controller.get("disableInsert"), false, "it should be false");
|
||||
assert.equal(controller.get("disableInsert"), false, "it should be false");
|
||||
|
||||
controller.setProperties({ isNumber: false, pollOptionsCount: 1 });
|
||||
|
||||
equal(controller.get("disableInsert"), true, "it should be true");
|
||||
assert.equal(controller.get("disableInsert"), true, "it should be true");
|
||||
});
|
||||
|
||||
test("number pollOutput", function() {
|
||||
test("number pollOutput", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
controller.siteSettings.poll_maximum_options = 20;
|
||||
@@ -187,18 +187,18 @@ test("number pollOutput", function() {
|
||||
pollMin: 1
|
||||
});
|
||||
|
||||
equal(controller.get("pollOutput"), "[poll type=number min=1 max=20 step=1]\n[/poll]", "it should return the right output");
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=number min=1 max=20 step=1]\n[/poll]", "it should return the right output");
|
||||
|
||||
controller.set("pollStep", 2);
|
||||
|
||||
equal(controller.get("pollOutput"), "[poll type=number min=1 max=20 step=2]\n[/poll]", "it should return the right output");
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=number min=1 max=20 step=2]\n[/poll]", "it should return the right output");
|
||||
|
||||
controller.set("publicPoll", true);
|
||||
|
||||
equal(controller.get("pollOutput"), "[poll type=number min=1 max=20 step=2 public=true]\n[/poll]", "it should return the right output");
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=number min=1 max=20 step=2 public=true]\n[/poll]", "it should return the right output");
|
||||
});
|
||||
|
||||
test("regular pollOutput", function() {
|
||||
test("regular pollOutput", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
controller.siteSettings.poll_maximum_options = 20;
|
||||
@@ -209,15 +209,15 @@ test("regular pollOutput", function() {
|
||||
pollType: controller.get("regularPollType")
|
||||
});
|
||||
|
||||
equal(controller.get("pollOutput"), "[poll type=regular]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=regular]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
|
||||
controller.set("publicPoll", "true");
|
||||
|
||||
equal(controller.get("pollOutput"), "[poll type=regular public=true]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=regular public=true]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
});
|
||||
|
||||
|
||||
test("multiple pollOutput", function() {
|
||||
test("multiple pollOutput", function(assert) {
|
||||
const controller = this.subject();
|
||||
controller.siteSettings = Discourse.SiteSettings;
|
||||
controller.siteSettings.poll_maximum_options = 20;
|
||||
@@ -229,9 +229,9 @@ test("multiple pollOutput", function() {
|
||||
pollOptions: "\n\n1\n\n2"
|
||||
});
|
||||
|
||||
equal(controller.get("pollOutput"), "[poll type=multiple min=1 max=2]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=multiple min=1 max=2]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
|
||||
controller.set("publicPoll", "true");
|
||||
|
||||
equal(controller.get("pollOutput"), "[poll type=multiple min=1 max=2 public=true]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
assert.equal(controller.get("pollOutput"), "[poll type=multiple min=1 max=2 public=true]\n* 1\n* 2\n[/poll]", "it should return the right output");
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ const template = `{{mount-widget
|
||||
widgetTest('single, not selected', {
|
||||
template,
|
||||
|
||||
setup() {
|
||||
beforeEach() {
|
||||
this.set('option', { id: 'opt-id' });
|
||||
this.set('vote', []);
|
||||
},
|
||||
@@ -21,7 +21,7 @@ widgetTest('single, not selected', {
|
||||
widgetTest('single, selected', {
|
||||
template,
|
||||
|
||||
setup() {
|
||||
beforeEach() {
|
||||
this.set('option', { id: 'opt-id' });
|
||||
this.set('vote', ['opt-id']);
|
||||
},
|
||||
@@ -34,7 +34,7 @@ widgetTest('single, selected', {
|
||||
widgetTest('multi, not selected', {
|
||||
template,
|
||||
|
||||
setup() {
|
||||
beforeEach() {
|
||||
this.setProperties({
|
||||
option: { id: 'opt-id' },
|
||||
isMultiple: true,
|
||||
@@ -50,7 +50,7 @@ widgetTest('multi, not selected', {
|
||||
widgetTest('multi, selected', {
|
||||
template,
|
||||
|
||||
setup() {
|
||||
beforeEach() {
|
||||
this.setProperties({
|
||||
option: { id: 'opt-id' },
|
||||
isMultiple: true,
|
||||
|
||||
@@ -8,7 +8,7 @@ const template = `{{mount-widget
|
||||
widgetTest('options in descending order', {
|
||||
template,
|
||||
|
||||
setup() {
|
||||
beforeEach() {
|
||||
this.set('poll', Ember.Object.create({
|
||||
options: [{ votes: 5 }, { votes: 4 }],
|
||||
voters: 9
|
||||
@@ -24,7 +24,7 @@ widgetTest('options in descending order', {
|
||||
widgetTest('options in ascending order', {
|
||||
template,
|
||||
|
||||
setup() {
|
||||
beforeEach() {
|
||||
this.set('poll', Ember.Object.create({
|
||||
options: [{ votes: 4 }, { votes: 5 }],
|
||||
voters: 9
|
||||
@@ -40,7 +40,7 @@ widgetTest('options in ascending order', {
|
||||
widgetTest('multiple options in descending order', {
|
||||
template,
|
||||
|
||||
setup() {
|
||||
beforeEach() {
|
||||
this.set('isMultiple', true);
|
||||
this.set('poll', Ember.Object.create({
|
||||
type: 'multiple',
|
||||
|
||||
Reference in New Issue
Block a user