<template id="qunit_suite" inherit_id="web.qunit_suite">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/academy/static/src/js/tools.js"></script>
<script type="text/javascript" src="/academy/static/tests/academy_tests.js"></script>
<script type="text/javascript" src="/academy/static/tests/academy_tests_field.js"></script>
</xpath>
</template>
const { CallQueuer } = require('academy.tools');
QUnit.module('academy', {}, function () {
QUnit.module('tools', {
beforeEach () {
/**
* Stores the execution call count.
*/
this.executedCount = 0;
}
}, function () {
QUnit.test('Tests multitples asyncronous calls', async function (assert) {
const done = assert.async();
assert.expect(1);
/**
* Mocked backend request.
*/
const request = () => new Promise((resolve) => {
setTimeout(() => resolve('Request done.'), 1000);
}).then(() => {
this.executedCount++;
});
CallQueuer(request);
CallQueuer(request);
CallQueuer(request);
CallQueuer(request);
CallQueuer(request);
setTimeout(() => {
assert.equal(this.executedCount, 2);
done();
}, 2100);
});
});
});
const { createView, dom } = require('web.test_utils');
const FormView = require('web.FormView');
QUnit.module('academy', {}, function () {
QUnit.module('tests', {
beforeEach () {
this.data = {
'product.template': {
fields: {
share_count: {string: "share count", type: "integer"},
},
records: [{
id: 1,
share_count: 420000,
}]
},
}
}
}, function () {
QUnit.test('Checks the correct display of value.', async function (assert) {
assert.expect(1);
const form = await createView({
View: FormView,
data: this.data,
model: 'product.template',
res_id: 1,
arch: `
<form>
<sheet>
<group>
<field name="share_count" widget="share_count"/>
</group>
</sheet>
</form>`,
});
assert.containsOnce(form, ".o_field_widget h1:contains('420,000')", "The string should be 420,000");
form.destroy();
});
QUnit.only('Checks the value is restarting', async function (assert) {
assert.expect(1);
const form = await createView({
View: FormView,
data: this.data,
model: 'product.template',
res_id: 1,
arch: `
<form>
<sheet>
<group>
<field name="share_count" widget="share_count"/>
</group>
</sheet>
</form>`,
});
await dom.click(form.$('.js_reset_field'))
assert.containsOnce(form, ".o_field_widget h1:contains('0')", "The string should be 0");
form.destroy();
});
});
});