2019-04-15 11:11:17 +02:00
|
|
|
import { createResetHandler, PasswordFieldEnum, Ctrl } from './passwordHandlers';
|
|
|
|
|
describe('createResetHandler', () => {
|
2021-01-20 07:59:48 +01:00
|
|
|
Object.values(PasswordFieldEnum).forEach((field) => {
|
2019-04-15 11:11:17 +02:00
|
|
|
it(`should reset existing ${field} field`, () => {
|
|
|
|
|
const event: any = {
|
|
|
|
|
preventDefault: () => {},
|
|
|
|
|
};
|
|
|
|
|
const ctrl: Ctrl = {
|
|
|
|
|
current: {
|
|
|
|
|
[field]: 'set',
|
|
|
|
|
secureJsonData: {
|
|
|
|
|
[field]: 'set',
|
|
|
|
|
},
|
|
|
|
|
secureJsonFields: {},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
createResetHandler(ctrl, field)(event);
|
|
|
|
|
expect(ctrl).toEqual({
|
|
|
|
|
current: {
|
2020-07-09 15:16:35 +02:00
|
|
|
[field]: undefined,
|
2019-04-15 11:11:17 +02:00
|
|
|
secureJsonData: {
|
|
|
|
|
[field]: '',
|
|
|
|
|
},
|
|
|
|
|
secureJsonFields: {
|
|
|
|
|
[field]: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|