mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 07:16:36 +01:00
537f1c7aee
* implement swap event metric e2e test * fix lint error * clean up initial balance helpers * fix eslint warnings * Fix `token_to_amount` format to address firefox bug and refactor tests
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
import { assertInAnyOrder } from './helpers';
|
|
|
|
describe('assertInAnyOrder()', () => {
|
|
it('returns true when all requests pass unique assertions', () => {
|
|
const requests = ['req1', 'req2', 'req3'];
|
|
const assertions = [
|
|
[(req) => req === 'req1'],
|
|
[(req) => req === 'req2'],
|
|
[(req) => req === 'req3'],
|
|
];
|
|
expect(assertInAnyOrder(requests, assertions)).toBe(true);
|
|
});
|
|
|
|
it('returns true when all requests pass unique assertions independently of the order', () => {
|
|
const requests = ['req1', 'req2', 'req3'];
|
|
const assertions = [
|
|
[(req) => req === 'req3'],
|
|
[(req) => req === 'req2'],
|
|
[(req) => req === 'req1'],
|
|
];
|
|
expect(assertInAnyOrder(requests, assertions)).toBe(true);
|
|
});
|
|
|
|
it('returns false when a request cannot pass any assertions', () => {
|
|
const requests = ['req1', 'req2', 'unknown'];
|
|
const assertions = [
|
|
[(req) => req === 'req1'],
|
|
[(req) => req === 'req2'],
|
|
[(req) => req === 'req3'],
|
|
];
|
|
expect(assertInAnyOrder(requests, assertions)).toBe(false);
|
|
});
|
|
|
|
it('returns false when there are unused assertions', () => {
|
|
const requests = ['req1', 'req2'];
|
|
const assertions = [
|
|
[(req) => req === 'req1'],
|
|
[(req) => req === 'req2'],
|
|
[(req) => req === 'req3'],
|
|
];
|
|
expect(assertInAnyOrder(requests, assertions)).toBe(false);
|
|
});
|
|
|
|
it('returns false when there are unused requests', () => {
|
|
const requests = ['req1', 'req2', 'req3', 'req4'];
|
|
const assertions = [
|
|
[(req) => req === 'req1'],
|
|
[(req) => req === 'req2'],
|
|
[(req) => req === 'req3'],
|
|
];
|
|
expect(assertInAnyOrder(requests, assertions)).toBe(false);
|
|
});
|
|
});
|