Skip to content

Commit 279abaa

Browse files
committed
Assert: Remove deprecation warning from assert.push()
Cherry-picks eaa0dbe (3.0.0-dev) > This is still used by numerous plugins that have no other reason to > break [in QUnit 3.0.0]. It's trivial to map to the new method > and requires no maintenance or increased complexity, and we're not > under any size constraints. Let's keep it around. Cherry-picks 2b0ae95 (3.0.0-dev) > Improve assert.pushResult() tests.
1 parent 98d7942 commit 279abaa

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

src/assert.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import dump from './dump';
22
import equiv from './equiv';
3-
import Logger from './logger';
43

54
import config from './core/config';
65
import { objectType, objectValues, objectValuesSubset, errorString } from './core/utilities';
@@ -90,12 +89,8 @@ class Assert {
9089
});
9190
}
9291

93-
// Exports test.push() to the user API
9492
// Alias of pushResult.
9593
push (result, actual, expected, message, negative) {
96-
Logger.warn('assert.push is deprecated and will be removed in QUnit 3.0.' +
97-
' Please use assert.pushResult instead. https://qunitjs.com/api/assert/pushResult');
98-
9994
const currentAssert = this instanceof Assert ? this : config.current.assert;
10095
return currentAssert.pushResult({
10196
result,
@@ -106,6 +101,7 @@ class Assert {
106101
});
107102
}
108103

104+
// Public API to internal test.pushResult()
109105
pushResult (resultInfo) {
110106
// Destructure of resultInfo = { result, actual, expected, message, negative }
111107
let assert = this;

test/main/test.js

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,39 @@ QUnit.module('test', function () {
187187
this.push(true, value, expected, message, false);
188188
};
189189

190-
QUnit.test('mod2', function (assert) {
191-
assert.mod2(2, 0, '2 % 2 == 0');
192-
assert.mod2(3, 1, '3 % 2 == 1');
190+
QUnit.test('assert.pushResult()', function (assert) {
191+
var detail;
192+
QUnit.log(function (data) {
193+
detail = data;
194+
});
195+
196+
assert.mod2(2, 0, 'two');
197+
assert.mod2(3, 1, 'three');
198+
199+
assert.propContains(detail, {
200+
result: true,
201+
actual: 1,
202+
expected: 1,
203+
message: 'three',
204+
negative: false
205+
});
193206
});
194207

195-
QUnit.test('testForPush', function (assert) {
196-
QUnit.log(function (detail) {
197-
if (detail.message === 'should be call pushResult') {
198-
/* eslint-disable qunit/no-conditional-assertions */
199-
assert.equal(detail.result, true);
200-
assert.equal(detail.actual, 1);
201-
assert.equal(detail.expected, 1);
202-
assert.equal(detail.message, 'should be call pushResult');
203-
assert.equal(detail.negative, false);
204-
/* eslint-enable */
205-
}
208+
QUnit.test('assert.push()', function (assert) {
209+
var detail;
210+
QUnit.log(function (data) {
211+
detail = data;
212+
});
213+
214+
assert.testForPush(10, 20, 'hello');
215+
216+
assert.propContains(detail, {
217+
result: true,
218+
actual: 10,
219+
expected: 20,
220+
message: 'hello',
221+
negative: false
206222
});
207-
assert.testForPush(1, 1, 'should be call pushResult');
208223
});
209224

210225
QUnit.module('aliases');

0 commit comments

Comments
 (0)