Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

59 rader
1.3 KiB

  1. import test from "ava";
  2. import * as getters from "../../src/store/getters";
  3. test("version", t => {
  4. const state = {
  5. password: { version: 1 },
  6. defaultPassword: { version: 2 }
  7. };
  8. const version = getters.version(state);
  9. t.is(version, 1);
  10. });
  11. test("version no password return default password version", t => {
  12. const state = {
  13. password: null,
  14. defaultPassword: { version: 2 }
  15. };
  16. const version = getters.version(state);
  17. t.is(version, 2);
  18. });
  19. test("passwordURL", t => {
  20. const state = {
  21. password: {
  22. login: "test@example.org",
  23. site: "example.org",
  24. uppercase: true,
  25. lowercase: true,
  26. numbers: true,
  27. symbols: false,
  28. length: 16,
  29. counter: 1,
  30. version: 2
  31. },
  32. baseURL: "https://lesspass.com"
  33. };
  34. t.is(
  35. getters.passwordURL(state),
  36. "https://lesspass.com/#/?login=test@example.org&site=example.org&uppercase=true&lowercase=true&numbers=true&symbols=false&length=16&counter=1&version=2"
  37. );
  38. });
  39. test("isAuthenticated", t => {
  40. const state = {
  41. authenticated: true
  42. };
  43. t.true(getters.isAuthenticated(state));
  44. t.false(getters.isGuest(state));
  45. });
  46. test("isGuest", t => {
  47. const state = {
  48. authenticated: false
  49. };
  50. t.false(getters.isAuthenticated(state));
  51. t.true(getters.isGuest(state));
  52. });