Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: 100% coverage of virtual-select component #2500

Merged
merged 4 commits into from
Oct 13, 2023

Conversation

suyashpatil78
Copy link
Contributor

@suyashpatil78 suyashpatil78 commented Oct 9, 2023

workerB

Description

🤖 Generated by Copilot at 56b2cf7

Added a shared component and unit tests for virtual select modal. The VirtualSelectComponent allows users to select an option from a list using a modal, and integrates with the ReactiveFormsModule. The virtual-select.component.spec.ts file contains the unit tests for the component's methods and properties. The modal-controller.data.ts file provides mock data for creating the modal.

🤖 Generated by Copilot at 56b2cf7

We test the virtual select, the component of control
We mock the modal data, the source of our console
We write and register, the methods of the interface
We open the modal gate, the portal to our fate

Walkthrough

🤖 Generated by Copilot at 56b2cf7

  • Import and mock VirtualSelectModalComponent for testing VirtualSelectComponent (link, link)
  • Add mock data object for creating virtual select modal using ModalController service (link)
  • Test VirtualSelectComponent's creation, modal opening, value setting, validation, and ControlValueAccessor methods (link)

Clickup

Please add link here

Code Coverage

https://app.clickup.com/t/85zu3u05y

UI Preview

Please add screenshots for UI changes

@github-actions github-actions bot added the size/L Large PR label Oct 9, 2023
modalController.create.and.resolveTo(selectionModalSpy);
});

it('openModal(): should open select modal and set value equals to value returned by modal', fakeAsync(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if openModal(): is added in describe no need to add again inside the it, fix it for all

component.options = [
{ label: 'Business', value: 'BUSINESS' },
{ label: 'Economy', value: 'ECONOMY' },
{ label: '', value: '' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when do we get the label as empty string ?

spyOn(component, 'onChangeCallback');
});

it('should set the value and update the displayValue if any option.value is equal to innerValue', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should set the value and update the displayValue if any "option.value" is equal to innerValue

expect(component.displayValue).toEqual('');
//@ts-ignore
expect(component.onChangeCallback).toHaveBeenCalledOnceWith('');
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one line space between each it()

//@ts-ignore
expect(component.onChangeCallback).toHaveBeenCalledOnceWith({ travelClass: 'BUSINESS', vendor: 'vendor1' });
});
it('should set the value and update the displayValue if none of the conditions holds true', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, fix it for all

];
});

it('should set the value and update the displayValue if any option.value is equal to innerValue', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should set the value and update the displayValue if any "option.value" is equal to innerValue

expect(component.innerValue).toEqual('');
expect(component.displayValue).toEqual('');
});
it('should set the value and update the displayValue if innerValue and defaultLabelProps is defined', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one line gap

@@ -162,6 +163,7 @@ describe('VirtualSelectModalComponent', () => {
//@ts-ignore
expect(component.onChangeCallback).toHaveBeenCalledOnceWith({ travelClass: 'BUSINESS', vendor: 'vendor1' });
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added one line space, don't know why github not showing as resolved

@suyashpatil78 suyashpatil78 merged commit 8dd2965 into master Oct 13, 2023
4 checks passed
@github-actions
Copy link

Unit Test Coverage % values
Statements 95.59% ( 17212 / 18005 )
Branches 93.22% ( 8687 / 9318 )
Functions 93.66% ( 5306 / 5665 )
Lines 95.75% ( 16393 / 17120 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Large PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants