fix: tasksLoaded tests (#1106)
This commit is contained in:
@@ -14,21 +14,11 @@
|
|||||||
"homepage": ".",
|
"homepage": ".",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
||||||
"start": "react-app-rewired start",
|
"start": "react-scripts start",
|
||||||
"prepublishOnly": "npm run build",
|
|
||||||
"clean-deploy-cache": "rm -rf node_modules/.cache/gh-pages",
|
|
||||||
"predeploy": "yarn run pretty && yarn run build && yarn clean-deploy-cache",
|
|
||||||
"deploy-build": "yarn run predeploy && gh-pages -b build -d build",
|
|
||||||
"deploy-dev": "yarn run predeploy && gh-pages -b dev -d build",
|
|
||||||
"deploy-stable": "yarn run predeploy && gh-pages -b gh-pages -d build",
|
|
||||||
"test:coverage": "npm run test -- --coverage --watchAll",
|
"test:coverage": "npm run test -- --coverage --watchAll",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"serve": "serve -s -p 3000 build",
|
"components:compile": "react-scripts build",
|
||||||
"server-public": "http-server -p 3000 --cors",
|
"components:test": "react-scripts test --watchAll=false",
|
||||||
"server-root": "http-server ./ -p 3000 --cors",
|
|
||||||
"server": "http-server ./build -p 3000 --cors",
|
|
||||||
"components:compile": "react-app-rewired build",
|
|
||||||
"components:test": "react-app-rewired test --watchAll=false",
|
|
||||||
"components:lint": "prettier --write 'src/**/*.{html,css,scss,js,jsx,ts,tsx,json}' README.md"
|
"components:lint": "prettier --write 'src/**/*.{html,css,scss,js,jsx,ts,tsx,json}' README.md"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
|||||||
@@ -8,13 +8,6 @@
|
|||||||
],
|
],
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/standardnotes/advanced-checklist.git"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/standardnotes/advanced-checklist/issues"
|
|
||||||
},
|
|
||||||
"sn": {
|
"sn": {
|
||||||
"main": "index.html"
|
"main": "index.html"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,5 @@
|
|||||||
"url": "http://localhost:3000/index.html",
|
"url": "http://localhost:3000/index.html",
|
||||||
"download_url": "",
|
"download_url": "",
|
||||||
"latest_url": "",
|
"latest_url": "",
|
||||||
"marketing_url": "https://github.com/standardnotes/advanced-checklist",
|
|
||||||
"thumbnail_url": ""
|
"thumbnail_url": ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -535,8 +535,16 @@ it('should handle loading tasks into the tasks store, if an invalid payload is p
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(reducer(previousState, tasksLoaded('null'))).toEqual(previousState)
|
expect(reducer(previousState, tasksLoaded('null'))).toEqual({
|
||||||
expect(reducer(previousState, tasksLoaded('undefined'))).toEqual(previousState)
|
schemaVersion: '1.0.0',
|
||||||
|
groups: [],
|
||||||
|
initialized: true
|
||||||
|
})
|
||||||
|
expect(reducer(previousState, tasksLoaded('undefined'))).toMatchObject({
|
||||||
|
...previousState,
|
||||||
|
initialized: false,
|
||||||
|
lastError: expect.stringContaining('An error has occurred while parsing the note\'s content')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should initialize the storage with an empty object', () => {
|
it('should initialize the storage with an empty object', () => {
|
||||||
@@ -564,28 +572,6 @@ it('should initialize the storage with an empty object', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not initialize the storage again with an empty object', () => {
|
|
||||||
const previousState: TasksState = {
|
|
||||||
schemaVersion: '1.0.0',
|
|
||||||
groups: [
|
|
||||||
{
|
|
||||||
name: 'Test',
|
|
||||||
tasks: [
|
|
||||||
{
|
|
||||||
id: 'another-id',
|
|
||||||
description: 'Another simple task',
|
|
||||||
completed: false,
|
|
||||||
createdAt: new Date(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
initialized: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(reducer(previousState, tasksLoaded(''))).toEqual(previousState)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should handle loading tasks into the tasks store, with a valid payload', () => {
|
it('should handle loading tasks into the tasks store, with a valid payload', () => {
|
||||||
const previousState: TasksState = {
|
const previousState: TasksState = {
|
||||||
schemaVersion: '1.0.0',
|
schemaVersion: '1.0.0',
|
||||||
|
|||||||
@@ -295,8 +295,8 @@ const tasksSlice = createSlice({
|
|||||||
|
|
||||||
const parsedState = JSON.parse(payload) as TasksState
|
const parsedState = JSON.parse(payload) as TasksState
|
||||||
const newState: TasksState = {
|
const newState: TasksState = {
|
||||||
schemaVersion: parsedState.schemaVersion ?? '1.0.0',
|
schemaVersion: parsedState?.schemaVersion ?? '1.0.0',
|
||||||
groups: parsedState.groups ?? [],
|
groups: parsedState?.groups ?? [],
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newState !== initialState) {
|
if (newState !== initialState) {
|
||||||
|
|||||||
Reference in New Issue
Block a user