|
1 | 1 | import React from 'react'; |
2 | | -import Reflux from 'reflux'; |
3 | | -import { mount } from 'enzyme'; |
| 2 | +import { render, screen } from '@mongodb-js/testing-library-compass'; |
4 | 3 | import HadronDocument from 'hadron-document'; |
5 | 4 | import { expect } from 'chai'; |
6 | 5 | import sinon from 'sinon'; |
7 | 6 |
|
8 | 7 | import EditableDocument from './editable-document'; |
9 | | -import { CompassComponentsProvider } from '@mongodb-js/compass-components'; |
10 | 8 |
|
11 | 9 | describe('<EditableDocument />', function () { |
12 | | - describe('#render', function () { |
13 | | - let wrapper; |
| 10 | + describe('render', function () { |
14 | 11 | const doc = { a: 1, b: 2, c: null }; |
15 | | - const action = Reflux.createAction(); |
16 | 12 |
|
17 | | - before(function () { |
18 | | - wrapper = mount( |
| 13 | + beforeEach(function () { |
| 14 | + render( |
19 | 15 | <EditableDocument |
20 | 16 | doc={new HadronDocument(doc)} |
21 | | - removeDocument={sinon.spy(action)} |
22 | | - replaceDocument={sinon.spy(action)} |
23 | | - updateDocument={sinon.spy(action)} |
24 | | - copyToClipboard={sinon.spy(action)} |
25 | | - openInsertDocumentDialog={sinon.spy(action)} |
26 | | - />, |
27 | | - { wrappingComponent: CompassComponentsProvider } |
| 17 | + removeDocument={sinon.spy()} |
| 18 | + replaceDocument={sinon.spy()} |
| 19 | + updateDocument={sinon.spy()} |
| 20 | + copyToClipboard={sinon.spy()} |
| 21 | + openInsertDocumentDialog={sinon.spy()} |
| 22 | + /> |
28 | 23 | ); |
29 | 24 | }); |
30 | 25 |
|
31 | 26 | it('renders the list div', function () { |
32 | | - const component = wrapper.find('[data-testid="editable-document"]'); |
33 | | - (expect(component) as any).to.be.present(); |
| 27 | + const component = screen.getByTestId('editable-document'); |
| 28 | + expect(component).to.exist; |
34 | 29 | }); |
35 | 30 |
|
36 | 31 | it('renders the base element list', function () { |
37 | | - const component = wrapper.find( |
38 | | - '[data-testid="editable-document-elements"]' |
39 | | - ); |
40 | | - (expect(component) as any).to.be.present(); |
| 32 | + const component = screen.getByTestId('editable-document-elements'); |
| 33 | + expect(component).to.exist; |
41 | 34 | }); |
42 | 35 |
|
43 | 36 | it('renders an editable element for each document element', function () { |
44 | | - const component = wrapper.find('[data-testid="hadron-document-element"]'); |
45 | | - expect(component).to.have.lengthOf(3); |
| 37 | + const components = screen.getAllByTestId('hadron-document-element'); |
| 38 | + expect(components).to.have.lengthOf(3); |
46 | 39 | }); |
47 | 40 | }); |
48 | 41 | }); |
0 commit comments