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

unit tests for SidebarQuota.vue #5229

Merged
merged 2 commits into from
Jun 15, 2021
Merged

unit tests for SidebarQuota.vue #5229

merged 2 commits into from
Jun 15, 2021

Conversation

individual-it
Copy link
Member

Description

  • unit tests for SidebarQuota.vue
  • show 0 B of 2 GB as quota in case of a negative number given as used quota and not only of 2 GB

Related Issue

part of #5217

Motivation and Context

increase unit test coverage

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • ...

@update-docs
Copy link

update-docs bot commented Jun 10, 2021

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

Copy link
Contributor

@kiranparajuli589 kiranparajuli589 left a comment

Choose a reason for hiding this comment

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

lgtm 👍🏼

@@ -22,7 +22,7 @@ export default {
...mapGetters(['quota']),

usedQuota() {
return getResourceSize(this.quota.used)
return getResourceSize(this.quota.used) || '0 B'
Copy link
Member

Choose a reason for hiding this comment

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

Can't we just change getResourceSize so that it treats a negative number as 0?
like this:

size = (size < 0) ? 0 : size

instead of the return ''.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes you are right. My thought was that the same function is also defined in

getResourceSize(size) {
and used in https://github.com/owncloud/web/blob/f46085ad7dba7cfc7d35a953c796714e0e88b4e1/packages/web-app-files/src/components/InfoSelectedResources.vue
so in the next step I wanted to consolidate both functions (not sure where it has to be placed to be used from both though)
Now looking at InfoSelectedResources.vue in detail I think returning 0 instead of '' would not harm there ether

Copy link
Member

Choose a reason for hiding this comment

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

We introduced packages/web-pkg a while ago for shared code, I think it would be good to have it there.

packages/web-runtime/tests/components/SidebarQuota.spec.js Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Jun 11, 2021

Kudos, SonarCloud Quality Gate passed!

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

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link
Member

@kulmann kulmann left a comment

Choose a reason for hiding this comment

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

👍

@kulmann kulmann merged commit f41d46d into master Jun 15, 2021
@delete-merged-branch delete-merged-branch bot deleted the SidebarQuotaUnitTests2 branch June 15, 2021 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants