prepareStatus: created_at_parsed.
This commit is contained in:
parent
59647798b9
commit
aeb8868b82
@ -115,11 +115,15 @@ export const findMaxId = (...args) => {
|
||||
}
|
||||
|
||||
export const prepareStatus = (status) => {
|
||||
// Parse nsfw tags
|
||||
if (status.nsfw === undefined) {
|
||||
const nsfwRegex = /#nsfw/i
|
||||
status.nsfw = !!status.text.match(nsfwRegex)
|
||||
}
|
||||
|
||||
// Set created_at_parsed to initial value
|
||||
status.created_at_parsed = status.created_at
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,15 @@ describe('Statuses.prepareStatus', () => {
|
||||
|
||||
expect(prepareStatus(nsfw).nsfw).to.eq(false)
|
||||
})
|
||||
|
||||
it('sets the created_at_parsed property', () => {
|
||||
const status = makeMockStatus({id: 1})
|
||||
status.created_at = ''
|
||||
expect(status.created_at_parsed).to.eq(undefined)
|
||||
|
||||
const prepared = prepareStatus(status)
|
||||
expect(prepared.created_at_parsed).to.not.eq(undefined)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Statuses.findMaxId', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user