passwordHandlers.test.ts 796 B

1234567891011121314151617181920212223242526272829303132
  1. import { createResetHandler, PasswordFieldEnum, Ctrl } from './passwordHandlers';
  2. describe('createResetHandler', () => {
  3. Object.values(PasswordFieldEnum).forEach((field) => {
  4. it(`should reset existing ${field} field`, () => {
  5. const event: any = {
  6. preventDefault: () => {},
  7. };
  8. const ctrl: Ctrl = {
  9. current: {
  10. [field]: 'set',
  11. secureJsonData: {
  12. [field]: 'set',
  13. },
  14. secureJsonFields: {},
  15. },
  16. };
  17. createResetHandler(ctrl, field)(event);
  18. expect(ctrl).toEqual({
  19. current: {
  20. [field]: undefined,
  21. secureJsonData: {
  22. [field]: '',
  23. },
  24. secureJsonFields: {
  25. [field]: false,
  26. },
  27. },
  28. });
  29. });
  30. });
  31. });