Sha256: 0df90ed5cf1cb47be6d6994eb72936323436500018cfbd0e283619a2bb77101d

Contents?: true

Size: 1.4 KB

Versions: 6

Compression:

Stored size: 1.4 KB

Contents

{addTimeEl, assert, defer, getText, setText, test, testAsync, testGroup, triggerEvent} = LocalTime.TestHelpers
{config} = LocalTime
{i18n} = config

testGroup "i18n", ->
  testAsync "updating a value", (done) ->
    now = moment()
    values = i18n[config.defaultLocale].date

    originalValue = values.today
    values.today = "2day"

    el = addTimeEl type: "weekday", datetime: now.toISOString()
    defer ->
      assert.equal getText(el), "2day"
      assert.equal getText(el), "2day"
      values.today = originalValue
      done()

  testAsync "adding a new locale", (done) ->
    now = moment()

    originalLocale = config.locale
    config.locale = "es"
    i18n.es = date: today: "hoy"

    el = addTimeEl type: "weekday", datetime: now.toISOString()
    defer ->
      assert.equal getText(el), "hoy"
      config.locale = originalLocale
      done()

  testAsync "falling back to the default locale", (done) ->
    now = moment()
    yesterday = moment().subtract("days", 1)

    originalLocale = config.locale
    config.locale = "es"
    i18n.es = date: yesterday: "ayer"

    elWithTranslation = addTimeEl type: "weekday", datetime: yesterday.toISOString()
    elWithoutTranslation = addTimeEl type: "weekday", datetime: now.toISOString()
    defer ->
      assert.equal getText(elWithTranslation), "ayer"
      assert.equal getText(elWithoutTranslation), "today"
      config.locale = originalLocale
      done()

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/local_time-2.1.0/test/javascripts/src/i18n_test.coffee
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/local_time-2.1.0/test/javascripts/src/i18n_test.coffee
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/local_time-2.1.0/test/javascripts/src/i18n_test.coffee
local_time-2.1.0 test/javascripts/src/i18n_test.coffee
local_time-2.0.1 test/javascripts/src/i18n_test.coffee
local_time-2.0.0 test/javascripts/src/i18n_test.coffee