forked from mongodb-js/compass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(search-indexes): add search index signals COMPASS-7176 (mongodb-…
- Loading branch information
Showing
18 changed files
with
252 additions
and
107 deletions.
There are no files selected for viewing
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
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
45 changes: 20 additions & 25 deletions
45
packages/compass-aggregations/src/components/focus-mode/focus-mode.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 |
---|---|---|
@@ -1,51 +1,46 @@ | ||
import React from 'react'; | ||
import type { ComponentProps } from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { expect } from 'chai'; | ||
import { Provider } from 'react-redux'; | ||
import sinon from 'sinon'; | ||
|
||
import configureStore from '../../../test/configure-store'; | ||
import { FocusMode } from './focus-mode'; | ||
import FocusMode from './focus-mode'; | ||
import { disableFocusMode, enableFocusMode } from '../../modules/focus-mode'; | ||
|
||
const renderFocusMode = ( | ||
props: Partial<ComponentProps<typeof FocusMode>> = {} | ||
) => { | ||
const renderFocusMode = () => { | ||
const store = configureStore({ | ||
pipeline: [{ $match: { _id: 1 } }, { $limit: 10 }, { $out: 'out' }], | ||
}); | ||
render( | ||
<Provider | ||
store={configureStore({ | ||
pipeline: [{ $match: { _id: 1 } }, { $limit: 10 }, { $out: 'out' }], | ||
})} | ||
> | ||
<FocusMode | ||
isModalOpen={true} | ||
isAutoPreviewEnabled={true} | ||
onCloseModal={() => {}} | ||
{...props} | ||
/> | ||
<Provider store={store}> | ||
<FocusMode /> | ||
</Provider> | ||
); | ||
return store; | ||
}; | ||
|
||
describe('FocusMode', function () { | ||
it('does not show modal when closed', function () { | ||
renderFocusMode({ isModalOpen: false }); | ||
const store = renderFocusMode(); | ||
store.dispatch(disableFocusMode()); | ||
expect(() => { | ||
screen.getByTestId('focus-mode-modal'); | ||
}).to.throw; | ||
}); | ||
|
||
it('shows modal when open', function () { | ||
renderFocusMode({ isModalOpen: true }); | ||
const store = renderFocusMode(); | ||
store.dispatch(enableFocusMode(0)); | ||
expect(screen.getByTestId('focus-mode-modal')).to.exist; | ||
}); | ||
|
||
it('calls onCloseModal when close button is clicked', function () { | ||
const onCloseModal = sinon.spy(); | ||
renderFocusMode({ onCloseModal, isModalOpen: true }); | ||
|
||
expect(onCloseModal).to.not.have.been.called; | ||
it('hides modal when close button is clicked', function () { | ||
const store = renderFocusMode(); | ||
store.dispatch(enableFocusMode(0)); | ||
screen.getByLabelText(/close modal/i).click(); | ||
expect(onCloseModal).to.have.been.calledOnce; | ||
|
||
expect(() => { | ||
screen.getByTestId('focus-mode-modal'); | ||
}).to.throw; | ||
}); | ||
}); |
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
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
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
Oops, something went wrong.