Skip to content

Commit

Permalink
[explorer] task: patch update on UI store
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyLaw committed Dec 22, 2022
1 parent 104133c commit a058360
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions __tests__/store/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,22 @@ describe('store/ui', () => {
});

describe('input value contain whitespace', () => {
const runBasicWhitespaceTests = (pageName, inputValue) => {
it(`returns ${pageName} page`, async () => {
const runBasicWhitespaceTests = (inputValue, expectedResult) => {
it(`returns ${expectedResult} page`, async () => {
// Arrange:
if ('mosaic' === pageName)
if ('mosaic' === expectedResult)
stub(MosaicService, 'getMosaicInfo').returns(Promise.resolve({}));
else if('account' === pageName)
else if('account' === expectedResult)
stub(AccountService, 'getAccountInfo').returns(Promise.resolve({}));
else if ('namespace' === pageName)
else if ('namespace' === expectedResult)
stub(NamespaceService, 'getNamespaceInfo').returns(Promise.resolve({}));


// Act:
await ui.actions.search({ dispatch, rootGetters }, inputValue);

// Assert:
expect(dispatch).toHaveBeenNthCalledWith(1, 'openPage', {
pageName,
pageName: expectedResult,
param: inputValue.replace(/\s/g, '')
});
});
Expand All @@ -156,32 +155,32 @@ describe('store/ui', () => {
// Arrange:
const inputValues = [
{
pageName: 'block',
expectedResult: 'block',
input: ' 10 '
},
{
pageName: 'account',
expectedResult: 'account',
input: ' DC20B243B63246C9E75E4FB5ED236513A005454393E93C8A4CE6EDEE323C2DDB '
},
{
pageName: 'account',
expectedResult: 'account',
input: ' TAR5OQBKR4KSVRVZ3ZBVHNLMBZ4N4Q27WFVMJDI '
},
{
pageName: 'transaction',
expectedResult: 'transaction',
input: ' 706BBC8F95AF60B22CB38911A645D3BA24DC480FDBE18C197ACCFE0FDE0DC24D'
},
{
pageName: 'mosaic',
expectedResult: 'mosaic',
input: '3A8416DB2D53B6C8 '
},
{
pageName: 'namespace',
expectedResult: 'namespace',
input: 'symbol . xym '
}
];

inputValues.forEach(({input, pageName}) => runBasicWhitespaceTests(pageName, input));
inputValues.forEach(({input, expectedResult}) => runBasicWhitespaceTests(input, expectedResult));
});
});
});

0 comments on commit a058360

Please sign in to comment.