-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adding more test unit for insert link modal
- Loading branch information
Showing
9 changed files
with
437 additions
and
6 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
src/editors/sharedComponents/InsertLinkModal/BlocksList/__snapshots__/index.test.jsx.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,107 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`BlocksList Component snapshot 1`] = ` | ||
<IntlProvider | ||
defaultFormats={Object {}} | ||
defaultLocale="en" | ||
fallbackOnEmptyString={true} | ||
formats={Object {}} | ||
locale="en" | ||
messages={Object {}} | ||
onError={[Function]} | ||
onWarn={[Function]} | ||
textComponent={Symbol(react.fragment)} | ||
> | ||
<BlocksList | ||
blocks={ | ||
Object { | ||
"block-children-1": Object { | ||
"blockId": "edx_block-1", | ||
"displayName": "Block children 1", | ||
"id": "block-children-1", | ||
"legacyWebUrl": "http://localhost/legacy", | ||
"lmsWebUrl": "http://localhost/weburl", | ||
"studentViewUrl": "http://localhost/studentview", | ||
"type": "sequential", | ||
}, | ||
"block-children-2": Object { | ||
"blockId": "edx_block-2", | ||
"displayName": "Block children 2", | ||
"id": "block-children-2", | ||
"legacyWebUrl": "http://localhost/legacy", | ||
"lmsWebUrl": "http://localhost/weburl", | ||
"studentViewUrl": "http://localhost/studentview", | ||
"type": "sequential", | ||
}, | ||
"block-key": Object { | ||
"blockId": "edx_block-1", | ||
"children": Array [ | ||
"block-children-1", | ||
"block-children-2", | ||
], | ||
"displayName": "Any display name", | ||
"id": "block-key", | ||
"legacyWebUrl": "http://localhost/legacy", | ||
"lmsWebUrl": "http://localhost/weburl", | ||
"studentViewUrl": "http://localhost/studentview", | ||
"type": "sequential", | ||
}, | ||
} | ||
} | ||
onBlockSelected={[Function]} | ||
/> | ||
</IntlProvider> | ||
`; | ||
|
||
exports[`BlocksList Component snapshot with onBlockSelected 1`] = ` | ||
<IntlProvider | ||
defaultFormats={Object {}} | ||
defaultLocale="en" | ||
fallbackOnEmptyString={true} | ||
formats={Object {}} | ||
locale="en" | ||
messages={Object {}} | ||
onError={[Function]} | ||
onWarn={[Function]} | ||
textComponent={Symbol(react.fragment)} | ||
> | ||
<BlocksList | ||
blocks={ | ||
Object { | ||
"block-children-1": Object { | ||
"blockId": "edx_block-1", | ||
"displayName": "Block children 1", | ||
"id": "block-children-1", | ||
"legacyWebUrl": "http://localhost/legacy", | ||
"lmsWebUrl": "http://localhost/weburl", | ||
"studentViewUrl": "http://localhost/studentview", | ||
"type": "sequential", | ||
}, | ||
"block-children-2": Object { | ||
"blockId": "edx_block-2", | ||
"displayName": "Block children 2", | ||
"id": "block-children-2", | ||
"legacyWebUrl": "http://localhost/legacy", | ||
"lmsWebUrl": "http://localhost/weburl", | ||
"studentViewUrl": "http://localhost/studentview", | ||
"type": "sequential", | ||
}, | ||
"block-key": Object { | ||
"blockId": "edx_block-1", | ||
"children": Array [ | ||
"block-children-1", | ||
"block-children-2", | ||
], | ||
"displayName": "Any display name", | ||
"id": "block-key", | ||
"legacyWebUrl": "http://localhost/legacy", | ||
"lmsWebUrl": "http://localhost/weburl", | ||
"studentViewUrl": "http://localhost/studentview", | ||
"type": "sequential", | ||
}, | ||
} | ||
} | ||
onBlockSelected={[Function]} | ||
/> | ||
</IntlProvider> | ||
`; |
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
42 changes: 42 additions & 0 deletions
42
src/editors/sharedComponents/InsertLinkModal/FilterBlock/__snapshots__/index.test.jsx.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,42 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`FilterBlock Component snapshot 1`] = ` | ||
<FilterBlock | ||
block={ | ||
Object { | ||
"blockId": "edx_block-1", | ||
"children": Array [ | ||
"block-children-1", | ||
"block-children-2", | ||
], | ||
"displayName": "Any display name", | ||
"id": "block-key", | ||
"legacyWebUrl": "http://localhost/legacy", | ||
"lmsWebUrl": "http://localhost/weburl", | ||
"path": "Path / To / Block 1", | ||
"studentViewUrl": "http://localhost/studentview", | ||
"type": "sequential", | ||
} | ||
} | ||
onBlockFilterClick={[MockFunction]} | ||
> | ||
<Button | ||
className="d-flex flex-column w-100 align-items-start p-3" | ||
data-testid="filter-block-item" | ||
key="filtered_block_block-key" | ||
onClick={[Function]} | ||
variant="tertiary" | ||
> | ||
<span | ||
className="h5 text-left" | ||
> | ||
Path / To | ||
</span> | ||
<span | ||
className="h3" | ||
> | ||
Block 1 | ||
</span> | ||
</Button> | ||
</FilterBlock> | ||
`; |
51 changes: 51 additions & 0 deletions
51
src/editors/sharedComponents/InsertLinkModal/FilterBlock/index.test.jsx
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,51 @@ | ||
import React from 'react'; | ||
import Enzyme, { mount } from 'enzyme'; | ||
import Adapter from '@wojtekmaj/enzyme-adapter-react-17'; | ||
|
||
import FilterBlock from '.'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
const mockBlock = { | ||
id: 'block-key', | ||
blockId: 'edx_block-1', | ||
lmsWebUrl: 'http://localhost/weburl', | ||
legacyWebUrl: 'http://localhost/legacy', | ||
studentViewUrl: 'http://localhost/studentview', | ||
type: 'sequential', | ||
displayName: 'Any display name', | ||
path: 'Path / To / Block 1', | ||
children: ['block-children-1', 'block-children-2'], | ||
}; | ||
|
||
describe('FilterBlock Component', () => { | ||
const mockOnBlockFilterClick = jest.fn(); | ||
|
||
const setup = ( | ||
block = mockBlock, | ||
onBlockFilterClick = mockOnBlockFilterClick, | ||
) => mount(<FilterBlock block={block} onBlockFilterClick={onBlockFilterClick} />); | ||
|
||
test('renders without crashing', () => { | ||
const wrapper = setup(); | ||
expect(wrapper.exists()).toBeTruthy(); | ||
}); | ||
|
||
test('snapshot', () => { | ||
const wrapper = setup(); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
test('calls onBlockFilterClick when the button is clicked', () => { | ||
const wrapper = setup(); | ||
const button = wrapper.find('Button[data-testid="filter-block-item"]'); | ||
button.simulate('click'); | ||
expect(mockOnBlockFilterClick).toHaveBeenCalledWith(mockBlock); | ||
}); | ||
|
||
test('displays the block title and subtitle', () => { | ||
const wrapper = setup(); | ||
expect(wrapper.find('.h5').text()).toContain('Path / To'); | ||
expect(wrapper.find('.h3').text()).toContain('Block 1'); | ||
}); | ||
}); |
59 changes: 59 additions & 0 deletions
59
src/editors/sharedComponents/InsertLinkModal/SearchBlocks/__snapshots__/index.test.jsx.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,59 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SearchBlocks Component snapshot 1`] = ` | ||
<IntlProvider | ||
defaultFormats={Object {}} | ||
defaultLocale="en" | ||
fallbackOnEmptyString={true} | ||
formats={Object {}} | ||
locale="en" | ||
messages={Object {}} | ||
onError={[Function]} | ||
onWarn={[Function]} | ||
textComponent={Symbol(react.fragment)} | ||
> | ||
<SearchBlocks | ||
blocks={ | ||
Object { | ||
"block-children-1": Object { | ||
"blockId": "edx_block-1", | ||
"displayName": "Block children 1", | ||
"id": "block-children-1", | ||
"legacyWebUrl": "http://localhost/legacy", | ||
"lmsWebUrl": "http://localhost/weburl", | ||
"path": "Any display name / Block children 1", | ||
"studentViewUrl": "http://localhost/studentview", | ||
"type": "sequential", | ||
}, | ||
"block-children-2": Object { | ||
"blockId": "edx_block-2", | ||
"displayName": "Block children 2", | ||
"id": "block-children-2", | ||
"legacyWebUrl": "http://localhost/legacy", | ||
"lmsWebUrl": "http://localhost/weburl", | ||
"path": "Any display name / Block children 2", | ||
"studentViewUrl": "http://localhost/studentview", | ||
"type": "sequential", | ||
}, | ||
"block-key": Object { | ||
"blockId": "edx_block-1", | ||
"children": Array [ | ||
"block-children-1", | ||
"block-children-2", | ||
], | ||
"displayName": "Any display name", | ||
"id": "block-key", | ||
"legacyWebUrl": "http://localhost/legacy", | ||
"lmsWebUrl": "http://localhost/weburl", | ||
"path": "Any display name", | ||
"studentViewUrl": "http://localhost/studentview", | ||
"type": "sequential", | ||
}, | ||
} | ||
} | ||
onBlockSelected={[Function]} | ||
onSearchFilter={[Function]} | ||
searchInputValue="" | ||
/> | ||
</IntlProvider> | ||
`; |
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
Oops, something went wrong.