mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
886328ff7a
Great breakdown of React changes here: https://github.com/facebook/react/blob/master/CHANGELOG.md#0140-october-7-2015 Due to deprecation warnings, I don't think this will break third-party extensions unless they were doing really bad things.
42 lines
1.7 KiB
CoffeeScript
42 lines
1.7 KiB
CoffeeScript
moment = require 'moment'
|
|
React = require "react"
|
|
ReactDOM = require "react-dom"
|
|
ReactTestUtils = require 'react-addons-test-utils'
|
|
MessageTimestamp = require '../lib/message-timestamp'
|
|
|
|
msgTime = ->
|
|
moment([2010, 1, 14, 15, 25, 50, 125]) # Feb 14, 2010 at 3:25 PM
|
|
|
|
describe "MessageTimestamp", ->
|
|
beforeEach ->
|
|
@item = ReactTestUtils.renderIntoDocument(
|
|
<MessageTimestamp date={msgTime()} />
|
|
)
|
|
|
|
it "still processes one day, even if it crosses a month divider", ->
|
|
# this should be tested in moment.js, but we add a test here for our own sanity too
|
|
feb28 = moment([2015, 1, 28])
|
|
mar01 = moment([2015, 2, 1])
|
|
expect(mar01.diff(feb28, 'days')).toBe 1
|
|
|
|
it "displays the full time when in detailed timestamp mode", ->
|
|
expect(@item._formattedDate(msgTime(), null, true)).toBe "February 14, 2010 at 3:25 PM"
|
|
|
|
it "displays the time from messages shown today", ->
|
|
now = msgTime().add(2, 'hours')
|
|
expect(@item._formattedDate(msgTime(), now)).toBe "3:25 PM"
|
|
|
|
it "displays the time from messages yesterday with the relative time if it's less than 36 hours ago", ->
|
|
now = msgTime().add(21, 'hours')
|
|
expect(@item._formattedDate(msgTime(), now)).toBe "3:25 PM (21 hours ago)"
|
|
|
|
now = msgTime().add(30, 'hours')
|
|
expect(@item._formattedDate(msgTime(), now)).toBe "3:25 PM (a day ago)"
|
|
|
|
it "displays month, day for messages less than a year ago, but more than 24 hours ago", ->
|
|
now = msgTime().add(2, 'months')
|
|
expect(@item._formattedDate(msgTime(), now)).toBe "Feb 14"
|
|
|
|
it "displays month, day, and year for messages over a year ago", ->
|
|
now = msgTime().add(2, 'years')
|
|
expect(@item._formattedDate(msgTime(), now)).toBe "Feb 14, 2010"
|