1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
odoo.define('web.custom_checkbox_tests', function (require) {
"use strict";
const CustomCheckbox = require('web.CustomCheckbox');
const testUtils = require('web.test_utils');
const { createComponent, dom: testUtilsDom } = testUtils;
QUnit.module('Components', {}, function () {
QUnit.module('CustomCheckbox');
QUnit.test('test checkbox: default values', async function(assert) {
assert.expect(6);
const checkbox = await createComponent(CustomCheckbox, {});
assert.containsOnce(checkbox.el, 'input');
assert.containsNone(checkbox.el, 'input:disabled');
assert.containsOnce(checkbox.el, 'label');
const input = checkbox.el.querySelector('input');
assert.notOk(input.checked, 'checkbox should be unchecked');
assert.ok(input.id.startsWith('checkbox-comp-'));
await testUtilsDom.click(checkbox.el.querySelector('label'));
assert.ok(input.checked, 'checkbox should be checked');
checkbox.destroy();
});
QUnit.test('test checkbox: custom values', async function(assert) {
assert.expect(6);
const checkbox = await createComponent(CustomCheckbox, {
props: {
id: 'my-custom-checkbox',
disabled: true,
value: true,
text: 'checkbox',
}
});
assert.containsOnce(checkbox.el, 'input');
assert.containsOnce(checkbox.el, 'input:disabled');
assert.containsOnce(checkbox.el, 'label');
const input = checkbox.el.querySelector('input');
assert.ok(input.checked, 'checkbox should be checked');
assert.strictEqual(input.id, 'my-custom-checkbox');
assert.ok(input.checked, 'checkbox should be checked');
checkbox.destroy();
});
});
});
|