Permalink
Browse files

[FIX] web,mrp: move test to adequate module

  • Loading branch information...
KangOl committed Oct 10, 2018
1 parent c8633bc commit 32b19115e9d7470531f3218b39e8773ba5361bba
Showing with 44 additions and 44 deletions.
  1. +0 −44 addons/mrp/static/tests/mrp_tests.js
  2. +44 −0 addons/web/static/tests/fields/basic_fields_tests.js
@@ -1,7 +1,6 @@
odoo.define('mrp.tests', function (require) {
"use strict";
var field_registry = require('web.field_registry');
var FormView = require('web.FormView');
var testUtils = require("web.test_utils");
@@ -30,49 +29,6 @@ QUnit.module('mrp', {
},
}, function () {
QUnit.test("pdf_viewer: upload rendering", function (assert) {
assert.expect(6);
testUtils.patch(field_registry.map.pdf_viewer, {
on_file_change: function (ev) {
ev.target = {files: [new Blob()]};
this._super.apply(this, arguments);
},
_getURI: function (fileURI) {
var res = this._super.apply(this, arguments);
assert.step('_getURI');
assert.ok(_.str.startsWith(fileURI, 'blob:'));
this.PDFViewerApplication = {
open: function (URI) {
assert.step('open');
assert.ok(_.str.startsWith(URI, 'blob:'));
},
};
return 'about:blank';
},
});
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch:
'<form>' +
'<field name="document" widget="pdf_viewer"/>' +
'</form>',
});
// first upload initialize iframe
form.$('input[type="file"]').trigger('change');
assert.verifySteps(['_getURI']);
// second upload call pdfjs method inside iframe
form.$('input[type="file"]').trigger('change');
assert.verifySteps(['_getURI', 'open']);
testUtils.unpatch(field_registry.map.pdf_viewer);
form.destroy();
});
QUnit.test("bullet_state: basic rendering", function (assert) {
assert.expect(2);
@@ -10,6 +10,7 @@ var KanbanView = require('web.KanbanView');
var ListView = require('web.ListView');
var session = require('web.session');
var testUtils = require('web.test_utils');
var field_registry = require('web.field_registry');
var createView = testUtils.createView;
var DebouncedField = basicFields.DebouncedField;
@@ -1653,6 +1654,49 @@ QUnit.module('basic_fields', {
form.destroy();
});
QUnit.test("pdf_viewer: upload rendering", function (assert) {
assert.expect(6);
testUtils.patch(field_registry.map.pdf_viewer, {
on_file_change: function (ev) {
ev.target = {files: [new Blob()]};
this._super.apply(this, arguments);
},
_getURI: function (fileURI) {
var res = this._super.apply(this, arguments);
assert.step('_getURI');
assert.ok(_.str.startsWith(fileURI, 'blob:'));
this.PDFViewerApplication = {
open: function (URI) {
assert.step('open');
assert.ok(_.str.startsWith(URI, 'blob:'));
},
};
return 'about:blank';
},
});
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch:
'<form>' +
'<field name="document" widget="pdf_viewer"/>' +
'</form>',
});
// first upload initialize iframe
form.$('input[type="file"]').trigger('change');
assert.verifySteps(['_getURI']);
// second upload call pdfjs method inside iframe
form.$('input[type="file"]').trigger('change');
assert.verifySteps(['_getURI', 'open']);
testUtils.unpatch(field_registry.map.pdf_viewer);
form.destroy();
});
QUnit.test('text field rendering in list view', function (assert) {
assert.expect(1);

0 comments on commit 32b1911

Please sign in to comment.