forked from JSKitty/scc-web3
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Switch from jest to vitest * Remove old config files * Add TransferMenu test * Quick test to see if github actions are working * Revert "Quick test to see if github actions are working" This reverts commit 3bbc2a1.
- Loading branch information
Showing
8 changed files
with
5,050 additions
and
12,629 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import { nextTick, ref } from 'vue'; | ||
import { expect } from 'vitest'; | ||
import TransferMenu from '../../scripts/dashboard/TransferMenu.vue'; | ||
const price = 0.4; | ||
const mountTM = (amount = '123', address = '') => { | ||
const wrapper = mount(TransferMenu, { | ||
props: { | ||
show: true, | ||
price, | ||
currency: 'USD', | ||
amount, | ||
address, | ||
|
||
'onUpdate:amount': (e) => wrapper.setProps({ amount: e }), | ||
}, | ||
}); | ||
return wrapper; | ||
}; | ||
|
||
it('Updates inputs', async () => { | ||
const wrapper = mountTM(); | ||
|
||
const amount = wrapper.find('[data-testid=amount]'); | ||
const currency = wrapper.find('[data-testid=amountCurrency]'); | ||
|
||
amount.trigger('input'); | ||
|
||
await nextTick(); | ||
await nextTick(); | ||
|
||
// Test that amount -> currency updates | ||
expect(amount.element.value).toBe('123'); | ||
expect(currency.element.value).toBe(`${123 * price}`); | ||
|
||
// Test that currency -> amount updates | ||
currency.element.value = '49'; | ||
currency.trigger('input'); | ||
await nextTick(); | ||
|
||
expect(amount.element.value).toBe(`${49 / price}`); | ||
expect(currency.element.value).toBe(`49`); | ||
|
||
// Test that setting one as empty clears the other | ||
currency.element.value = ''; | ||
currency.trigger('input'); | ||
await nextTick(); | ||
|
||
expect(amount.element.value).toBe(''); | ||
expect(currency.element.value).toBe(''); | ||
}); | ||
|
||
it('Closes correctly', async () => { | ||
const wrapper = mountTM(); | ||
expect(wrapper.emitted('close')).toBeUndefined(); | ||
wrapper.find('[data-testid=closeButton]').trigger('click'); | ||
expect(wrapper.emitted('close')).toHaveLength(1); | ||
}); | ||
|
||
it('Sends transaction correctly', async () => { | ||
const wrapper = mountTM('60', 'DLabsktzGMnsK5K9uRTMCF6NoYNY6ET4Bc'); | ||
expect(wrapper.emitted('send')).toBeUndefined(); | ||
wrapper.find('[data-testid=sendButton]').trigger('click'); | ||
expect(wrapper.emitted('send')).toStrictEqual([ | ||
['DLabsktzGMnsK5K9uRTMCF6NoYNY6ET4Bc', '60'], | ||
]); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineConfig } from 'vitest/config'; | ||
import vue from '@vitejs/plugin-vue'; | ||
|
||
export default defineConfig({ | ||
assetsInclude: '**/*.toml', | ||
plugins: [vue()], | ||
test: { | ||
environment: 'happy-dom', | ||
globals: true, | ||
}, | ||
}); |