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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ const formRelativeDateFromRFC = jest.fn()
const resetDateMocks = () => {
formDateFromRFC.mockReset()
formRelativeDateFromRFC.mockReset()
formDateFromRFC.mockImplementation(() => 'ABSOLUTE_TIME')
formRelativeDateFromRFC.mockImplementation(() => 'RELATIVE_TIME')
}

describe('FileInfo', () => {
it('shows file info', () => {
resetDateMocks()

const tooltipStub = jest.fn()
const wrapper = createWrapper(simpleOwnFile, tooltipStub)
expect(wrapper.find(selectors.name).exists()).toBeTruthy()
Expand All @@ -52,8 +56,6 @@ describe('FileInfo', () => {

it('shows modification date info', () => {
resetDateMocks()
formDateFromRFC.mockImplementation(() => 'ABSOLUTE_MODIFICATION_TIME')
formRelativeDateFromRFC.mockImplementation(() => 'RELATIVE_MODIFICATION_TIME')

const tooltipStub = jest.fn()
const wrapper = createWrapper(simpleOwnFile, tooltipStub)
Expand All @@ -68,8 +70,6 @@ describe('FileInfo', () => {

it('shows deletion date info', () => {
resetDateMocks()
formDateFromRFC.mockImplementation(() => 'ABSOLUTE_DELETION_TIME')
formRelativeDateFromRFC.mockImplementation(() => 'RELATIVE_DELETION_TIME')

const tooltipStub = jest.fn()
const wrapper = createWrapper(simpleDeletedFile, tooltipStub, 'files-common-trash')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`FileInfo shows deletion date info 1`] = `
<oc-resource-name-stub type="file"></oc-resource-name-stub>
</h3>
<p class="oc-my-rm">
<!----> <span data-testid="files-info-mdate" tabindex="0" aria-label="deleted RELATIVE_DELETION_TIME (ABSOLUTE_DELETION_TIME)">deleted RELATIVE_DELETION_TIME</span>
<!----> <span data-testid="files-info-mdate" tabindex="0" aria-label="deleted RELATIVE_TIME (ABSOLUTE_TIME)">deleted RELATIVE_TIME</span>
</p>
</div>
<!---->
Expand All @@ -22,7 +22,7 @@ exports[`FileInfo shows modification date info 1`] = `
<h3 data-testid="files-info-name">
<oc-resource-name-stub type="file"></oc-resource-name-stub>
</h3>
<p class="oc-my-rm">740 B, <span data-testid="files-info-mdate" tabindex="0" aria-label="modified RELATIVE_MODIFICATION_TIME (ABSOLUTE_MODIFICATION_TIME)">modified RELATIVE_MODIFICATION_TIME</span></p>
<p class="oc-my-rm">740 B, <span data-testid="files-info-mdate" tabindex="0" aria-label="modified RELATIVE_TIME (ABSOLUTE_TIME)">modified RELATIVE_TIME</span></p>
</div>
<!---->
</div>
Expand Down