form_language.js 1023 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. QUnit.test('form language checks', (assert) => {
  2. App.Config.set('locale_default', 'de-de')
  3. $('#forms').append('<hr><h1>form language #1</h1><form id="form1"></form>')
  4. var el = $('#form1')
  5. new App.ControllerForm({
  6. el: el,
  7. model: {
  8. configure_attributes: [
  9. { name: 'language', display: 'Language', tag: 'language', null: false }
  10. ]
  11. },
  12. });
  13. var params = App.ControllerForm.params(el)
  14. assert.deepEqual(params, { language: 'de-de' }, 'default/fallback param check')
  15. })
  16. QUnit.test('initial value', (assert) => {
  17. App.Config.set('locale_default', 'de-de')
  18. $('#forms').append('<hr><h1>form language #1</h1><form id="form2"></form>')
  19. var el = $('#form2')
  20. new App.ControllerForm({
  21. el: el,
  22. model: {
  23. configure_attributes: [
  24. { name: 'language', display: 'Language', tag: 'language', null: false, value: 'en-us' }
  25. ]
  26. },
  27. });
  28. var params = App.ControllerForm.params(el)
  29. assert.deepEqual(params, { language: 'en-us' }, 'initial param check')
  30. })