summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js39
1 files changed, 38 insertions, 1 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index 35431904cec..0e1bb096e50 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -24,7 +24,7 @@ QUnit.module('basic_fields', {
date: {string: "A date", type: "date", searchable: true},
datetime: {string: "A datetime", type: "datetime", searchable: true},
display_name: {string: "Displayed name", type: "char", searchable: true},
- foo: {string: "Foo", type: "char", default: "My little Foo Value", searchable: true},
+ foo: {string: "Foo", type: "char", default: "My little Foo Value", searchable: true, trim: true},
bar: {string: "Bar", type: "boolean", default: true, searchable: true},
txt: {string: "txt", type: "text", default: "My little txt Value\nHo-ho-hoooo Merry Christmas"},
int_field: {string: "int_field", type: "integer", sortable: true, searchable: true},
@@ -876,6 +876,43 @@ QUnit.module('basic_fields', {
form.destroy();
});
+ QUnit.test('char field trim (or not) characters', function (assert) {
+ assert.expect(2);
+
+ this.data.partner.fields.foo2 = {string: "Foo2", type: "char", trim: false};
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<sheet>' +
+ '<group>' +
+ '<field name="foo"/>' +
+ '<field name="foo2"/>' +
+ '</group>' +
+ '</sheet>' +
+ '</form>',
+ res_id: 1,
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ form.$('input[name="foo"]').val(' abc ').trigger('input');
+ form.$('input[name="foo2"]').val(' def ').trigger('input');
+
+ form.$buttons.find('.o_form_button_save').click();
+
+ // edit mode
+ form.$buttons.find('.o_form_button_edit').click();
+
+ assert.strictEqual(form.$('input[name="foo"]').val(), 'abc', 'Foo value should have been trimmed');
+ assert.strictEqual(form.$('input[name="foo2"]').val(), ' def ', 'Foo2 value should not have been trimmed');
+
+ form.destroy();
+ });
+
QUnit.test('input field: change value before pending onchange returns', function (assert) {
assert.expect(3);