Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KFI]test(document-viewer-react): Add some tests
- Loading branch information
Showing
9 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/sn-document-viewer-react/test/PrintWidget.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { shallow } from 'enzyme' | ||
import React from 'react' | ||
import { PrintComponent } from '../src/components/document-widgets/PrintWidget' | ||
import { DocumentData } from '../src/models/DocumentData' | ||
|
||
describe('DownloadWidget component', () => { | ||
it('Should render without crashing', () => { | ||
const print = jest.fn() | ||
const wrapper = shallow(<PrintComponent print={print} title="" document={{} as DocumentData} />) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it('Should trigger a print request when clicked', () => { | ||
const print = jest.fn() | ||
const wrapper = shallow(<PrintComponent print={print} title="" document={{} as DocumentData} />) | ||
wrapper.find('#Print').simulate('click') | ||
expect(print).toBeCalled() | ||
}) | ||
}) |
36 changes: 36 additions & 0 deletions
36
packages/sn-document-viewer-react/test/RotateActivePage.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { shallow } from 'enzyme' | ||
import React from 'react' | ||
import { RotateActivePagesComponent } from '../src/components/document-widgets/RotateActivePages' | ||
import { ROTATION_AMOUNT } from '../src/components/page-widgets/RotatePage' | ||
import { examplePreviewImageData } from './__Mocks__/viewercontext' | ||
|
||
describe('RotateActivePage component', () => { | ||
const locals = { | ||
rotateDocumentLeft: 'rotateDocumentLeft', | ||
rotateDocumentRight: 'rotateDocumentRight', | ||
pages: [], | ||
activePages: [1], | ||
} | ||
it('Should render without crashing', () => { | ||
const wrapper = shallow(<RotateActivePagesComponent {...locals} rotateImages={jest.fn()} />) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it('RotateLeft should trigger a rotate to left', () => { | ||
const rotateImages = jest.fn() | ||
const wrapper = shallow(<RotateActivePagesComponent {...locals} rotateImages={rotateImages} />) | ||
|
||
wrapper.find('#RotateActiveLeft').simulate('click') | ||
expect(rotateImages).toBeCalledWith([examplePreviewImageData.Index], -ROTATION_AMOUNT) | ||
expect(rotateImages).toBeCalled() | ||
}) | ||
|
||
it('RotateRight should trigger a rotate to right', () => { | ||
const rotateImages = jest.fn() | ||
const wrapper = shallow(<RotateActivePagesComponent {...locals} rotateImages={rotateImages} />) | ||
|
||
wrapper.find('#RotateActiveRight').simulate('click') | ||
expect(rotateImages).toBeCalledWith([examplePreviewImageData.Index], ROTATION_AMOUNT) | ||
expect(rotateImages).toBeCalled() | ||
}) | ||
}) |
19 changes: 19 additions & 0 deletions
19
packages/sn-document-viewer-react/test/ShareWidget.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { shallow } from 'enzyme' | ||
import React from 'react' | ||
import { ShareComponent } from '../src/components/document-widgets/ShareWidget' | ||
import { DocumentData } from '../src/models/DocumentData' | ||
|
||
describe('DownloadWidget component', () => { | ||
it('Should render without crashing', () => { | ||
const share = jest.fn() | ||
const wrapper = shallow(<ShareComponent share={share} title="" document={{} as DocumentData} />) | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it('Should trigger a print request when clicked', () => { | ||
const share = jest.fn() | ||
const wrapper = shallow(<ShareComponent share={share} title="" document={{} as DocumentData} />) | ||
wrapper.find('#Share').simulate('click') | ||
expect(share).toBeCalled() | ||
}) | ||
}) |
20 changes: 20 additions & 0 deletions
20
packages/sn-document-viewer-react/test/__snapshots__/PrintWidget.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`DownloadWidget component Should render without crashing 1`] = ` | ||
<div | ||
style={ | ||
Object { | ||
"display": "inline-block", | ||
} | ||
} | ||
> | ||
<WithStyles(IconButton) | ||
color="inherit" | ||
id="Print" | ||
onClick={[Function]} | ||
title="" | ||
> | ||
<pure(PrintIcon) /> | ||
</WithStyles(IconButton)> | ||
</div> | ||
`; |
28 changes: 28 additions & 0 deletions
28
packages/sn-document-viewer-react/test/__snapshots__/RotateActivePage.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`RotateActivePage component Should render without crashing 1`] = ` | ||
<div | ||
style={ | ||
Object { | ||
"display": "inline-block", | ||
} | ||
} | ||
> | ||
<WithStyles(IconButton) | ||
color="inherit" | ||
id="RotateActiveLeft" | ||
onClick={[Function]} | ||
title="rotateDocumentLeft" | ||
> | ||
<pure(RotateLeftIcon) /> | ||
</WithStyles(IconButton)> | ||
<WithStyles(IconButton) | ||
color="inherit" | ||
id="RotateActiveRight" | ||
onClick={[Function]} | ||
title="rotateDocumentRight" | ||
> | ||
<pure(RotateRightIcon) /> | ||
</WithStyles(IconButton)> | ||
</div> | ||
`; |
20 changes: 20 additions & 0 deletions
20
packages/sn-document-viewer-react/test/__snapshots__/ShareWidget.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`DownloadWidget component Should render without crashing 1`] = ` | ||
<div | ||
style={ | ||
Object { | ||
"display": "inline-block", | ||
} | ||
} | ||
> | ||
<WithStyles(IconButton) | ||
color="inherit" | ||
id="Share" | ||
onClick={[Function]} | ||
title="" | ||
> | ||
<pure(ShareIcon) /> | ||
</WithStyles(IconButton)> | ||
</div> | ||
`; |