Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

store.getters.js 2.3 KiB

pirms 7 gadiem
pirms 7 gadiem
pirms 7 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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("isDefaultProfile", t => {
  40. const state = {
  41. password: {
  42. login: "test@example.org",
  43. site: "example.org",
  44. uppercase: true,
  45. lowercase: true,
  46. numbers: true,
  47. symbols: true,
  48. length: 16,
  49. counter: 1,
  50. version: 2
  51. },
  52. defaultPassword: {
  53. login: "",
  54. site: "",
  55. uppercase: true,
  56. lowercase: true,
  57. numbers: true,
  58. symbols: true,
  59. length: 16,
  60. counter: 1,
  61. version: 2
  62. }
  63. };
  64. t.true(getters.isDefaultProfile(state));
  65. });
  66. test("isDefaultProfile false", t => {
  67. const state = {
  68. password: {
  69. login: "test@example.org",
  70. site: "example.org",
  71. uppercase: true,
  72. lowercase: true,
  73. numbers: true,
  74. symbols: false,
  75. length: 32,
  76. counter: 1,
  77. version: 1
  78. },
  79. defaultPassword: {
  80. login: "",
  81. site: "",
  82. uppercase: true,
  83. lowercase: true,
  84. numbers: true,
  85. symbols: true,
  86. length: 16,
  87. counter: 1,
  88. version: 2
  89. }
  90. };
  91. t.false(getters.isDefaultProfile(state));
  92. });
  93. test("isAuthenticated", t => {
  94. const state = {
  95. authenticated: true
  96. };
  97. t.true(getters.isAuthenticated(state));
  98. t.false(getters.isGuest(state));
  99. });
  100. test("isGuest", t => {
  101. const state = {
  102. authenticated: false
  103. };
  104. t.false(getters.isAuthenticated(state));
  105. t.true(getters.isGuest(state));
  106. });