Sha256: 18e5361c9418706a31153c9bb6f354bfb934cfef33279a821d4bcf04ff551b16

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 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 "%Y", ":("
  el.innerText = "2013"
  run()
  equal el.innerText, "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 = el.innerText

  datetimeParsed = moment datetime
  localParsed = moment local, momentFormat

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
local_time-0.1.0 test/javascripts/unit/local_time_test.js.coffee