2015-02-25 08:20:57 +08:00
|
|
|
moment = require 'moment'
|
2016-03-29 16:41:24 +08:00
|
|
|
React = require "react"
|
|
|
|
ReactDOM = require "react-dom"
|
|
|
|
ReactTestUtils = require 'react-addons-test-utils'
|
2016-08-19 09:11:52 +08:00
|
|
|
MessageTimestamp = require('../lib/message-timestamp').default
|
2015-02-25 08:20:57 +08:00
|
|
|
|
2015-08-13 05:52:03 +08:00
|
|
|
msgTime = ->
|
2016-01-12 08:23:04 +08:00
|
|
|
moment([2010, 1, 14, 15, 25, 50, 125]) # Feb 14, 2010 at 3:25 PM
|
2015-02-25 08:20:57 +08:00
|
|
|
|
|
|
|
describe "MessageTimestamp", ->
|
|
|
|
beforeEach ->
|
2016-03-29 16:41:24 +08:00
|
|
|
@item = ReactTestUtils.renderIntoDocument(
|
2015-08-13 05:52:03 +08:00
|
|
|
<MessageTimestamp date={msgTime()} />
|
2015-02-25 08:20:57 +08:00
|
|
|
)
|
2015-03-10 02:17:22 +08:00
|
|
|
|
2015-08-13 05:52:03 +08:00
|
|
|
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
|