Skip to content

Commit

Permalink
refactor: remove unnecessary usage of shallow wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Syed-Ali-Abbas-Zaidi committed Jan 25, 2024
1 parent aae713e commit e70a6d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ describe('BulkManagementAlerts', () => {
expect(el.snapshot).toMatchSnapshot();
});
test('closed danger alert', () => {
expect(el.shallowWrapper.props.children[0].type).toBe(Alert);
expect(el.instance.children[0].type).toBe('Alert');
expect(el.instance.findByType(Alert)[0].props.show).toEqual(false);
expect(el.instance.findByType(Alert)[0].props.variant).toEqual('danger');
});
test('closed success alert', () => {
expect(el.shallowWrapper.props.children[1].type).toBe(Alert);
expect(el.instance.children[1].type).toBe('Alert');
expect(el.instance.findByType(Alert)[1].props.show).toEqual(false);
expect(el.instance.findByType(Alert)[1].props.variant).toEqual('success');
});
Expand All @@ -60,16 +60,16 @@ describe('BulkManagementAlerts', () => {
expect(el.snapshot).toMatchSnapshot();
});
test('open danger alert with bulkImportError content', () => {
expect(el.shallowWrapper.props.children[0].type).toBe(Alert);
expect(el.instance.children[0].type).toBe('Alert');
expect(el.instance.findByType(Alert)[0].children[0].el).toEqual(errorMessage);
expect(el.instance.findByType(Alert)[0].props.show).toEqual(true);
});
test('open success alert with messages.successDialog content', () => {
expect(el.shallowWrapper.props.children[1].type).toBe(Alert);
expect(el.instance.children[1].type).toBe('Alert');
expect(el.shallowWrapper.props.children[1].props.children).toEqual(
<FormattedMessage {...messages.successDialog} />,
);
expect(el.shallowWrapper.props.children[1].props.show).toEqual(true);
expect(el.instance.children[1].props.show).toEqual(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/GradesView/GradebookTable/Fields.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Gradebook Table Fields', () => {
expect(el.snapshot).toMatchSnapshot();
});
test('wraps external user key and username', () => {
expect(el.instance.findByType('span')[0]).toMatchSnapshot();
expect(el.instance.findByType('span')[0].el).toMatchSnapshot();
const content = el.instance.findByType('span')[0].children[0];
expect(content.children[0].children[0].el).toEqual(username);
expect(content.children[1].children[0].el).toEqual(props.userKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,168 +28,34 @@ exports[`Gradebook Table Fields Username with external_user_key snapshot 1`] = `
`;

exports[`Gradebook Table Fields Username with external_user_key wraps external user key and username 1`] = `
ElementExplorer {
Object {
"children": Array [
ElementExplorer {
Object {
"children": Array [
ElementExplorer {
Object {
"children": Array [
ElementExplorer {
"children": Array [],
"el": "MyNameFromHere",
"parent": [Circular],
"props": Object {},
"toSnapshot": [Function],
"type": null,
},
"MyNameFromHere",
],
"el": Object {
"children": Array [
"MyNameFromHere",
],
"props": Object {},
"type": "div",
},
"parent": [Circular],
"props": Object {},
"toSnapshot": [Function],
"type": "div",
},
ElementExplorer {
Object {
"children": Array [
ElementExplorer {
"children": Array [],
"el": "My name from another land",
"parent": [Circular],
"props": Object {},
"toSnapshot": [Function],
"type": null,
},
"My name from another land",
],
"el": Object {
"children": Array [
"My name from another land",
],
"props": Object {
"className": "student-key",
},
"type": "div",
},
"parent": [Circular],
"props": Object {
"className": "student-key",
},
"toSnapshot": [Function],
"type": "div",
},
],
"el": Object {
"children": Array [
Object {
"children": Array [
"MyNameFromHere",
],
"props": Object {},
"type": "div",
},
Object {
"children": Array [
"My name from another land",
],
"props": Object {
"className": "student-key",
},
"type": "div",
},
],
"props": Object {},
"type": "div",
},
"parent": [Circular],
"props": Object {},
"toSnapshot": [Function],
"type": "div",
},
],
"el": Object {
"children": Array [
Object {
"children": Array [
Object {
"children": Array [
"MyNameFromHere",
],
"props": Object {},
"type": "div",
},
Object {
"children": Array [
"My name from another land",
],
"props": Object {
"className": "student-key",
},
"type": "div",
},
],
"props": Object {},
"type": "div",
},
],
"props": Object {
"className": "wrap-text-in-cell",
},
"type": "span",
},
"parent": ElementExplorer {
"children": Array [
[Circular],
],
"el": Object {
"children": Array [
Object {
"children": Array [
Object {
"children": Array [
Object {
"children": Array [
"MyNameFromHere",
],
"props": Object {},
"type": "div",
},
Object {
"children": Array [
"My name from another land",
],
"props": Object {
"className": "student-key",
},
"type": "div",
},
],
"props": Object {},
"type": "div",
},
],
"props": Object {
"className": "wrap-text-in-cell",
},
"type": "span",
},
],
"props": Object {},
"type": "div",
},
"parent": null,
"props": Object {},
"toSnapshot": [Function],
"type": "div",
},
"props": Object {
"className": "wrap-text-in-cell",
},
"toSnapshot": [Function],
"type": "span",
}
`;
Expand Down

0 comments on commit e70a6d2

Please sign in to comment.