-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Scille/run-tests
Setup components test (with ms-input tests imported from parsec-cloud)
- Loading branch information
Showing
9 changed files
with
207 additions
and
8 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
|
||
import { IonInput } from '@ionic/vue'; | ||
import { MsChoosePasswordInput } from '@lib'; | ||
import { VueWrapper, mount } from '@vue/test-utils'; | ||
|
||
describe('Choose password', () => { | ||
let wrapper: VueWrapper<any>; | ||
|
||
beforeEach(() => { | ||
wrapper = mount(MsChoosePasswordInput, {}); | ||
}); | ||
|
||
it('Validate the fields', async () => { | ||
// Fields are empty, obviously not valid | ||
expect(await wrapper.vm.areFieldsCorrect()).to.be.false; | ||
|
||
const ionInputs = wrapper.findAllComponents(IonInput); | ||
ionInputs[0].vm.$emit('ionInput', { target: { value: 'P@ssw0rd.' } }); | ||
expect(wrapper.vm.password).to.equal('P@ssw0rd.'); | ||
|
||
// Confirmation is not filled, not valid | ||
expect(await wrapper.vm.areFieldsCorrect()).to.be.false; | ||
|
||
ionInputs[1].vm.$emit('ionInput', { target: { value: 'P@ssw0rd.' } }); | ||
expect(wrapper.vm.passwordConfirm).to.equal('P@ssw0rd.'); | ||
|
||
// P@ssw0rd is not strong enough | ||
expect(await wrapper.vm.areFieldsCorrect()).to.be.false; | ||
|
||
ionInputs[0].vm.$emit('ionInput', { | ||
target: { value: 'ABiggerSaferPassword' }, | ||
}); | ||
expect(wrapper.vm.password).to.equal('ABiggerSaferPassword'); | ||
|
||
// Password is strong enough but password and confirmation don't match | ||
expect(await wrapper.vm.areFieldsCorrect()).to.be.false; | ||
|
||
ionInputs[1].vm.$emit('ionInput', { | ||
target: { value: 'ABiggerSaferPassword' }, | ||
}); | ||
expect(wrapper.vm.passwordConfirm).to.equal('ABiggerSaferPassword'); | ||
expect(await wrapper.vm.areFieldsCorrect()).to.be.true; | ||
}); | ||
}); |
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,46 @@ | ||
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
|
||
import { IonInput } from '@ionic/vue'; | ||
import { MsPasswordInput } from '@lib'; | ||
import { VueWrapper, mount } from '@vue/test-utils'; | ||
|
||
describe('Password Input', () => { | ||
let wrapper: VueWrapper; | ||
beforeEach(() => { | ||
wrapper = mount(MsPasswordInput, { | ||
props: { | ||
label: 'A Label', | ||
modelValue: '', | ||
}, | ||
}); | ||
}); | ||
|
||
it('should emit a signal when input changes', async () => { | ||
const ionInput = wrapper.findComponent(IonInput); | ||
ionInput.vm.$emit('ionInput', { target: { value: 'P@ssw0rd.' } }); | ||
expect(wrapper.emitted('change')?.length).to.equal(1); | ||
expect(wrapper.emitted('change')?.at(0)).to.have.same.members(['P@ssw0rd.']); | ||
}); | ||
|
||
it('should emit enter when Enter key is pressed', async () => { | ||
// Setting a value | ||
await wrapper.setProps({ modelValue: 'P@ssw0rd.' }); | ||
const ionInput = wrapper.findComponent(IonInput); | ||
await ionInput.trigger('keyup.enter'); | ||
expect(wrapper.emitted('onEnterKeyup')?.length).to.equal(1); | ||
}); | ||
|
||
it('should not emit enter when input is empty', async () => { | ||
const ionInput = wrapper.findComponent(IonInput); | ||
await ionInput.trigger('keyup.enter'); | ||
expect(wrapper.emitted('onEnterKeyup')).to.be.undefined; | ||
}); | ||
|
||
it('should toggle password visibility button icon and password input type on password visibility button click', async () => { | ||
expect((wrapper.vm as any).passwordVisible).to.be.false; | ||
await wrapper.find('.input-icon').trigger('click'); | ||
expect((wrapper.vm as any).passwordVisible).to.be.true; | ||
await wrapper.find('.input-icon').trigger('click'); | ||
expect((wrapper.vm as any).passwordVisible).to.be.false; | ||
}); | ||
}); |
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,37 @@ | ||
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
|
||
import { IonInput } from '@ionic/vue'; | ||
import { MsSearchInput } from '@lib'; | ||
import { mount, VueWrapper } from '@vue/test-utils'; | ||
|
||
describe('Search Input', () => { | ||
let wrapper: VueWrapper; | ||
beforeEach(() => { | ||
wrapper = mount(MsSearchInput, { | ||
props: { | ||
placeholder: 'A Label', | ||
}, | ||
}); | ||
}); | ||
|
||
it('should emit a signal when input changes', async () => { | ||
const ionInput = wrapper.findComponent(IonInput); | ||
ionInput.vm.$emit('ionInput', { target: { value: 'Search string' } }); | ||
expect(wrapper.emitted('change')?.length).to.equal(1); | ||
expect(wrapper.emitted('change')?.at(0)).to.have.same.members(['Search string']); | ||
}); | ||
|
||
it('should emit enter when Enter key is pressed', async () => { | ||
// Setting a value | ||
await wrapper.setProps({ modelValue: 'Search string' }); | ||
const ionInput = wrapper.findComponent(IonInput); | ||
await ionInput.trigger('keyup.enter'); | ||
expect(wrapper.emitted('enter')?.length).to.equal(1); | ||
}); | ||
|
||
it('should not emit enter when input is empty', async () => { | ||
const ionInput = wrapper.findComponent(IonInput); | ||
await ionInput.trigger('keyup.enter'); | ||
expect(wrapper.emitted('enter')).to.be.undefined; | ||
}); | ||
}); |
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,12 @@ | ||
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
|
||
import { I18n, Translatable } from '@lib'; | ||
import { config } from '@vue/test-utils'; | ||
|
||
function mockI18n(): void { | ||
config.global.mocks = { | ||
$msTranslate: (tr: Translatable): string => I18n.translate(tr), | ||
}; | ||
} | ||
|
||
export { mockI18n }; |
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,17 @@ | ||
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS | ||
|
||
import { I18n } from '@lib'; | ||
import appEnUS from '@lib/locales/en-US.json'; | ||
import appFrFR from '@lib/locales/fr-FR.json'; | ||
import { mockI18n } from '@tests/support/mocks'; | ||
|
||
beforeEach(() => { | ||
I18n.init({ | ||
defaultLocale: 'en-US', | ||
customAssets: { | ||
'fr-FR': appFrFR, | ||
'en-US': appEnUS, | ||
}, | ||
}); | ||
mockI18n(); | ||
}); |
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