Skip to content

Commit

Permalink
mock date/time functions in FileInfo unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
individual-it committed Feb 10, 2022
1 parent 707f074 commit c0b1d2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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

0 comments on commit c0b1d2f

Please sign in to comment.