Skip to content

Commit 0d21433

Browse files
committed
file
1 parent 10ee23e commit 0d21433

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from 'react';
2+
import { renderWithStore } from '../../tests/create-store';
3+
import { expect } from 'chai';
4+
import { screen } from '@mongodb-js/testing-library-compass';
5+
import ExampleCommandsMarkup, {
6+
type ExampleCommandsMarkupProps,
7+
} from './example-commands-markup';
8+
import { type ShardKey } from '../store/reducer';
9+
10+
describe('ExampleCommandsMarkup', function () {
11+
const db = 'db1';
12+
const coll = 'coll1';
13+
const namespace = `${db}.${coll}`;
14+
const shardKey: ShardKey = {
15+
fields: [
16+
{ type: 'RANGE', name: 'location' },
17+
{ type: 'HASHED', name: 'secondary' },
18+
],
19+
isUnique: false,
20+
};
21+
22+
function renderWithProps(props?: Partial<ExampleCommandsMarkupProps>) {
23+
return renderWithStore(
24+
<ExampleCommandsMarkup
25+
namespace={namespace}
26+
shardKey={shardKey}
27+
{...props}
28+
/>
29+
);
30+
}
31+
32+
it('Contains sample codes', async function () {
33+
await renderWithProps();
34+
35+
const findingDocumentsSample = await screen.findByTestId(
36+
'sample-finding-documents'
37+
);
38+
expect(findingDocumentsSample).to.be.visible;
39+
expect(findingDocumentsSample.textContent).to.contain(
40+
`use db1db["coll1"].find({"location": "US-NY", "secondary": "<id_value>"})`
41+
);
42+
43+
const insertingDocumentsSample = await screen.findByTestId(
44+
'sample-inserting-documents'
45+
);
46+
expect(insertingDocumentsSample).to.be.visible;
47+
expect(insertingDocumentsSample.textContent).to.contain(
48+
`use db1db["coll1"].insertOne({"location": "US-NY", "secondary": "<id_value>",...<other fields>})`
49+
);
50+
});
51+
});

0 commit comments

Comments
 (0)