-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [explorer] task: fix jest config and missing extension * [explorer] fix: search bug * [explorer] task: add unit test for search bar
- Loading branch information
1 parent
06dc320
commit 466789a
Showing
12 changed files
with
175 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import Helper from '../../src/helper'; | ||
import { AccountService, MosaicService, NamespaceService } from '../../src/infrastructure'; | ||
import ui from '../../src/store/ui'; | ||
import { stub, restore } from 'sinon'; | ||
|
||
describe('store/ui', () => { | ||
describe('action search should', () => { | ||
let dispatch; | ||
let rootGetters; | ||
|
||
beforeEach(() => { | ||
dispatch = jest.fn(); | ||
rootGetters = {}; | ||
}); | ||
|
||
afterEach(restore); | ||
|
||
it('return block page with height', async () => { | ||
// Arrange: | ||
const height = '10'; | ||
|
||
// Act: | ||
await ui.actions.search({ dispatch, rootGetters }, height); | ||
|
||
// Assert: | ||
expect(dispatch).toHaveBeenCalledTimes(1); | ||
expect(dispatch).toHaveBeenNthCalledWith(1, 'openPage', { | ||
pageName: 'block', | ||
param: height | ||
}); | ||
}); | ||
|
||
it('return account page with public key', async () => { | ||
// Arrange: | ||
const publicKey = 'DC20B243B63246C9E75E4FB5ED236513A005454393E93C8A4CE6EDEE323C2DDB'; | ||
|
||
const getAccountInfoStub = stub(AccountService, 'getAccountInfo'); | ||
getAccountInfoStub.returns(Promise.resolve({})); | ||
|
||
// Act: | ||
await ui.actions.search({ dispatch, rootGetters }, publicKey); | ||
|
||
// Assert: | ||
expect(dispatch).toHaveBeenCalledTimes(1); | ||
expect(dispatch).toHaveBeenNthCalledWith(1, 'openPage', { | ||
pageName: 'account', | ||
param: publicKey | ||
}); | ||
}); | ||
|
||
it('return account page with address', async () => { | ||
// Arrange: | ||
const address = 'TAR5OQBKR4KSVRVZ3ZBVHNLMBZ4N4Q27WFVMJDI'; | ||
|
||
// Act: | ||
await ui.actions.search({ dispatch, rootGetters }, address); | ||
|
||
// Assert: | ||
expect(dispatch).toHaveBeenCalledTimes(1); | ||
expect(dispatch).toHaveBeenNthCalledWith(1, 'openPage', { | ||
pageName: 'account', | ||
param: address | ||
}); | ||
}); | ||
|
||
it('return transaction page with hash', async () => { | ||
// Arrange: | ||
const hash = '706BBC8F95AF60B22CB38911A645D3BA24DC480FDBE18C197ACCFE0FDE0DC24D'; | ||
|
||
// Act: | ||
await ui.actions.search({ dispatch, rootGetters }, hash); | ||
|
||
// Assert: | ||
expect(dispatch).toHaveBeenCalledTimes(1); | ||
expect(dispatch).toHaveBeenNthCalledWith(1, 'openPage', { | ||
pageName: 'transaction', | ||
param: hash | ||
}); | ||
}); | ||
|
||
it('return mosaic page with mosaic Id', async () => { | ||
// Arrange: | ||
const mosaicId = '3A8416DB2D53B6C8'; | ||
|
||
const getMosaicInfoStub = stub(MosaicService, 'getMosaicInfo'); | ||
getMosaicInfoStub.returns(Promise.resolve({})); | ||
|
||
// Act: | ||
await ui.actions.search({ dispatch, rootGetters }, mosaicId); | ||
|
||
// Assert: | ||
expect(dispatch).toHaveBeenCalledTimes(1); | ||
expect(dispatch).toHaveBeenNthCalledWith(1, 'openPage', { | ||
pageName: 'mosaic', | ||
param: mosaicId | ||
}); | ||
}); | ||
|
||
it('return namespace page with namespace name', async () => { | ||
// Arrange: | ||
const namespaceName = 'symbol.xym'; | ||
|
||
const getNamespaceInfoStub = stub(NamespaceService, 'getNamespaceInfo'); | ||
getNamespaceInfoStub.returns(Promise.resolve({})); | ||
|
||
// Act: | ||
await ui.actions.search({ dispatch, rootGetters }, namespaceName); | ||
|
||
// Assert: | ||
expect(dispatch).toHaveBeenCalledTimes(1); | ||
expect(dispatch).toHaveBeenNthCalledWith(1, 'openPage', { | ||
pageName: 'namespace', | ||
param: namespaceName | ||
}); | ||
}); | ||
|
||
it('throw error given Nem address', async () => { | ||
// Arrange: | ||
const nemAddress = 'TALICE546OTUY4YJTQCQZ4HSEP4UM5Y5KRG4JHD7'; | ||
|
||
// Act + Assert: | ||
return expect(ui.actions.search({ dispatch, rootGetters }, nemAddress)) | ||
.rejects.toThrow('errorNisAddressNotAllowed'); | ||
}); | ||
|
||
it('throw error given data not found', async () => { | ||
// Arrange: | ||
const randomText = 'zz'; | ||
|
||
// Act + Assert: | ||
return expect(ui.actions.search({ dispatch, rootGetters }, randomText)) | ||
.rejects.toThrow('errorNothingFound'); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters