mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 22:23:33 +01:00
tests: Disable deprecation warnings when testing deprecated functions
This commit is contained in:
parent
c4f18a9b3a
commit
6beb5dcaf5
2 changed files with 21 additions and 10 deletions
|
@ -101,6 +101,7 @@ const padutils = {
|
||||||
* @param {...*} args - Passed to `console.warn`, with a stack trace appended.
|
* @param {...*} args - Passed to `console.warn`, with a stack trace appended.
|
||||||
*/
|
*/
|
||||||
warnDeprecated: (...args) => {
|
warnDeprecated: (...args) => {
|
||||||
|
if (padutils.warnDeprecated.disabledForTestingOnly) return;
|
||||||
const err = new Error();
|
const err = new Error();
|
||||||
if (Error.captureStackTrace) Error.captureStackTrace(err, padutils.warnDeprecated);
|
if (Error.captureStackTrace) Error.captureStackTrace(err, padutils.warnDeprecated);
|
||||||
err.name = '';
|
err.name = '';
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
const Changeset = require('../../../static/js/Changeset');
|
const Changeset = require('../../../static/js/Changeset');
|
||||||
const AttributePool = require('../../../static/js/AttributePool');
|
const AttributePool = require('../../../static/js/AttributePool');
|
||||||
const {randomMultiline, poolOrArray} = require('../easysync-helper.js');
|
const {randomMultiline, poolOrArray} = require('../easysync-helper.js');
|
||||||
|
const {padutils} = require('../../../static/js/pad_utils');
|
||||||
|
|
||||||
describe('easysync-other', function () {
|
describe('easysync-other', function () {
|
||||||
describe('filter attribute numbers', function () {
|
describe('filter attribute numbers', function () {
|
||||||
|
@ -23,8 +24,12 @@ describe('easysync-other', function () {
|
||||||
const testMakeAttribsString = (testId, pool, opcode, attribs, correctString) => {
|
const testMakeAttribsString = (testId, pool, opcode, attribs, correctString) => {
|
||||||
it(`testMakeAttribsString#${testId}`, async function () {
|
it(`testMakeAttribsString#${testId}`, async function () {
|
||||||
const p = poolOrArray(pool);
|
const p = poolOrArray(pool);
|
||||||
const str = Changeset.makeAttribsString(opcode, attribs, p);
|
padutils.warnDeprecated.disabledForTestingOnly = true;
|
||||||
expect(str).to.equal(correctString);
|
try {
|
||||||
|
expect(Changeset.makeAttribsString(opcode, attribs, p)).to.equal(correctString);
|
||||||
|
} finally {
|
||||||
|
delete padutils.warnDeprecated.disabledForTestingOnly;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,14 +86,19 @@ describe('easysync-other', function () {
|
||||||
|
|
||||||
const stringOp = (str) => Changeset.deserializeOps(str).next().value;
|
const stringOp = (str) => Changeset.deserializeOps(str).next().value;
|
||||||
|
|
||||||
expect(Changeset.opAttributeValue(stringOp('*0*1+1'), 'name', p)).to.equal('david');
|
padutils.warnDeprecated.disabledForTestingOnly = true;
|
||||||
expect(Changeset.opAttributeValue(stringOp('*0+1'), 'name', p)).to.equal('david');
|
try {
|
||||||
expect(Changeset.opAttributeValue(stringOp('*1+1'), 'name', p)).to.equal('');
|
expect(Changeset.opAttributeValue(stringOp('*0*1+1'), 'name', p)).to.equal('david');
|
||||||
expect(Changeset.opAttributeValue(stringOp('+1'), 'name', p)).to.equal('');
|
expect(Changeset.opAttributeValue(stringOp('*0+1'), 'name', p)).to.equal('david');
|
||||||
expect(Changeset.opAttributeValue(stringOp('*0*1+1'), 'color', p)).to.equal('green');
|
expect(Changeset.opAttributeValue(stringOp('*1+1'), 'name', p)).to.equal('');
|
||||||
expect(Changeset.opAttributeValue(stringOp('*1+1'), 'color', p)).to.equal('green');
|
expect(Changeset.opAttributeValue(stringOp('+1'), 'name', p)).to.equal('');
|
||||||
expect(Changeset.opAttributeValue(stringOp('*0+1'), 'color', p)).to.equal('');
|
expect(Changeset.opAttributeValue(stringOp('*0*1+1'), 'color', p)).to.equal('green');
|
||||||
expect(Changeset.opAttributeValue(stringOp('+1'), 'color', p)).to.equal('');
|
expect(Changeset.opAttributeValue(stringOp('*1+1'), 'color', p)).to.equal('green');
|
||||||
|
expect(Changeset.opAttributeValue(stringOp('*0+1'), 'color', p)).to.equal('');
|
||||||
|
expect(Changeset.opAttributeValue(stringOp('+1'), 'color', p)).to.equal('');
|
||||||
|
} finally {
|
||||||
|
delete padutils.warnDeprecated.disabledForTestingOnly;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('applyToAttribution', function () {
|
describe('applyToAttribution', function () {
|
||||||
|
|
Loading…
Reference in a new issue