prepareStatus: created_at_parsed.

environments/dev/deployments/1
Roger Braun 8 years ago
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…
Cancel
Save