Skip to content

Commit

Permalink
Don't hardcode on the length of the password
Browse files Browse the repository at this point in the history
  • Loading branch information
panleone committed Dec 9, 2023
1 parent 708c678 commit b1a4a61
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/components/GenKeyWarning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ describe('GenKeyWarning tests', () => {
);

// Ok now the length has been changed to the minimum allowed value but passwords dont match!
newPassword.element.value = 'secure';
const safePassword = new Array(MIN_PASS_LENGTH + 1).join('x');
newPassword.element.value = safePassword;
newPassword.trigger('input');
await nextTick();
await submitBtn.trigger('click');
Expand All @@ -172,13 +173,15 @@ describe('GenKeyWarning tests', () => {
expect(misc.createAlert).toHaveBeenCalled();
expect(misc.createAlert).toHaveReturnedWith('pass_doesnt_match');
// Finally passwords match
confirmPassword.element.value = 'secure';
confirmPassword.element.value = safePassword;
confirmPassword.trigger('input');
await nextTick();
await submitBtn.trigger('click');
await nextTick();
checkEventsEmitted(wrapper, 1, 1, 0);
expect(wrapper.emitted('onEncrypt')).toStrictEqual([['secure', '']]);
expect(wrapper.emitted('onEncrypt')).toStrictEqual([
[safePassword, ''],
]);
expect(wrapper.emitted('close')).toStrictEqual([[]]);

// Test the close button
Expand Down Expand Up @@ -242,7 +245,8 @@ describe('GenKeyWarning tests', () => {
);

// Ok now the length has been changed to the minimum allowed value but passwords dont match!
newPassword.element.value = 'secure';
const safePassword = new Array(MIN_PASS_LENGTH + 1).join('x');
newPassword.element.value = safePassword;
newPassword.trigger('input');
await nextTick();
await submitBtn.trigger('click');
Expand All @@ -255,14 +259,14 @@ describe('GenKeyWarning tests', () => {
currentPassword.element.value = 'panleon';
currentPassword.trigger('input');
await nextTick();
confirmPassword.element.value = 'secure';
confirmPassword.element.value = safePassword;
confirmPassword.trigger('input');
await nextTick();
await submitBtn.trigger('click');
await nextTick();
checkEventsEmitted(wrapper, 1, 1, 0);
expect(wrapper.emitted('onEncrypt')).toStrictEqual([
['secure', 'panleon'],
[safePassword, 'panleon'],
]);
expect(wrapper.emitted('close')).toStrictEqual([[]]);
// Test the close button
Expand Down

0 comments on commit b1a4a61

Please sign in to comment.