Add test for DashboardsPage loading state
parent
b99f231483
commit
3f5850ddec
|
@ -33,11 +33,11 @@ import {Source, Dashboard, RemoteDataState} from 'src/types'
|
||||||
import {Notification} from 'src/types/notifications'
|
import {Notification} from 'src/types/notifications'
|
||||||
import {DashboardFile, Cell} from 'src/types/dashboards'
|
import {DashboardFile, Cell} from 'src/types/dashboards'
|
||||||
|
|
||||||
interface Props {
|
export interface Props {
|
||||||
source: Source
|
source: Source
|
||||||
sources: Source[]
|
sources: Source[]
|
||||||
router: InjectedRouter
|
router: InjectedRouter
|
||||||
handleGetDashboards: () => Dashboard[]
|
handleGetDashboards: () => Promise<Dashboard[]>
|
||||||
handleGetChronografVersion: () => string
|
handleGetChronografVersion: () => string
|
||||||
handleDeleteDashboard: (dashboard: Dashboard) => void
|
handleDeleteDashboard: (dashboard: Dashboard) => void
|
||||||
handleImportDashboard: (dashboard: Dashboard) => void
|
handleImportDashboard: (dashboard: Dashboard) => void
|
||||||
|
@ -51,7 +51,7 @@ interface State {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ErrorHandling
|
@ErrorHandling
|
||||||
class DashboardsPage extends PureComponent<Props, State> {
|
export class DashboardsPage extends PureComponent<Props, State> {
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
import React from 'react'
|
||||||
|
import {shallow} from 'enzyme'
|
||||||
|
|
||||||
|
import {DashboardsPage, Props} from 'src/dashboards/containers/DashboardsPage'
|
||||||
|
import DashboardsTable from 'src/dashboards/components/DashboardsTable'
|
||||||
|
import DashboardsContents from 'src/dashboards/components/DashboardsPageContents'
|
||||||
|
import {Page} from 'src/reusable_ui'
|
||||||
|
|
||||||
|
import {source} from 'test/resources'
|
||||||
|
|
||||||
|
describe('DashboadsPage', () => {
|
||||||
|
test('it displays a loading state initially', () => {
|
||||||
|
const props = {
|
||||||
|
dashboards: [],
|
||||||
|
handleGetDashboards: () => new Promise(() => {}),
|
||||||
|
source,
|
||||||
|
sources: [source],
|
||||||
|
} as Props
|
||||||
|
|
||||||
|
const wrapper = shallow(<DashboardsPage {...props} />)
|
||||||
|
|
||||||
|
const text = wrapper
|
||||||
|
.find(Page)
|
||||||
|
.dive()
|
||||||
|
.find(Page.Contents)
|
||||||
|
.dive()
|
||||||
|
.find(DashboardsContents)
|
||||||
|
.dive()
|
||||||
|
.find(DashboardsTable)
|
||||||
|
.dive()
|
||||||
|
.find('.generic-empty-state h4')
|
||||||
|
.text()
|
||||||
|
|
||||||
|
expect(text).toEqual('Loading dashboards...')
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue