Skip to content

Commit 046ed8f

Browse files
committed
Update tests
1 parent dea98b2 commit 046ed8f

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

cypress/component/DataView.cy.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
import React from 'react';
2+
import DataView from '../../packages/module/dist/dynamic/DataView';
3+
import DataViewToolbar from '../../packages/module/dist/esm/DataViewToolbar';
24

35
describe('DataView', () => {
4-
it('renders data view', () => {
5-
cy.mount(<div id="test">Some text</div>);
6+
it('renders the data view layout', () => {
7+
cy.mount(<DataView><>Data view content</></DataView>)
8+
cy.get('[data-ouia-component-id="DataView-stack-item-0"]').contains('Data view content');
9+
});
610

7-
cy.get('[id="test"]').should('contain', 'Some text');
8-
})
9-
})
11+
it('renders the data view with toolbar, data section and footer', () => {
12+
cy.mount(
13+
<DataView>
14+
<DataViewToolbar page={1} perPage={10} />
15+
<>Data section</>
16+
<DataViewToolbar page={1} perPage={10} isBottom />
17+
</DataView>
18+
);
19+
cy.get('[data-ouia-component-id="DataViewToolbar-pagination"]').should('exist');
20+
cy.get('[data-ouia-component-id="DataView-stack-item-1"]').contains('Data section');
21+
cy.get('[data-ouia-component-id="DataViewToolbar-pagination-bottom"]').should('exist');
22+
});
23+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import DataViewToolbar from '../../packages/module/dist/dynamic/DataViewToolbar';
3+
4+
describe('DataViewToolbar', () => {
5+
it('renders the data view toolbar', () => {
6+
cy.mount(<DataViewToolbar page={1} perPage={10} />)
7+
cy.get('[data-ouia-component-id="DataViewToolbar-pagination-bottom"]').should('not.exist');
8+
cy.get('[data-ouia-component-id="DataViewToolbar-pagination"]').should('exist');
9+
});
10+
11+
it('renders the data view bottom toolbar', () => {
12+
cy.mount(<DataViewToolbar page={1} perPage={10} isBottom />)
13+
cy.get('[data-ouia-component-id="DataViewToolbar-pagination"]').should('not.exist');
14+
cy.get('[data-ouia-component-id="DataViewToolbar-pagination-bottom"]').should('exist');
15+
});
16+
});

packages/module/src/DataView/DataView.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import DataView from './DataView';
66
describe('DataView', () => {
77

88
it('should render data view', () => {
9-
render(<DataView />);
10-
expect(screen.getByText('This is Data view')).toBeInTheDocument();
9+
render(<DataView><>Data view content</></DataView>);
10+
expect(screen.getByText('Data view content')).toBeInTheDocument();
1111
});
1212

1313
});

0 commit comments

Comments
 (0)