summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorMartin Geubelle <mge@odoo.com>2017-10-19 12:00:50 +0200
committerMartin Geubelle <mge@odoo.com>2017-10-20 11:04:08 +0200
commit1312ee72cf35e3887721ac56472f1188f636ec61 (patch)
tree9958185c32904705d8a092acf7fab8dfc1ef40ba /addons/web/static/tests/fields/basic_fields_tests.js
parent0fc6fe8653952b359aa16f79eb22129217dbd101 (diff)
[FIX] web: correctly render the field image
Before this commit, the image was directly built without using the corresponding template, which set some properties on the image (class, width, etc.).
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index ada39fe3a29..1e3233128d6 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -1424,6 +1424,42 @@ QUnit.module('basic_fields', {
}
});
+ QUnit.module('FieldImage');
+
+ QUnit.test('image fields are correctly rendered', function (assert) {
+ assert.expect(5);
+
+ this.data.partner.records[0].document = 'myimage';
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="document" widget="image" options="{\'size\': [90, 90]}"/> ' +
+ '</form>',
+ res_id: 1,
+ mockRPC: function (route) {
+ if (route === 'data:image/png;base64,myimage') {
+ assert.ok(true, "should called the correct route");
+ return $.when('wow');
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ assert.ok(form.$('div[name="document"]').hasClass('o_field_image'),
+ "the widget should have the correct class");
+ assert.strictEqual(form.$('div[name="document"] > img').length, 1,
+ "the widget should contain an image");
+ assert.ok(form.$('div[name="document"] > img').hasClass('img-responsive'),
+ "the image should have the correct class");
+ assert.strictEqual(form.$('div[name="document"] > img').attr('width'), "90",
+ "the image should correctly set its attributes");
+ form.destroy();
+
+ });
+
QUnit.module('JournalDashboardGraph');
QUnit.test('graph dashboard widget is rendered correctly', function (assert) {