From 7dff70778258891b9a5d44578c7c23428a69df72 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Wed, 30 Oct 2019 15:09:25 -0400 Subject: [PATCH] split password tests up --- test/unit/lib/validate.test.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/test/unit/lib/validate.test.js b/test/unit/lib/validate.test.js index 72dd7729b..d839e3c8b 100644 --- a/test/unit/lib/validate.test.js +++ b/test/unit/lib/validate.test.js @@ -24,21 +24,21 @@ describe('unit test lib/validate.js', () => { expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'}); }); - test('validate password', () => { + test('validate password existence', () => { let response; expect(typeof validate.validatePassword).toBe('function'); response = validate.validatePassword('abcdef'); expect(response).toEqual({valid: true}); - response = validate.validatePassword('abcdefghijklmnopqrst'); - expect(response).toEqual({valid: true}); - response = validate.validatePassword('passwo'); - expect(response).toEqual({valid: true}); response = validate.validatePassword(''); expect(response).toEqual({valid: false, errMsgId: 'general.required'}); + }); + + test('validate password length', () => { + let response; + response = validate.validatePassword('abcdefghijklmnopqrst'); + expect(response).toEqual({valid: true}); response = validate.validatePassword('abcde'); expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'}); - response = validate.validatePassword('password'); - expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordNotEquals'}); response = validate.validatePassword('😺'); expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'}); response = validate.validatePassword('😺🦆🐝'); @@ -47,6 +47,15 @@ describe('unit test lib/validate.js', () => { expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordLength'}); response = validate.validatePassword('😺🦆🐝🐮🐠🐻'); expect(response).toEqual({valid: true}); + }); + + test('validate password cannot be "password"', () => { + const response = validate.validatePassword('password'); + expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordNotEquals'}); + }); + + test('validate password cannot be same as username', () => { + let response; response = validate.validatePassword('abcdefg', 'abcdefg'); expect(response).toEqual({valid: false, errMsgId: 'registration.validationPasswordNotUsername'}); response = validate.validatePassword('abcdefg', 'abcdefG');