Skip to content

Commit

Permalink
Merge pull request krujos#39 from gambtho/readme_and_tests#
Browse files Browse the repository at this point in the history
Readme and tests#
  • Loading branch information
gambtho committed Apr 8, 2016
2 parents 0789448 + edaad69 commit 4333152
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,8 @@ You can run it locally by using
➜ ./gradlew bootRun
```

#ChatOps

Willitconnect can also be connected to hubot -- more information at [hubot-will-it-connect](https://www.npmjs.com/package/hubot-will-it-connect)


3 changes: 2 additions & 1 deletion src/main/resources/static/scripts/Entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var Entry = React.createClass({
mixpanel.track("connection attempted", { "canConnect": data.canConnect,
"httpStatus": data.httpStatus, "validHostName":data.validHostName,
"validUrl":data.validUrl});
console.log(data);
this.setState({status: data});
},
componentWillMount: function () {
Expand All @@ -40,7 +41,7 @@ var Entry = React.createClass({
if(Object.keys(this.state.status).length) {
connectionStyle = this.state.status.canConnect ? {color: 'green'} : {color: 'red'};
if(this.state.status.statusCode) {
resultString += " statusCode - " + this.state.status.statusCode;
resultString += " status: " + this.state.status.statusCode;
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/resources/static/scripts/EntryForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ var EntryForm = React.createClass({
var port = this.refs.port.getValue();

if (!this.isValid()) {
mixpanel.track("connect attempted with invalid form");
mixpanel.track("failed connect attempted", {"type": "invalid form"});
return;
}

if(this.state.isChecked) {
mixpanel.track("connect attempted with proxy");
mixpanel.track("failed connect attempted", {"type": "invalid form"});
proxyHost = this.refs.proxyHost.getValue();
proxyPort = this.refs.proxyPort.getValue();
}
Expand All @@ -48,7 +48,6 @@ var EntryForm = React.createClass({
hostUpdate: function() {
if(!this.isPortRequired()) {
this.setState({isPortRequired:false});
this.forceUpdate();
}
},
isPortRequired: function() {
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/static/scripts/__test__/EntryTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ describe('Entry', () => {

});

it("displays a host and port with a status code", function() {
entry = TestUtils.renderIntoDocument(<Entry host="test.com" port="80"/>);
jquery.ajax = jest.fn(() =>
entry.successFunc({"canConnect": true, "statusCode": "200"}));

entry.componentWillMount();
renderedEntry = ReactDOM.findDOMNode(entry);

expect(renderedEntry.children[0].textContent).toEqual("test.com:80 status: 200");
expect(renderedEntry.style._values.color).toEqual("green");

});

it("displays a host and port without a canConnect response", function() {
entry = TestUtils.renderIntoDocument(<Entry host="test.com" port="80"/>);
jquery.ajax = jest.fn(() =>
Expand Down

0 comments on commit 4333152

Please sign in to comment.