|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import test from "ava";
- import * as getters from "../../src/store/getters";
-
- test("version", t => {
- const state = {
- password: { version: 1 },
- defaultPassword: { version: 2 }
- };
- const version = getters.version(state);
- t.is(version, 1);
- });
-
- test("version no password return default password version", t => {
- const state = {
- password: null,
- defaultPassword: { version: 2 }
- };
- const version = getters.version(state);
- t.is(version, 2);
- });
-
- test("passwordURL", t => {
- const state = {
- password: {
- login: "test@example.org",
- site: "example.org",
- uppercase: true,
- lowercase: true,
- numbers: true,
- symbols: false,
- length: 16,
- counter: 1,
- version: 2
- },
- baseURL: "https://lesspass.com"
- };
-
- t.is(
- getters.passwordURL(state),
- "https://lesspass.com/#/?login=test@example.org&site=example.org&uppercase=true&lowercase=true&numbers=true&symbols=false&length=16&counter=1&version=2"
- );
- });
-
- test("isDefaultProfile", t => {
- const state = {
- password: {
- login: "test@example.org",
- site: "example.org",
- uppercase: true,
- lowercase: true,
- numbers: true,
- symbols: true,
- length: 16,
- counter: 1,
- version: 2
- },
- defaultPassword: {
- login: "",
- site: "",
- uppercase: true,
- lowercase: true,
- numbers: true,
- symbols: true,
- length: 16,
- counter: 1,
- version: 2
- }
- };
- t.true(getters.isDefaultProfile(state));
- });
-
- test("isDefaultProfile false", t => {
- const state = {
- password: {
- login: "test@example.org",
- site: "example.org",
- uppercase: true,
- lowercase: true,
- numbers: true,
- symbols: false,
- length: 32,
- counter: 1,
- version: 1
- },
- defaultPassword: {
- login: "",
- site: "",
- uppercase: true,
- lowercase: true,
- numbers: true,
- symbols: true,
- length: 16,
- counter: 1,
- version: 2
- }
- };
- t.false(getters.isDefaultProfile(state));
- });
-
- test("isAuthenticated", t => {
- const state = {
- authenticated: true
- };
- t.true(getters.isAuthenticated(state));
- t.false(getters.isGuest(state));
- });
-
- test("isGuest", t => {
- const state = {
- authenticated: false
- };
- t.false(getters.isAuthenticated(state));
- t.true(getters.isGuest(state));
- });
|