1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00
metamask-extension/ui/selectors/metametrics.test.js

72 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-01-12 20:31:54 +01:00
const {
selectFragmentBySuccessEvent,
selectFragmentById,
selectMatchingFragment,
} = require('.');
describe('selectFragmentBySuccessEvent', () => {
it('should find matching fragment in state by successEvent', () => {
const state = {
metamask: {
fragments: {
randomid: {
successEvent: 'example event',
persist: true,
id: 'randomid',
},
},
},
};
const selected = selectFragmentBySuccessEvent(state, {
successEvent: 'example event',
persist: true,
});
expect(selected).toHaveProperty('id', 'randomid');
});
});
describe('selectFragmentById', () => {
it('should find matching fragment in state by id', () => {
const state = {
metamask: {
fragments: {
randomid: {
successEvent: 'example event',
persist: true,
id: 'randomid',
},
},
},
};
const selected = selectFragmentById(state, 'randomid');
expect(selected).toHaveProperty('id', 'randomid');
});
});
describe('selectMatchingFragment', () => {
it('should find matching fragment in state by id', () => {
const state = {
metamask: {
fragments: {
notthecorrectid: {
successEvent: 'event name',
id: 'notthecorrectid',
},
randomid: {
successEvent: 'example event',
persist: true,
id: 'randomid',
},
},
},
};
const selected = selectMatchingFragment(state, {
fragmentOptions: {
successEvent: 'event name',
},
existingId: 'randomid',
});
expect(selected).toHaveProperty('id', 'randomid');
});
});