Sha256: 24956a20f67745212fe53d295f419326967d00b1e1c6498569fbeaa776b53180

Contents?: true

Size: 802 Bytes

Versions: 4

Compression:

Stored size: 802 Bytes

Contents

module "localized"

for id in ["one", "two", "past", "future"]
  test id, ->
    assertLocalized id

test "date", ->
  assertLocalized "date", "date"

test "unparseable time", ->
  el = addTimeEl format: "%Y", datetime: ":("
  setText el, "2013"
  run()
  equal getText(el), "2013"


assertLocalized = (id, type = "time") ->
  switch type
    when "time"
      momentFormat = "MMMM D, YYYY h:mma"
      compare = "toString"
    when "date"
      momentFormat = "MMMM D, YYYY"
      compare = "dayOfYear"

  el = document.getElementById id

  ok datetime = el.getAttribute "datetime"
  ok local = getText el

  datetimeParsed = moment datetime
  localParsed = moment local, momentFormat

  ok datetimeParsed.isValid()
  ok localParsed.isValid()
  equal datetimeParsed[compare](), localParsed[compare]()

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
local_time-1.0.3 test/javascripts/src/local_time_test.js.coffee
local_time-1.0.2 test/javascripts/local_time/local_time_test.js.coffee
local_time-1.0.1 test/javascripts/local_time/local_time_test.js.coffee
local_time-1.0.0 test/javascripts/local_time/local_time_test.js.coffee