diff --git a/packages/compass-global-writes/src/components/example-commands-markup.spec.tsx b/packages/compass-global-writes/src/components/example-commands-markup.spec.tsx new file mode 100644 index 00000000000..77cc92ed53e --- /dev/null +++ b/packages/compass-global-writes/src/components/example-commands-markup.spec.tsx @@ -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) { + return renderWithStore( + + ); + } + + 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": ""})` + ); + + 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": "",...})` + ); + }); +});