Skip to content

Commit

Permalink
added test for role page
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamsinghbundela committed Jul 23, 2023
1 parent f72378d commit 2a0dd97
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
8 changes: 4 additions & 4 deletions app/components/new-signup/checkbox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<input
type='checkbox'
name='developer'
checked={{@roles.developer}}
checked={{false}}
{{on 'change' this.checkboxFieldChanged}}
class='checkbox-input'
/>
Expand All @@ -17,7 +17,7 @@
<input
type='checkbox'
name='designer'
checked={{@roles.designer}}
checked={{false}}
{{on 'change' this.checkboxFieldChanged}}
class='checkbox-input'
/>
Expand All @@ -27,7 +27,7 @@
<input
type='checkbox'
name='mavens'
checked={{@roles.mavens}}
checked={{false}}
{{on 'change' this.checkboxFieldChanged}}
class='checkbox-input'
/>
Expand All @@ -37,7 +37,7 @@
<input
type='checkbox'
name='productmanager'
checked={{@roles.productmanager}}
checked={{false}}
{{on 'change' this.checkboxFieldChanged}}
class='checkbox-input'
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module('Integration | Component | new-sign-up/form', function (hooks) {
});

await render(hbs`
<NewSignup::Select
<NewSignup::Checkbox
@onClick={{this.onClick}}
@currentStep={{this.currentStep}}
@dev={{this.dev}}
Expand All @@ -39,7 +39,7 @@ module('Integration | Component | new-sign-up/form', function (hooks) {
});

await render(hbs`
<NewSignup::Select
<NewSignup::Checkbox
@onClick={{this.onClick}}
@currentStep={{this.currentStep}}
@dev={{this.dev}}
Expand All @@ -49,8 +49,8 @@ module('Integration | Component | new-sign-up/form', function (hooks) {
assert.dom('[data-test-btn="signup"]').hasText('Submit');
});

test('It should have select field(currently behind dev flag)', async function (assert) {
assert.expect(3);
test('It should have label and checkbox(currently behind dev flag)', async function (assert) {
assert.expect(10);

this.setProperties({
onClick: function () {
Expand All @@ -61,16 +61,23 @@ module('Integration | Component | new-sign-up/form', function (hooks) {
});

await render(hbs`
<NewSignup::Select
<NewSignup::Checkbox
@onClick={{this.onClick}}
@currentStep={{this.currentStep}}
@dev={{this.dev}}
/>`);

assert.dom('[data-test-signup-form-select]').exists();
assert
.dom('[data-test-signup-form-select]')
.hasAttribute('name', 'role')
.hasAttribute('id', 'role');
assert.dom('.checkbox-label').exists({ count: 4 });
assert.dom('.checkbox-input').exists({ count: 4 });

assert.dom('.checkbox-input[name="developer"]').isNotChecked();
assert.dom('.checkbox-input[name="designer"]').isNotChecked();
assert.dom('.checkbox-input[name="mavens"]').isNotChecked();
assert.dom('.checkbox-input[name="productmanager"]').isNotChecked();

assert.dom('.checkbox-label:nth-child(1)').hasText('Developer');
assert.dom('.checkbox-label:nth-child(2)').hasText('Designer');
assert.dom('.checkbox-label:nth-child(3)').hasText('Mavens');
assert.dom('.checkbox-label:nth-child(4)').hasText('Product Manager');
});
});
22 changes: 16 additions & 6 deletions tests/unit/controllers/new-signup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,25 @@ module('Unit | Controller | new-signup', function (hooks) {
'vinayak',
'username value updated'
);
});

test('testing handleCheckboxInput change function', function (assert) {
let controller = this.owner.lookup('controller:new-signup');
let developer = 'developer';
let designer = 'designer';
let mavens = 'mavens';
let productmanager = 'productmanager';

controller.send('handleInputChange', 'role', 'developer');
assert.equal(controller.developer, true, 'developer set to true');
controller.send('handleCheckboxInputChange', 'developer', true);
assert.equal(controller.roles[developer], true);

assert.equal(controller.designer, false, 'designer set to false');
controller.send('handleCheckboxInputChange', 'designer', true);
assert.equal(controller.roles[designer], true);

controller.send('handleInputChange', 'role', 'designer');
assert.equal(controller.designer, true, 'designer set to true');
controller.send('handleCheckboxInputChange', 'mavens', true);
assert.equal(controller.roles[mavens], true);

assert.equal(controller.developer, false, 'developer set to false');
controller.send('handleCheckboxInputChange', 'productmanager', true);
assert.equal(controller.roles[productmanager], true);
});
});

0 comments on commit 2a0dd97

Please sign in to comment.