diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/web/static/tests/components/custom_checkbox_tests.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/web/static/tests/components/custom_checkbox_tests.js')
| -rw-r--r-- | addons/web/static/tests/components/custom_checkbox_tests.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/addons/web/static/tests/components/custom_checkbox_tests.js b/addons/web/static/tests/components/custom_checkbox_tests.js new file mode 100644 index 00000000..21d7ae53 --- /dev/null +++ b/addons/web/static/tests/components/custom_checkbox_tests.js @@ -0,0 +1,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(); + }); + }); +}); |
