Skip to content

Commit

Permalink
Change to shallowMount
Browse files Browse the repository at this point in the history
  • Loading branch information
panleone committed Dec 12, 2023
1 parent 54b439f commit cd177bd
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/components/Login.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import { expect } from 'vitest';
import Login from '../../scripts/dashboard/Login.vue';
Expand All @@ -18,7 +18,7 @@ document.body.innerHTML = `
describe('Login tests', () => {
afterEach(() => vi.clearAllMocks());
test('Create wallet login (no advanced)', async () => {
const wrapper = mount(Login, {
const wrapper = shallowMount(Login, {
props: {
advancedMode: false,
},
Expand All @@ -32,15 +32,15 @@ describe('Login tests', () => {
advancedMode: false,
});
// We can just emit the event: CreateWallet has already been unit tested!
createWalletComponent.vm.emit('import-wallet', 'mySecret', '');
createWalletComponent.vm.$emit('import-wallet', 'mySecret', '');
// Make sure the Login component relays the right event
expect(wrapper.emitted('import-wallet')).toHaveLength(1);
expect(wrapper.emitted('import-wallet')).toStrictEqual([
[{ password: '', secret: 'mySecret', type: 'hd' }],
]);
});
test('Create wallet login (advanced)', async () => {
const wrapper = mount(Login, {
const wrapper = shallowMount(Login, {
props: {
advancedMode: true,
},
Expand All @@ -54,15 +54,15 @@ describe('Login tests', () => {
advancedMode: true,
});
// We can just emit the event: CreateWallet has already been unit tested!
createWalletComponent.vm.emit('import-wallet', 'mySecret', 'myPass');
createWalletComponent.vm.$emit('import-wallet', 'mySecret', 'myPass');
// Make sure the Login component relays the right event
expect(wrapper.emitted('import-wallet')).toHaveLength(1);
expect(wrapper.emitted('import-wallet')).toStrictEqual([
[{ password: 'myPass', secret: 'mySecret', type: 'hd' }],
]);
});
test('Vanity gen login', async () => {
const wrapper = mount(Login, {
const wrapper = shallowMount(Login, {
props: {
advancedMode: false,
},
Expand All @@ -75,15 +75,15 @@ describe('Login tests', () => {
// Vanity gen is easy: it has no props
expect(vanityGenComponent.props()).toStrictEqual({});
// We can just emit a complete random event: VanityGen has already been unit tested!
vanityGenComponent.vm.emit('import-wallet', 'mySecret');
vanityGenComponent.vm.$emit('import-wallet', 'mySecret');
// Make sure the Login component relays the right event
expect(wrapper.emitted('import-wallet')).toHaveLength(1);
expect(wrapper.emitted('import-wallet')).toStrictEqual([
[{ secret: 'mySecret', type: 'legacy' }],
]);
});
test('Access wallet login (no advanced)', async () => {
const wrapper = mount(Login, {
const wrapper = shallowMount(Login, {
props: {
advancedMode: false,
},
Expand All @@ -96,15 +96,15 @@ describe('Login tests', () => {
advancedMode: false,
});
// We can just emit a complete random event: AccessWallet has already been unit tested!
accessWalletComponent.vm.emit('import-wallet', 'mySecret', '');
accessWalletComponent.vm.$emit('import-wallet', 'mySecret', '');
// Make sure the Login component relays the right event
expect(wrapper.emitted('import-wallet')).toHaveLength(1);
expect(wrapper.emitted('import-wallet')).toStrictEqual([
[{ secret: 'mySecret', type: 'hd', password: '' }],
]);
});
test('Access wallet login (advanced)', async () => {
const wrapper = mount(Login, {
const wrapper = shallowMount(Login, {
props: {
advancedMode: true,
},
Expand All @@ -117,15 +117,15 @@ describe('Login tests', () => {
advancedMode: true,
});
// We can just emit a complete random event: AccessWallet has already been unit tested!
accessWalletComponent.vm.emit('import-wallet', 'mySecret', 'myPass');
accessWalletComponent.vm.$emit('import-wallet', 'mySecret', 'myPass');
// Make sure the Login component relays the right event
expect(wrapper.emitted('import-wallet')).toHaveLength(1);
expect(wrapper.emitted('import-wallet')).toStrictEqual([
[{ secret: 'mySecret', type: 'hd', password: 'myPass' }],
]);
});
test('HardwareWallet login', async () => {
const wrapper = mount(Login, {
const wrapper = shallowMount(Login, {
props: {
advancedMode: false,
},
Expand Down

0 comments on commit cd177bd

Please sign in to comment.