Skip to content

Commit 07c902d

Browse files
committed
added unit tests for create-index-modal-header
1 parent 18168b9 commit 07c902d

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import { render, screen } from '@mongodb-js/testing-library-compass';
3+
import CreateIndexModalHeader from './create-index-modal-header';
4+
import { expect } from 'chai';
5+
6+
describe('CreateIndexModalHeader', () => {
7+
it('renders the modal title', () => {
8+
render(<CreateIndexModalHeader />);
9+
const title = screen.getByTestId('create-index-modal-header-title');
10+
11+
expect(title.textContent).to.be.equal('Create Index');
12+
});
13+
14+
it('renders the subtitle text', () => {
15+
render(<CreateIndexModalHeader />);
16+
const subtitle = screen.getByTestId('create-index-modal-header-subtitle');
17+
expect(subtitle).to.exist;
18+
});
19+
20+
it('renders the link to the Index Strategies Documentation', () => {
21+
render(<CreateIndexModalHeader />);
22+
const link = screen.getByRole('link', {
23+
name: /Index Strategies Documentation/i,
24+
});
25+
expect(link).to.exist;
26+
});
27+
});

packages/compass-indexes/src/components/create-index-modal/create-index-modal-header.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ const headerStyle = css({
1717
const CreateIndexModalHeader = () => {
1818
return (
1919
<div className={cx(headerStyle)}>
20-
<H3 data-testid="modal-title" id="modal-title">
21-
Create Index
22-
</H3>
20+
<H3 data-testid="create-index-modal-header-title">Create Index</H3>
2321

24-
<Body style={{ color: palette.gray.dark1 }}>
22+
<Body
23+
data-testid="create-index-modal-header-subtitle"
24+
style={{ color: palette.gray.dark1 }}
25+
>
2526
The best indexes for your application should consider a number of
2627
factors, such as your data model, and the queries you use most often. To
2728
learn more about indexing best practices, read the{' '}

packages/compass-indexes/src/components/create-index-modal/create-index-modal.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {
55
ModalFooter,
66
ModalHeader,
77
ModalBody,
8-
Link,
9-
palette,
108
} from '@mongodb-js/compass-components';
119
import {
1210
fieldAdded,

0 commit comments

Comments
 (0)