Test sort by due date

This commit is contained in:
Raimund Schlüßler 2019-04-22 21:38:52 +02:00
parent a7df0b425e
commit 2150c2f39c
No known key found for this signature in database
GPG key ID: 036FA7EB1A599178
3 changed files with 48 additions and 0 deletions

6
package-lock.json generated
View file

@ -10513,6 +10513,12 @@
}
}
},
"moment": {
"version": "2.24.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==",
"dev": true
},
"move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

View file

@ -73,6 +73,7 @@
"jsdom": "^15.0.0",
"jsdom-global": "^3.0.2",
"node-sass": "^4.11.0",
"moment": "^2.24.0",
"prettier-eslint": "^8.8.2",
"raw-loader": "^2.0.0",
"sass-loader": "^7.1.0",

View file

@ -0,0 +1,41 @@
import moment from 'moment'
import { sort } from '@/store/storeHelper'
global.moment = moment
const tasks = [
{
id: 1,
due: '20191119T183901'
},
{
id: 2,
due: '20181119T183901'
},
{
id: 3,
due: null
},
{
id: 4,
due: '20151119T183901'
},
]
describe('storeHelper', () => {
'use strict'
it('Tests descending sort by due date.', () => {
const clonedTasks = tasks.slice(0)
const expectedTasks = [tasks[3], tasks[1], tasks[0], tasks[2]]
const receivedTasks = sort(clonedTasks, 'due', 0)
expect(receivedTasks).toEqual(expectedTasks)
})
it('Tests ascending sort by due date.', () => {
const clonedTasks = tasks.slice(0)
const expectedTasks = [tasks[2], tasks[0], tasks[1], tasks[3]]
const receivedTasks = sort(clonedTasks, 'due', 1)
expect(receivedTasks).toEqual(expectedTasks)
})
})