Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
function formatActual(calls) {
if (calls.length) {
return calls
.map(args => {
return formatArray([!!args[0]].concat(args.slice(1)));
})
.join(', ');
} else {
return '[]';
}
}
const warning = require('warning');
if (!warning.mock) {
throw new Error("toWarn(): Requires `jest.mock('warning')`.");
}
const callsCount = warning.mock.calls.length;
actual();
const calls = warning.mock.calls.slice(callsCount);
// Simple case: no explicit expectation.
if (!expected) {
const warned = calls.filter(args => !args[0]).length;
return {
pass: !!warned,
message: () =>
`Expected ${negative ? 'not ' : ''}to warn but ` +
'`warning` received the following calls: ' +
`${formatActual(calls)}.`,
return calls
.map(args => {
return formatArray([!!args[0]].concat(args.slice(1)));
})
.join(', ');
} else {
return '[]';
}
}
const warning = require('warning');
if (!warning.mock) {
throw new Error("toWarn(): Requires `jest.mock('warning')`.");
}
const callsCount = warning.mock.calls.length;
actual();
const calls = warning.mock.calls.slice(callsCount);
// Simple case: no explicit expectation.
if (!expected) {
const warned = calls.filter(args => !args[0]).length;
return {
pass: !!warned,
message: () =>
`Expected ${negative ? 'not ' : ''}to warn but ` +
'`warning` received the following calls: ' +
`${formatActual(calls)}.`,
};
}
// Custom case: explicit expectation.
}
function formatActual(calls) {
if (calls.length) {
return calls
.map(args => {
return formatArray([!!args[0]].concat(args.slice(1)));
})
.join(', ');
} else {
return '[]';
}
}
const warning = require('warning');
if (!warning.mock) {
throw new Error("toWarn(): Requires `jest.mock('warning')`.");
}
const callsCount = warning.mock.calls.length;
actual();
const calls = warning.mock.calls.slice(callsCount);
// Simple case: no explicit expectation.
if (!expected) {
const warned = calls.filter(args => !args[0]).length;
return {
pass: !!warned,
message: () =>
`Expected ${negative ? 'not ' : ''}to warn but ` +
'`warning` received the following calls: ' +
`${formatActual(calls)}.`,
}
function formatActual(calls) {
if (calls.length) {
return calls
.map(args => {
return formatArray([!!args[0]].concat(args.slice(1)));
})
.join(', ');
} else {
return '[]';
}
}
const warning = require('warning');
if (!warning.mock) {
throw new Error("toWarn(): Requires `jest.mock('warning')`.");
}
const callsCount = warning.mock.calls.length;
actual();
const calls = warning.mock.calls.slice(callsCount);
// Simple case: no explicit expectation.
if (!expected) {
const warned = calls.filter(args => !args[0]).length;
return {
pass: !!warned,
message: () =>
`Expected ${negative ? 'not ' : ''}to warn but ` +
'`warning` received the following calls: ' +
`${formatActual(calls)}.`,
return formatArray([!!args[0]].concat(args.slice(1)));
})
.join(', ');
} else {
return '[]';
}
}
const warning = require('warning');
if (!warning.mock) {
throw new Error("toWarn(): Requires `jest.mock('warning')`.");
}
const callsCount = warning.mock.calls.length;
actual();
const calls = warning.mock.calls.slice(callsCount);
// Simple case: no explicit expectation.
if (!expected) {
const warned = calls.filter(args => !args[0]).length;
return {
pass: !!warned,
message: () =>
`Expected ${negative ? 'not ' : ''}to warn but ` +
'`warning` received the following calls: ' +
`${formatActual(calls)}.`,
};
}
// Custom case: explicit expectation.
if (!Array.isArray(expected)) {
expected = [expected];
return formatArray([!!args[0]].concat(args.slice(1)));
})
.join(', ');
} else {
return '[]';
}
}
const warning = require('warning');
if (!warning.mock) {
throw new Error("toWarn(): Requires `jest.mock('warning')`.");
}
const callsCount = warning.mock.calls.length;
actual();
const calls = warning.mock.calls.slice(callsCount);
// Simple case: no explicit expectation.
if (!expected) {
const warned = calls.filter(args => !args[0]).length;
return {
pass: !!warned,
message: () =>
`Expected ${negative ? 'not ' : ''}to warn but ` +
'`warning` received the following calls: ' +
`${formatActual(calls)}.`,
};
}
// Custom case: explicit expectation.
if (!Array.isArray(expected)) {
expected = [expected];
return formatArray([!!args[0]].concat(args.slice(1)));
})
.join(', ');
} else {
return '[]';
}
}
const warning = require('warning');
if (!warning.mock) {
throw new Error("toWarn(): Requires `jest.mock('warning')`.");
}
const callsCount = warning.mock.calls.length;
actual();
const calls = warning.mock.calls.slice(callsCount);
// Simple case: no explicit expectation.
if (!expected) {
const warned = calls.filter(args => !args[0]).length;
return {
pass: !(negative ? warned : !warned),
message:
`Expected ${negative ? 'not ' : ''}to warn but ` +
'`warning` received the following calls: ' +
`${formatActual(calls)}.`,
};
}
// Custom case: explicit expectation.
if (!Array.isArray(expected)) {
expected = [expected];
}
function formatActual(calls) {
if (calls.length) {
return calls
.map(args => {
return formatArray([!!args[0]].concat(args.slice(1)));
})
.join(', ');
} else {
return '[]';
}
}
const warning = require('warning');
if (!warning.mock) {
throw new Error("toWarn(): Requires `jest.mock('warning')`.");
}
const callsCount = warning.mock.calls.length;
actual();
const calls = warning.mock.calls.slice(callsCount);
// Simple case: no explicit expectation.
if (!expected) {
const warned = calls.filter(args => !args[0]).length;
return {
pass: !(negative ? warned : !warned),
message:
`Expected ${negative ? 'not ' : ''}to warn but ` +
'`warning` received the following calls: ' +
`${formatActual(calls)}.`,