mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Upgrade QUnit to latest version
This commit is contained in:
parent
8ae445766f
commit
cc525b1a8d
145 changed files with 7569 additions and 6763 deletions
|
@ -1,7 +1,6 @@
|
|||
import { blank } from 'helpers/qunit-helpers';
|
||||
import Report from 'admin/models/report';
|
||||
|
||||
module("Report");
|
||||
QUnit.module("Report");
|
||||
|
||||
function reportWithData(data) {
|
||||
return Report.create({
|
||||
|
@ -12,53 +11,53 @@ function reportWithData(data) {
|
|||
});
|
||||
}
|
||||
|
||||
test("counts", function() {
|
||||
QUnit.test("counts", assert => {
|
||||
var report = reportWithData([5, 4, 3, 2, 1, 100, 99, 98, 1000]);
|
||||
|
||||
equal(report.get('todayCount'), 5);
|
||||
equal(report.get('yesterdayCount'), 4);
|
||||
equal(report.valueFor(2, 4), 6, "adds the values for the given range of days, inclusive");
|
||||
equal(report.get('lastSevenDaysCount'), 307, "sums 7 days excluding today");
|
||||
assert.equal(report.get('todayCount'), 5);
|
||||
assert.equal(report.get('yesterdayCount'), 4);
|
||||
assert.equal(report.valueFor(2, 4), 6, "adds the values for the given range of days, inclusive");
|
||||
assert.equal(report.get('lastSevenDaysCount'), 307, "sums 7 days excluding today");
|
||||
|
||||
report.set("method", "average");
|
||||
equal(report.valueFor(2, 4), 2, "averages the values for the given range of days");
|
||||
assert.equal(report.valueFor(2, 4), 2, "averages the values for the given range of days");
|
||||
});
|
||||
|
||||
test("percentChangeString", function() {
|
||||
QUnit.test("percentChangeString", assert => {
|
||||
var report = reportWithData([]);
|
||||
|
||||
equal(report.percentChangeString(8, 5), "+60%", "value increased");
|
||||
equal(report.percentChangeString(2, 8), "-75%", "value decreased");
|
||||
equal(report.percentChangeString(8, 8), "0%", "value unchanged");
|
||||
blank(report.percentChangeString(8, 0), "returns blank when previous value was 0");
|
||||
equal(report.percentChangeString(0, 8), "-100%", "yesterday was 0");
|
||||
blank(report.percentChangeString(0, 0), "returns blank when both were 0");
|
||||
assert.equal(report.percentChangeString(8, 5), "+60%", "value increased");
|
||||
assert.equal(report.percentChangeString(2, 8), "-75%", "value decreased");
|
||||
assert.equal(report.percentChangeString(8, 8), "0%", "value unchanged");
|
||||
assert.blank(report.percentChangeString(8, 0), "returns blank when previous value was 0");
|
||||
assert.equal(report.percentChangeString(0, 8), "-100%", "yesterday was 0");
|
||||
assert.blank(report.percentChangeString(0, 0), "returns blank when both were 0");
|
||||
});
|
||||
|
||||
test("yesterdayCountTitle with valid values", function() {
|
||||
QUnit.test("yesterdayCountTitle with valid values", assert => {
|
||||
var title = reportWithData([6,8,5,2,1]).get('yesterdayCountTitle');
|
||||
ok(title.indexOf('+60%') !== -1);
|
||||
ok(title.match(/Was 5/));
|
||||
assert.ok(title.indexOf('+60%') !== -1);
|
||||
assert.ok(title.match(/Was 5/));
|
||||
});
|
||||
|
||||
test("yesterdayCountTitle when two days ago was 0", function() {
|
||||
QUnit.test("yesterdayCountTitle when two days ago was 0", assert => {
|
||||
var title = reportWithData([6,8,0,2,1]).get('yesterdayCountTitle');
|
||||
equal(title.indexOf('%'), -1);
|
||||
ok(title.match(/Was 0/));
|
||||
assert.equal(title.indexOf('%'), -1);
|
||||
assert.ok(title.match(/Was 0/));
|
||||
});
|
||||
|
||||
|
||||
test("sevenDayCountTitle", function() {
|
||||
QUnit.test("sevenDayCountTitle", assert => {
|
||||
var title = reportWithData([100,1,1,1,1,1,1,1,2,2,2,2,2,2,2,100,100]).get('sevenDayCountTitle');
|
||||
ok(title.match(/-50%/));
|
||||
ok(title.match(/Was 14/));
|
||||
assert.ok(title.match(/-50%/));
|
||||
assert.ok(title.match(/Was 14/));
|
||||
});
|
||||
|
||||
test("thirtyDayCountTitle", function() {
|
||||
QUnit.test("thirtyDayCountTitle", assert => {
|
||||
var report = reportWithData([5,5,5,5]);
|
||||
report.set('prev30Days', 10);
|
||||
var title = report.get('thirtyDayCountTitle');
|
||||
|
||||
ok(title.indexOf('+50%') !== -1);
|
||||
ok(title.match(/Was 10/));
|
||||
});
|
||||
assert.ok(title.indexOf('+50%') !== -1);
|
||||
assert.ok(title.match(/Was 10/));
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue