Skip to content

Commit 837dc91

Browse files
committed
fixed merge conflicts
2 parents d3f9b9d + b1f779f commit 837dc91

File tree

10 files changed

+125
-25
lines changed

10 files changed

+125
-25
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/composer/NewRequest/GRPCAutoInputForm.jsx

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class GRPCAutoInputForm extends Component {
1313
this.setService = this.setService.bind(this);
1414
this.setRequest = this.setRequest.bind(this);
1515
}
16-
// event handler on the arrow button that allows you to open/close the section
16+
// event handler on the arrow button that allows you to open/close the section
1717
toggleShow() {
1818
this.setState({
1919
show: !this.state.show
@@ -86,9 +86,9 @@ class GRPCAutoInputForm extends Component {
8686
let streamingType;
8787
let packageName;
8888
/*
89-
for each service obj in the services array, if its name matches the current selected service option then:
89+
for each service obj in the services array, if its name matches the current selected service option then:
9090
- save the package name
91-
- iterate through the rpcs and if its name matches the current selected request then save its streaming type
91+
- iterate through the rpcs and if its name matches the current selected request then save its streaming type
9292
*/
9393
for (const service of services) {
9494
if (service.name === selectedService ) {
@@ -112,7 +112,7 @@ class GRPCAutoInputForm extends Component {
112112
let req;
113113
let results = [];
114114
let query = '';
115-
/*
115+
/*
116116
for each service obj in the services array, if its name matches the current selected service option then:
117117
- iterate through the rpcs and if its name matches the current selected request then save the name of req/rpc
118118
- iterate through the messages and if its name matches the saved req/rpc name,
@@ -126,15 +126,41 @@ class GRPCAutoInputForm extends Component {
126126
}
127127
}
128128
for (const message of service.messages) {
129+
// console.log('message: ', message);
129130
if (message.name === req ) {
130131
for (const key in message.def) {
132+
// if message type is a nested message (message.def.nested === true)
133+
// message.def = key: {dependent: dependent.message.def}
134+
// console.log('message.def.nested: ', message.def[key].nested);
135+
// console.log('key: ', key);
136+
if (message.def[key].nested) {
137+
for (const submess of service.messages) {
138+
// console.log('submess: ', submess);
139+
// console.log('submess.name: ', submess.name);
140+
// console.log('message.def[key].dependent: ', message.def[key].dependent);
141+
if (submess.name === message.def[key].dependent ) {
142+
// define obj for the submessage definition
143+
let tempObj = {};
144+
for (const subKey in submess.def) {
145+
tempObj[subKey] = submess.def[subKey].type.slice(5).toLowerCase()
146+
}
147+
// console.log('tempObj: ', tempObj);
148+
results.push(`"${key}":${JSON.stringify(tempObj)}`)
149+
break;
150+
}
151+
// break;
152+
}//after
153+
} else {
154+
// console.log('message.def: ', message.def);
131155
results.push(`"${key}": "${message.def[key].type.slice(5).toLowerCase()}"`)
132156
}
133-
break;
134157
}
135-
}
158+
break;
136159
}
137160
}
161+
}
162+
}
163+
138164
const streamsArr = this.props.newRequestStreams.streamsArr;
139165
const streamContent = this.props.newRequestStreams.streamContent;
140166
// query for messages with single key:value pair
@@ -149,7 +175,7 @@ class GRPCAutoInputForm extends Component {
149175
}
150176
query = query.slice(1).trim();
151177
}
152-
// set query in streamsArr
178+
// set query in streamsArr
153179
if (streamsArr[0] !== '') {
154180
streamsArr[0].query = `{
155181
${query}
Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,55 @@
1+
// Copyright 2015 gRPC authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
syntax = "proto3";
216

3-
package helloworld;
17+
option java_multiple_files = true;
18+
option java_package = "io.grpc.examples.routeguide";
19+
option java_outer_classname = "RouteGuideProto";
20+
option objc_class_prefix = "RTG";
421

5-
// The greeting service definition.
6-
service Greeter {
7-
// Sends a greeting
8-
rpc SayHello (HelloRequest) returns (HelloReply) {}
9-
rpc SayHelloCS (stream HelloRequest) returns (HelloReply) {}
10-
rpc SayHellos (HelloRequest) returns (stream HelloReply) {}
11-
rpc SayHelloBidi (stream HelloRequest) returns (stream HelloReply) {}
22+
package routeguide;
23+
24+
// Interface exported by the server.
25+
service RouteGuide {
26+
// A simple RPC.
27+
//
28+
// Obtains the feature at a given position.
29+
//
30+
// A feature with an empty name is returned if there's no feature at the given
31+
// position.
32+
rpc GetFeature(Point) returns (Feature) {}
33+
34+
// A server-to-client streaming RPC.
35+
//
36+
// Obtains the Features available within the given Rectangle. Results are
37+
// streamed rather than returned at once (e.g. in a response message with a
38+
// repeated field), as the rectangle may cover a large area and contain a
39+
// huge number of features.
40+
rpc ListFeatures(Rectangle) returns (stream Feature) {}
41+
42+
// A client-to-server streaming RPC.
43+
//
44+
// Accepts a stream of Points on a route being traversed, returning a
45+
// RouteSummary when traversal is completed.
46+
rpc RecordRoute(stream Point) returns (RouteSummary) {}
47+
48+
// A Bidirectional streaming RPC.
49+
//
50+
// Accepts a stream of RouteNotes sent while a route is being traversed,
51+
// while receiving other RouteNotes (e.g. from other users).
52+
rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
1253
}
1354

1455
service Butler {
@@ -23,7 +64,13 @@ message HelloRequest {
2364
string name = 1;
2465
}
2566

26-
// The response message containing the greetings
27-
message HelloReply {
28-
string message = 1;
67+
// A feature names something at a given point.
68+
//
69+
// If a feature could not be named, the name is empty.
70+
message Feature {
71+
// The name of the feature.
72+
string name = 1;
73+
74+
// The point where the feature is detected.
75+
Point location = 2;
2976
}

src/client/components/display/ResponseTabs.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ResponseTabs extends Component {
1818
{
1919
!this.props.content.gRPC &&
2020
<Tab onTabSelected={this.props.handleTabSelect} tabName={cookies} key="cookies" openTab={this.props.openResponseTab}/>
21-
}
21+
} */}
2222
</ul>
2323
);
2424
}

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)