-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added testcases for Tokens & TotalAmount Component #1629
base: develop
Are you sure you want to change the base?
Changes from all commits
d0bd264
04c9993
1bac9a6
4868a42
7816cd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ module.exports = { | |
'<rootDir>/config/jest/setEnvVars.js', | ||
'<rootDir>/config/jest/setup.js', | ||
], | ||
collectCoverage: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to collect coverage on every run of |
||
transform: { | ||
'^.+\\.(ts|tsx)$': 'ts-jest', | ||
'^.+\\.vue$': 'vue-jest', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { shallowMount } from '@vue/test-utils'; | ||
import TokenAmount from '../../src/popup/components/TokenAmount.vue'; | ||
|
||
let wrapper; | ||
|
||
describe('TokenAmount', () => { | ||
beforeEach(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need to have a |
||
wrapper = shallowMount(TokenAmount, { | ||
propsData: { | ||
amount: 111, | ||
hideFiat: true, | ||
direction: 'sent', | ||
large: false, | ||
noSymbol: true, | ||
highPrecision: false, | ||
}, | ||
mocks: { | ||
$store: { | ||
state: {}, | ||
getters: {}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can import and use particular |
||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('should match the snapshot', () => { | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { shallowMount } from '@vue/test-utils'; | ||
import Tokens from '../../src/popup/components/Tokens.vue'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is not covering all the potential cases of |
||
|
||
let wrapper; | ||
|
||
describe('Tokens', () => { | ||
beforeEach(() => { | ||
wrapper = shallowMount(Tokens, { | ||
propsData: { | ||
tokens: [{ symbol: 'test123', contractId: '1' }, { symbol: 'test456', contractId: '2' }], | ||
vertical: true, | ||
}, | ||
}); | ||
}); | ||
|
||
it('should match the snapshot', () => { | ||
expect(wrapper.html()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should test getAvailableCharLength', async () => { | ||
const getAvailableCharLength = jest.spyOn(wrapper.vm, 'getAvailableCharLength'); | ||
let length = wrapper.vm.getAvailableCharLength(); | ||
expect(getAvailableCharLength).toHaveBeenCalled(); | ||
expect(length).toEqual(5); | ||
await wrapper.setProps({ | ||
symbolLength: 11, | ||
doubleSymbolLength: 5, | ||
tokens: [{ symbol: 'test' }, { symbol: 'test456' }], | ||
vertical: true, | ||
}); | ||
length = wrapper.vm.getAvailableCharLength(); | ||
expect(length).toEqual(7); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`TokenAmount should match the snapshot 1`] = ` | ||
<span class="token-amount sent"><span><!----> <span class="amount"> | ||
111 | ||
<!----></span></span> | ||
<!----></span> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Tokens should match the snapshot 1`] = ` | ||
<span class="tokens rg vertical"><span class="icons"><img src="https://avatars.z52da5wt.xyz/2" title="test456" class="to-token border"> <img src="https://avatars.z52da5wt.xyz/1" title="test123" class="border pair"></span> <span class="symbols"><span class="symbol"> | ||
test1... | ||
</span> <span class="separator"> | ||
/ | ||
</span> <span class="symbol"> | ||
test4... | ||
</span></span></span> | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all changes to this file should be undone.