Skip to content

Commit a0f4ffe

Browse files
committed
test: change editable document test from enzyme to testing library
1 parent 197d0ed commit a0f4ffe

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed
Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,41 @@
11
import React from 'react';
2-
import Reflux from 'reflux';
3-
import { mount } from 'enzyme';
2+
import { render, screen } from '@mongodb-js/testing-library-compass';
43
import HadronDocument from 'hadron-document';
54
import { expect } from 'chai';
65
import sinon from 'sinon';
76

87
import EditableDocument from './editable-document';
9-
import { CompassComponentsProvider } from '@mongodb-js/compass-components';
108

119
describe('<EditableDocument />', function () {
12-
describe('#render', function () {
13-
let wrapper;
10+
describe('render', function () {
1411
const doc = { a: 1, b: 2, c: null };
15-
const action = Reflux.createAction();
1612

17-
before(function () {
18-
wrapper = mount(
13+
beforeEach(function () {
14+
render(
1915
<EditableDocument
2016
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+
/>
2823
);
2924
});
3025

3126
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;
3429
});
3530

3631
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;
4134
});
4235

4336
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);
4639
});
4740
});
4841
});

0 commit comments

Comments
 (0)