prepareStatus: created_at_parsed.

This commit is contained in:
Roger Braun 2016-11-13 22:54:49 +01:00
parent 59647798b9
commit aeb8868b82
2 changed files with 13 additions and 0 deletions

View File

@ -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
}

View File

@ -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', () => {