Handle sorting with unsubmitted requests
This commit is contained in:
parent
ebbdbfe1c7
commit
800fa94363
@ -55,5 +55,21 @@ describe('RequestsList', () => {
|
|||||||
const requestNames = displayedRequests.map(req => req.name)
|
const requestNames = displayedRequests.map(req => req.name)
|
||||||
expect(requestNames).toEqual(['X Wing', 'TIE Fighter'])
|
expect(requestNames).toEqual(['X Wing', 'TIE Fighter'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('handles sorting with un-submitted requests', () => {
|
||||||
|
const unsubmittedRequest = {
|
||||||
|
name: 'Death Star',
|
||||||
|
status: 'Started',
|
||||||
|
last_submission_timestamp: null
|
||||||
|
}
|
||||||
|
const wrapper = shallowMount(RequestsList, {
|
||||||
|
propsData: {
|
||||||
|
requests: [unsubmittedRequest, ...requests],
|
||||||
|
isExtended: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const displayedRequests = wrapper.vm.filteredRequests
|
||||||
|
expect(displayedRequests).toEqual([requests[1], requests[0], unsubmittedRequest])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import LocalDatetime from '../components/local_datetime'
|
import LocalDatetime from '../components/local_datetime'
|
||||||
import { formatDollars } from '../lib/dollars'
|
import { formatDollars } from '../lib/dollars'
|
||||||
import { parse } from 'date-fns'
|
import { parse } from 'date-fns'
|
||||||
import { compose, partial, indexBy, prop, sortBy, reverse, pipe } from 'ramda'
|
import { compose, partial, indexBy, prop, propOr, sortBy, reverse, pipe } from 'ramda'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'requests-list',
|
name: 'requests-list',
|
||||||
@ -32,7 +32,7 @@ export default {
|
|||||||
data: function () {
|
data: function () {
|
||||||
const defaultSort = (sort, requests) => sortBy(prop(sort.columnName), requests)
|
const defaultSort = (sort, requests) => sortBy(prop(sort.columnName), requests)
|
||||||
const dateSort = (sort, requests) => {
|
const dateSort = (sort, requests) => {
|
||||||
const parseDate = compose(partial(parse), prop(sort.columnName))
|
const parseDate = compose(partial(parse), propOr(sort.columnName, ''))
|
||||||
return sortBy(parseDate, requests)
|
return sortBy(parseDate, requests)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user