Skip to content

Commit cc99252

Browse files
authored
Merge pull request #40 from oslabs-beta/testing
fixed testing suites not running, added two tests
2 parents fc8b350 + 7016fd4 commit cc99252

File tree

8 files changed

+36
-8
lines changed

8 files changed

+36
-8
lines changed

__mocks__/electronMock.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const ipcRenderer = {
2+
on: jest.fn()
3+
};

__mocks__/styleMocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = {};
1+
module.exports = 'test-file-stub';

__tests__/businessReducer.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import reducer from '../src/client/reducers/business';
2+
import {remote} from "electron";
23

34
describe('Business reducer', () => {
45
let state;
@@ -14,12 +15,26 @@ describe('Business reducer', () => {
1415
protocol: '',
1516
url: 'http://',
1617
method: 'GET',
17-
graphQL: false
18+
graphQL: false,
19+
gRPC: false
1820
},
1921
newRequestHeaders: {
2022
headersArr: [],
2123
count: 0,
2224
},
25+
newRequestStreams: {
26+
streamsArr: [],
27+
count: 0,
28+
streamContent: [],
29+
selectedPackage: null,
30+
selectedRequest: null,
31+
selectedService: null,
32+
selectedStreamingType: null,
33+
initialQuery: null,
34+
queryArr: null,
35+
protoPath: null,
36+
services: null,
37+
},
2338
newRequestCookies: {
2439
cookiesArr: [],
2540
count: 0,

__tests__/composerTests.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import React from 'react';
55
import { configure, shallow } from 'enzyme';
66
import Adapter from 'enzyme-adapter-react-16';
77
import toJson, { mountToJson } from 'enzyme-to-json';
8-
8+
import {remote} from "electron";
99
import { JestEnvironment } from '@jest/environment';
1010
// Enzyme is a wrapper around React test utilities which makes it easier to
1111
// shallow render and traverse the shallow rendered tree.
1212
// import * as actions from '../src/client/actions/actions.js';
1313
// import httpController from '../src/client/controllers/httpController.js'
1414
// import historyController from '../src/client/controllers/historyController.js'
1515
// import reqResController from '../src/client/controllers/reqResController.js'
16-
1716
// import ComposerNewRequest from "../src/client/components/composer/NewRequest/ComposerNewRequest.jsx"; //doesn't like png
1817
import ProtocolSelect from "../src/client/components/composer/NewRequest/ProtocolSelect.jsx";
1918
import FieldEntryForm from "../src/client/components/composer/NewRequest/FieldEntryForm.jsx";

__tests__/responseTests.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ describe('ResponseEventsDisplay', () => {
6767
const wrapper = shallow(<ResponseEventsDisplay {...props} />);
6868
expect(wrapper.find('SSERow')).toHaveLength(2);
6969
});
70+
// it('if gRPC, should render all events', () => {
71+
// const props = {
72+
// response: {
73+
// headers: { 'content-type': 'text/event-stream' },
74+
// events: ['event 1', 'event 2'],
75+
// }
76+
// };
77+
// const wrapper = shallow(<ResponseEventsDisplay {...props} />);
78+
// expect(wrapper.find('JSONPretty').props.data).toHaveLength(2);
79+
// });
7080
it('if not SSE, should render single event', () => {
7181
const props = {
7282
response: {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@
143143
"verbose": true,
144144
"collectCoverage": true,
145145
"moduleNameMapper": {
146-
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "./__mocks__/fileMock.js"
146+
"electron": "<rootDir>/__mocks__/electronMock.js",
147+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/styleMocks.js"
147148
}
148149
},
149150
"license": "MIT",

src/client/components/display/ResponseTabs.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class ResponseTabs extends Component {
1414
<ul className="tab_list-response">
1515
<Tab onTabSelected={this.props.handleTabSelect} tabName={events} key="events" openTab={this.props.openResponseTab}/>
1616
<Tab onTabSelected={this.props.handleTabSelect} tabName={headers} key="headers" openTab={this.props.openResponseTab}/>
17-
{
17+
<Tab onTabSelected={this.props.handleTabSelect} tabName={cookies} key="cookies" openTab={this.props.openResponseTab}/>
18+
{/* {
1819
!this.props.responseContent.bodyType === "GRPC" &&
1920
<Tab onTabSelected={this.props.handleTabSelect} tabName={cookies} key="cookies" openTab={this.props.openResponseTab}/>
20-
}
21+
} */}
2122
</ul>
2223
);
2324
}

src/client/reducers/business.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const initialState = {
4242
bodyType: 'none',
4343
rawType: 'Text (text/plain)',
4444
JSONFormatted: true,
45-
// protoContent: null
4645
},
4746
newRequestSSE: {
4847
isSSE: false

0 commit comments

Comments
 (0)