Skip to content
Snippets Groups Projects
Commit 15f951b0 authored by Aanand Prasad's avatar Aanand Prasad
Browse files

Test that lists in the dashboard display the projects

parent 5b93f8e6
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,12 @@ Enzyme.configure({ adapter: new Adapter() }) ...@@ -9,6 +9,12 @@ Enzyme.configure({ adapter: new Adapter() })
jest.mock('config', () => ({ 'pubsweet-client': {} })) jest.mock('config', () => ({ 'pubsweet-client': {} }))
const getProjects = section =>
section
.children()
.not('.heading')
.map(c => c.props().project)
describe('Dashboard', () => { describe('Dashboard', () => {
const makeWrapper = (props = {}) => { const makeWrapper = (props = {}) => {
props = Object.assign( props = Object.assign(
...@@ -38,26 +44,38 @@ describe('Dashboard', () => { ...@@ -38,26 +44,38 @@ describe('Dashboard', () => {
}) })
it('shows a list of projects submitted by the current user', () => { it('shows a list of projects submitted by the current user', () => {
const project = { id: 1 }
const dashboard = makeWrapper({ const dashboard = makeWrapper({
dashboard: { owner: [{ id: 1 }] }, dashboard: { owner: [project] },
}) })
expect(dashboard.find('.empty')).toHaveLength(0) expect(dashboard.find('.empty')).toHaveLength(0)
expect(dashboard.find('.heading')).toHaveLength(1) const section = dashboard.find('.section')
expect(section).toHaveLength(1)
expect(getProjects(section)).toEqual([project])
}) })
it('shows a list of projects to be reviewed', () => { it('shows a list of projects to be reviewed', () => {
const project = { id: 1 }
const dashboard = makeWrapper({ const dashboard = makeWrapper({
dashboard: { reviewer: [{ id: 1 }] }, dashboard: { reviewer: [project] },
}) })
expect(dashboard.find('.empty')).toHaveLength(0) expect(dashboard.find('.empty')).toHaveLength(0)
expect(dashboard.find('.heading')).toHaveLength(1) const section = dashboard.find('.section')
expect(section).toHaveLength(1)
expect(getProjects(section)).toEqual([project])
}) })
it('shows a list of projects of which the current user is the editor', () => { it('shows a list of projects of which the current user is the editor', () => {
const project = { id: 1 }
const dashboard = makeWrapper({ const dashboard = makeWrapper({
dashboard: { editor: [{ id: 1 }] }, dashboard: { editor: [project] },
}) })
expect(dashboard.find('.empty')).toHaveLength(0) expect(dashboard.find('.empty')).toHaveLength(0)
expect(dashboard.find('.heading')).toHaveLength(1) const section = dashboard.find('.section')
expect(section).toHaveLength(1)
expect(getProjects(section)).toEqual([project])
}) })
}) })
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment