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

[tests-only] mock date/time functions in FileInfo unit test #6408

Merged

Conversation

individual-it
Copy link
Member

Description

mock the date/time functions in all tests, not only in some

@JammingBen @dschmidt you have been working on these tests, please review. How much do we care about the string? If we don't we can reduce the complexity a bit more.

Related Issue

Motivation and Context

Cannot evaluate expression: timeRelative
  console.warn
    Cannot evaluate expression: timeRelative

      57 |         obj.timeRelative = this.formRelativeDateFromRFC(obj.sourceTime)
      58 |
    > 59 |         obj.infoString = this.$gettextInterpolate(obj.infoString, obj)
         | ^
      60 |         obj.ariaLabel = this.$gettextInterpolate(obj.ariaLabel, obj)
      61 |         return obj
      62 |       }

      at Object.evalInContext (node_modules/vue-gettext/dist/vue-gettext.js:280:21)
      at node_modules/vue-gettext/dist/vue-gettext.js:293:28
          at String.replace (<anonymous>)
      at Function.interpolate (node_modules/vue-gettext/dist/vue-gettext.js:247:24)
      at interpolate (packages/web-app-files/src/components/SideBar/FileInfo.vue:59:1)
      at VueComponent.timeData (packages/web-app-files/src/components/SideBar/FileInfo.vue:75:1)
      at Watcher.get (node_modules/vue/dist/vue.runtime.common.dev.js:4481:25)

How Has This Been Tested?

  • running unit tests locally
  • 🤖

Screenshots (if appropriate):

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:

  • ...

@dschmidt
Copy link
Member

I don't think resetDateMocks('ABSOLUTE_MODIFICATION_TIME', 'RELATIVE_MODIFICATION_TIME') is very clear semantically, if we want to move it to the reset function I'd be happier if we hardcode those strings instead of having positional params for them.

@individual-it individual-it force-pushed the web-app-files/tests/unit/components/SideBar/FileInfo.spec.js branch from 6d19012 to c0b1d2f Compare February 10, 2022 11:11
@individual-it
Copy link
Member Author

@dschmidt I've changed it to use ABSOLUTE_TIME and RELATIVE_TIME for every test. Is that what you meant?

@sonarqubecloud
Copy link

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
No Duplication information No Duplication information

@dschmidt
Copy link
Member

Yep, I prefer it this way!

@kulmann kulmann merged commit c34ac1f into master Feb 10, 2022
@delete-merged-branch delete-merged-branch bot deleted the web-app-files/tests/unit/components/SideBar/FileInfo.spec.js branch February 10, 2022 13:12
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