passwordHandlers.test.ts 851 B

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