-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39906aa
commit 39e1539
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
packages/compass-global-writes/src/components/example-commands-markup.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import { renderWithStore } from '../../tests/create-store'; | ||
import { expect } from 'chai'; | ||
import { screen } from '@mongodb-js/testing-library-compass'; | ||
import ExampleCommandsMarkup, { | ||
type ExampleCommandsMarkupProps, | ||
} from './example-commands-markup'; | ||
import { type ShardKey } from '../store/reducer'; | ||
|
||
describe('ExampleCommandsMarkup', function () { | ||
const db = 'db1'; | ||
const coll = 'coll1'; | ||
const namespace = `${db}.${coll}`; | ||
const shardKey: ShardKey = { | ||
fields: [ | ||
{ type: 'RANGE', name: 'location' }, | ||
{ type: 'HASHED', name: 'secondary' }, | ||
], | ||
isUnique: false, | ||
}; | ||
|
||
function renderWithProps(props?: Partial<ExampleCommandsMarkupProps>) { | ||
return renderWithStore( | ||
<ExampleCommandsMarkup | ||
namespace={namespace} | ||
shardKey={shardKey} | ||
{...props} | ||
/> | ||
); | ||
} | ||
|
||
it('Contains sample codes', async function () { | ||
await renderWithProps(); | ||
|
||
const findingDocumentsSample = await screen.findByTestId( | ||
'sample-finding-documents' | ||
); | ||
expect(findingDocumentsSample).to.be.visible; | ||
expect(findingDocumentsSample.textContent).to.contain( | ||
`use db1db["coll1"].find({"location": "US-NY", "secondary": "<id_value>"})` | ||
); | ||
|
||
const insertingDocumentsSample = await screen.findByTestId( | ||
'sample-inserting-documents' | ||
); | ||
expect(insertingDocumentsSample).to.be.visible; | ||
expect(insertingDocumentsSample.textContent).to.contain( | ||
`use db1db["coll1"].insertOne({"location": "US-NY", "secondary": "<id_value>",...<other fields>})` | ||
); | ||
}); | ||
}); |