Skip to content
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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tests/e2e/screenshots
.DS_Store
/tests/e2e/videos/
/tests/e2e/screenshots/
/coverage
Copy link
Collaborator

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.


# local env files
.env.local
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ module.exports = {
setupFiles: [
'<rootDir>/config/jest/setEnvVars.js',
],
collectCoverage: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 test:unit command. I think it would be better to track coverage differently.
#1778

};
32 changes: 32 additions & 0 deletions tests/unit/TokenAmount.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {shallowMount} from '@vue/test-utils'
import TokenAmount from '../../src/popup/components/TokenAmount.vue'

let wrapper;

describe('TokenAmount',()=>{
beforeEach(()=>{
wrapper = shallowMount(TokenAmount,{
propsData:{
amount:111,
hideFiat:true,
direction:'sent',
large:false,
noSymbol:true,
highPrecision:false
},
mocks:{
$store:{
state:{},
getters:{}
}
}
})
})

it('should match the snapshot',()=>{
expect(wrapper.vm).toMatchSnapshot()
})
})



35 changes: 35 additions & 0 deletions tests/unit/Tokens.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {shallowMount} from '@vue/test-utils'
import Tokens from '../../src/popup/components/Tokens.vue'

let wrapper;

describe('Tokens',()=>{
beforeEach(()=>{
wrapper = shallowMount(Tokens,{
propsData:{
tokens:[{symbol:'test123'},{symbol:'test456'}],
vertical:true
}
})
})

it('should match the snapshot',()=>{
expect(wrapper.vm).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)
})
})



Loading