You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.7 KiB
72 lines
1.7 KiB
3 years ago
|
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');
|
||
|
});
|
||
|
});
|