From bb55441d94e36904a119f69ecf13c8f4bd241297 Mon Sep 17 00:00:00 2001 From: shubhamsigdar1 Date: Tue, 25 Jul 2023 15:47:40 +0530 Subject: [PATCH] added test when checkbox is clicked --- .../components/new-signup/checkbox-test.js | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tests/integration/components/new-signup/checkbox-test.js b/tests/integration/components/new-signup/checkbox-test.js index 06d62e2a..e4d72c0b 100644 --- a/tests/integration/components/new-signup/checkbox-test.js +++ b/tests/integration/components/new-signup/checkbox-test.js @@ -1,6 +1,6 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; +import { render, find, click } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; // handler functions are creating some problems need to fix em @@ -80,4 +80,36 @@ module('Integration | Component | new-sign-up/form', function (hooks) { assert.dom('.checkbox-label:nth-child(3)').hasText('Mavens'); assert.dom('.checkbox-label:nth-child(4)').hasText('Product Manager'); }); + + test('should call the onChange function with the correct parameters when checkbox is clicked', async function (assert) { + assert.expect(1); + + this.setProperties({ + onClick: function () { + this.currentStep = this.LAST_STEP; + }, + currentStep: 'role', + dev: true, + }); + + this.set('onChange', (key, value) => { + assert.deepEqual( + { key, value }, + { key: 'developer', value: true }, + 'onChange function called with correct parameters' + ); + }); + + await render(hbs` + `); + + const checkboxElement = find('.checkbox-input'); + + await click(checkboxElement); + }); });