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];
future = function(control, propValue, newProp, comment) {
const additionalComment = comment ? ` ${comment}` : '';
if (!hasWarned[control + newProp]) {
/* eslint-disable max-len */
warning(
!propValue,
`[Design System React] \`${newProp}\` of ${control} is not implemented yet. Please check future releases for \`${newProp}\`.${additionalComment}`
);
/* eslint-enable max-len */
hasWarned[control + newProp] = !!propValue;
}
};
}
if (args.length < 2) {
const [handler]: [FunctionalHandler | Builder] = (args: any);
this.on(context => context.event.isPayload, handler);
} else {
// eslint-disable-next-line prefer-const
let [pattern, handler]: [
Pattern,
FunctionalHandler | Builder
] = (args: any);
if (handler.build) {
handler = handler.build();
}
warning(
typeof pattern === 'function' ||
typeof pattern === 'string' ||
pattern instanceof RegExp,
`'onPayload' only accepts string, regex or function, but received ${typeof pattern}`
);
if (typeof pattern === 'function') {
const predicate: Predicate = pattern;
this.on(
context =>
context.event.isPayload &&
predicate(context.event.payload, context),
handler
);
} else {
if (pattern instanceof RegExp) {
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)}.`,