From f555dc486d1d3df0b6a238edec06ffedb22946b1 Mon Sep 17 00:00:00 2001 From: Gilgard <Hjelljord.alida@gmail.com> Date: Mon, 2 May 2022 15:03:00 +0200 Subject: [PATCH] funktional mocking of route and store --- tests/unit/mock-router.js | 21 +++++++++++++++++++++ tests/unit/mock-store.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tests/unit/mock-router.js create mode 100644 tests/unit/mock-store.js diff --git a/tests/unit/mock-router.js b/tests/unit/mock-router.js new file mode 100644 index 0000000..f4f46df --- /dev/null +++ b/tests/unit/mock-router.js @@ -0,0 +1,21 @@ +// route id param for pages that require routing +// id = 1, user = test testesen +export const route = { + params: { + id: 1 + } +}; + +export const router = { +push: jest.fn() +}; + +export const $route = { + params: { + id: 1 + } +}; + +export const $router = { +push: jest.fn() +}; \ No newline at end of file diff --git a/tests/unit/mock-store.js b/tests/unit/mock-store.js new file mode 100644 index 0000000..c31cc0f --- /dev/null +++ b/tests/unit/mock-store.js @@ -0,0 +1,34 @@ +const user = { + state: { + token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmaXJzdE5hbWUiOiJUZXN0IiwibGFzdE5hbWUiOiJUZXN0ZXNlbiIsImFjY291bnRJZCI6IjEiLCJleHAiOjE2NTE2NTQxNDUsImVtYWlsIjoidGVzdEB0ZXN0LmNvbSJ9.LnOYs_9WLusp463bQo9aXPcNGI4ooz7uI3iiMrnSPTY", + }, + + mutations: { + logout(state) { + state.token = null; + }, + saveToken(state, token) { + state.token = token; + }, + }, +} + +export const store = { + state: { + user, + }, + modules: { + user, + }, + commit: jest.fn() +} + +export const $store = { + state: { + user, + }, + modules: { + user, + }, + commit: jest.fn() +} \ No newline at end of file -- GitLab