fix: tasksLoaded tests (#1106)

This commit is contained in:
Johnny A
2022-06-15 11:43:43 -04:00
committed by GitHub
parent 3fc87fed00
commit 008452fd86
5 changed files with 15 additions and 47 deletions

View File

@@ -14,21 +14,11 @@
"homepage": ".",
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
"start": "react-app-rewired 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",
"start": "react-scripts start",
"test:coverage": "npm run test -- --coverage --watchAll",
"eject": "react-scripts eject",
"serve": "serve -s -p 3000 build",
"server-public": "http-server -p 3000 --cors",
"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:compile": "react-scripts build",
"components:test": "react-scripts test --watchAll=false",
"components:lint": "prettier --write 'src/**/*.{html,css,scss,js,jsx,ts,tsx,json}' README.md"
},
"eslintConfig": {

View File

@@ -8,13 +8,6 @@
],
"private": true,
"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": {
"main": "index.html"
}

View File

@@ -8,6 +8,5 @@
"url": "http://localhost:3000/index.html",
"download_url": "",
"latest_url": "",
"marketing_url": "https://github.com/standardnotes/advanced-checklist",
"thumbnail_url": ""
}

View File

@@ -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('undefined'))).toEqual(previousState)
expect(reducer(previousState, tasksLoaded('null'))).toEqual({
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', () => {
@@ -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', () => {
const previousState: TasksState = {
schemaVersion: '1.0.0',

View File

@@ -295,8 +295,8 @@ const tasksSlice = createSlice({
const parsedState = JSON.parse(payload) as TasksState
const newState: TasksState = {
schemaVersion: parsedState.schemaVersion ?? '1.0.0',
groups: parsedState.groups ?? [],
schemaVersion: parsedState?.schemaVersion ?? '1.0.0',
groups: parsedState?.groups ?? [],
}
if (newState !== initialState) {