diff options
| author | Vincent Schippefilt <vsc@odoo.com> | 2019-03-06 14:02:32 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-03-06 20:07:17 +0100 |
| commit | ab56e637b7f97ddcdbcc9baea99ae097e342409c (patch) | |
| tree | 4cb47da9f7ef89b19d18429220a7507470ec12a9 /addons/web/static/tests/views/abstract_controller_tests.js | |
| parent | eeed894fd50e477135e1ac9a82f6e98ce063ab90 (diff) | |
[REF] web: adapt code after jQuery update
Part of task 1896658
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Christophe Matthieu <chm@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
Co-authored-by: Martin Geubelle <mge@odoo.com>
Co-authored-by: svs-odoo <svs@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
Diffstat (limited to 'addons/web/static/tests/views/abstract_controller_tests.js')
| -rw-r--r-- | addons/web/static/tests/views/abstract_controller_tests.js | 151 |
1 files changed, 72 insertions, 79 deletions
diff --git a/addons/web/static/tests/views/abstract_controller_tests.js b/addons/web/static/tests/views/abstract_controller_tests.js index f9045645bc6..e0fa433b13c 100644 --- a/addons/web/static/tests/views/abstract_controller_tests.js +++ b/addons/web/static/tests/views/abstract_controller_tests.js @@ -1,89 +1,82 @@ -odoo.define("base.abstract_controller_tests", function(require) { - "use strict"; +odoo.define("base.abstract_controller_tests", function (require) { +"use strict"; - var testUtils = require("web.test_utils"); - var createView = testUtils.createView; - var BasicView = require("web.BasicView"); - var BasicRenderer = require("web.BasicRenderer"); +var testUtils = require("web.test_utils"); +var createView = testUtils.createView; +var BasicView = require("web.BasicView"); +var BasicRenderer = require("web.BasicRenderer"); - function getHtmlRenderer(html) { - return BasicRenderer.extend({ - start: function() { - this.$el.html(html); - return this._super.apply(this, arguments); - } - }); - } - function getHtmlView(html, viewType) { - viewType = viewType || "test"; - return BasicView.extend({ - viewType: viewType, - config: _.extend({}, BasicView.prototype.config, { - Renderer: getHtmlRenderer(html) - }) - }); - } +function getHtmlRenderer(html) { + return BasicRenderer.extend({ + start: function () { + this.$el.html(html); + return this._super.apply(this, arguments); + } + }); +} +function getHtmlView(html, viewType) { + viewType = viewType || "test"; + return BasicView.extend({ + viewType: viewType, + config: _.extend({}, BasicView.prototype.config, { + Renderer: getHtmlRenderer(html) + }) + }); +} - QUnit.module( - "Views", - { - beforeEach: function() { - this.data = { - test_model: { - fields: {}, - records: [] - } - }; +QUnit.module("Views", { + beforeEach: function () { + this.data = { + test_model: { + fields: {}, + records: [] } - }, - function() { - - QUnit.module('AbstractController'); - - QUnit.test( - 'click on a a[type="action"] child triggers the correct action', - function(assert) { - assert.expect(7); + }; + } +}, function () { + QUnit.module('AbstractController'); - var html = - "<div>" + - '<a name="a1" type="action" class="simple">simple</a>' + - '<a name="a2" type="action" class="with-child">' + - "<span>child</input>" + - "</a>" + - '<a type="action" data-model="foo" data-method="bar" class="method">method</a>' + - '<a type="action" data-model="foo" data-res-id="42" class="descr">descr</a>' + - '<a type="action" data-model="foo" class="descr2">descr2</a>' + - "</div>"; + QUnit.test('click on a a[type="action"] child triggers the correct action', async function (assert) { + assert.expect(7); - var view = createView({ - View: getHtmlView(html, "test"), - data: this.data, - model: "test_model", - arch: "<test/>", - intercepts: { - do_action: function (event) { - assert.step(event.data.action.name || event.data.action); - } - }, - mockRPC: function (route, args) { - if (args.model === 'foo' && args.method === 'bar') { - assert.step("method"); - return $.when({name: 'method'}); - } - return this._super.apply(this, arguments); - } - }); - testUtils.dom.click(view.$(".simple")); - testUtils.dom.click(view.$(".with-child span")); - testUtils.dom.click(view.$(".method")); - testUtils.dom.click(view.$(".descr")); - testUtils.dom.click(view.$(".descr2")); - assert.verifySteps(["a1", "a2", "method", "method", "descr", "descr2"]); + var html = + "<div>" + + '<a name="a1" type="action" class="simple">simple</a>' + + '<a name="a2" type="action" class="with-child">' + + "<span>child</input>" + + "</a>" + + '<a type="action" data-model="foo" data-method="bar" class="method">method</a>' + + '<a type="action" data-model="foo" data-res-id="42" class="descr">descr</a>' + + '<a type="action" data-model="foo" class="descr2">descr2</a>' + + "</div>"; - view.destroy(); + var view = await createView({ + View: getHtmlView(html, "test"), + data: this.data, + model: "test_model", + arch: "<test/>", + intercepts: { + do_action: function (event) { + assert.step(event.data.action.name || event.data.action); } - ); - } + }, + mockRPC: function (route, args) { + if (args.model === 'foo' && args.method === 'bar') { + assert.step("method"); + return Promise.resolve({name: 'method'}); + } + return this._super.apply(this, arguments); + } + }); + await testUtils.dom.click(view.$(".simple")); + await testUtils.dom.click(view.$(".with-child span")); + await testUtils.dom.click(view.$(".method")); + await testUtils.dom.click(view.$(".descr")); + await testUtils.dom.click(view.$(".descr2")); + assert.verifySteps(["a1", "a2", "method", "method", "descr", "descr2"]); + + view.destroy(); + } ); }); +}); |
