Sha256: 6b290b5a85784f9fa26ca3f3d2e35476525f7a5a70223fbc6f6465acb43a1ede

Contents?: true

Size: 794 Bytes

Versions: 4

Compression:

Stored size: 794 Bytes

Contents

describe 'App.Validators.Inclusion', ->
  beforeEach ->
    @dummy = new App.Models.Dummy rate: 'decent'

  afterEach -> App.Env.loco.setLocale 'en'

  it 'adds error if value is not available in an array', ->
    @dummy.isValid()
    expect(@dummy.errors.rate[0]).toEqual "is not included in the list"

  it 'is valid if value is available in an array', ->
    @dummy.rate = 'good'
    @dummy.isValid()
    expect(@dummy.errors.rate).toBe undefined

  it 'supports i18n', ->
    App.Env.loco.setLocale 'pl'
    @dummy.isValid()
    expect(@dummy.errors.rate[0]).toEqual "nie znajduje się na liście dopuszczalnych wartości"

  it 'supports custom message', ->
    dcm = new App.Models.DummyCustomMsg rate: 'decent'
    dcm.isValid()
    expect(dcm.errors.rate[0]).toEqual 'value is not good'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
loco-rails-3.0.3 test/dummy/node_modules/loco-js/spec_coffee/loco/validators/inclusion_spec.coffee
loco-rails-3.0.2 test/dummy/node_modules/loco-js/spec_coffee/loco/validators/inclusion_spec.coffee
loco-rails-3.0.1 test/dummy/node_modules/loco-js/spec_coffee/loco/validators/inclusion_spec.coffee
loco-rails-3.0.0 test/dummy/node_modules/loco-js/spec_coffee/loco/validators/inclusion_spec.coffee