Skip to content

test: restructure and simplify side-nav-item unit tests - #5973

Merged
web-padawan merged 1 commit into
mainfrom
test/side-nav-item-cleanup
Jun 13, 2023
Merged

web-padawan merged 1 commit into
mainfrom
test/side-nav-item-cleanup

Conversation

@web-padawan

@web-padawan web-padawan commented Jun 13, 2023 •

Copy link
Copy Markdown
Member

Description

Reorganized tests for vaadin-side-nav-item in order to make them more readable:

  1. Moved all the individual test suites to be placed under the single root suite,
  2. Removed a few tests that seem to be duplicates (e.g. checking for expanded)
  3. Changed to use shorter variables e.g. item, not passiveItemWithChildren

Type of change

  • Tests

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Comment on lines -56 to -57
it('should have a toggle button', async () => {
expect(passiveItemWithChildren._button).to.be.ok;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These tests are removed in favor of DOM snapshot tests.
Also, we generally should not check for protected APIs like _button in unit tests.

describe('active item with children', () => {
let activeItemWithChildren;

describe('inactive', () => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Renamed passive to inactive which seems to be a better name.

Comment on lines -157 to -158
it('should be expanded', () => {
expect(activeItem.expanded).to.be.true;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This test is a duplicate: we check for expanded to be set for the active item with and without children.
To me it feels unnecessary to repeat this assertion twice, so I removed this test.

@ugur-vaadin ugur-vaadin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks much better in terms of structure and readability.

@web-padawan
web-padawan removed the request for review from vursen June 13, 2023 13:41
@web-padawan
web-padawan merged commit a66992c into main Jun 13, 2023
@web-padawan
web-padawan deleted the test/side-nav-item-cleanup branch June 13, 2023 13:41
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 24.2.0.alpha1 and is also targeting the upcoming stable 24.2.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants