You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

57 lines
1.5 KiB

  1. import test from 'ava';
  2. import {mutations} from '../src/store/mutations';
  3. test('LOGOUT', t => {
  4. const {LOGOUT} = mutations;
  5. const state = {authenticated: true};
  6. LOGOUT(state);
  7. t.false(state.authenticated);
  8. });
  9. test('LOGIN', t => {
  10. const {LOGIN} = mutations;
  11. const state = {authenticated: false};
  12. LOGIN(state);
  13. t.true(state.authenticated);
  14. });
  15. test('SET_CURRENT_PASSWORD_PROFILE', t => {
  16. const {SET_CURRENT_PASSWORD_PROFILE} = mutations;
  17. const state = {currentPasswordProfile: null};
  18. SET_CURRENT_PASSWORD_PROFILE(state, {
  19. uppercase: true,
  20. version: 2
  21. });
  22. t.is(state.currentPasswordProfile.version, 2);
  23. t.true(state.currentPasswordProfile.uppercase);
  24. });
  25. test('SET_CURRENT_PASSWORD_PROFILE immutable', t => {
  26. const {SET_CURRENT_PASSWORD_PROFILE} = mutations;
  27. const state = {};
  28. const profile = {version: 2};
  29. SET_CURRENT_PASSWORD_PROFILE(state, profile);
  30. profile.version = 1;
  31. t.is(state.currentPasswordProfile.version, 2);
  32. });
  33. test('SET_DEFAULT_OPTIONS', t => {
  34. const {SET_DEFAULT_OPTIONS} = mutations;
  35. const state = {
  36. defaultOptions: {
  37. uppercase: true,
  38. lowercase: true,
  39. numbers: true,
  40. symbols: true,
  41. length: 16,
  42. counter: 1,
  43. version: 2
  44. }
  45. };
  46. SET_DEFAULT_OPTIONS(state, {
  47. symbols: false,
  48. length: 30
  49. });
  50. t.is(state.defaultOptions.length, 30);
  51. t.false(state.defaultOptions.symbols);
  52. });