1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 19:10:22 +01:00
metamask-extension/test/e2e/helpers.test.js
Pedro Figueiredo 537f1c7aee
feat: implement swap event metric e2e test (#20129)
* 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
2023-07-28 19:57:06 +01:00

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);
});
});