Skip to content

Commit

Permalink
Merge pull request #352 from RickCarlino/master
Browse files Browse the repository at this point in the history
Yarnfile Updates
  • Loading branch information
RickCarlino committed Jul 25, 2017
2 parents 2c36aa2 + 2cba721 commit 743ebe7
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 16 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@
"webpack": "^3.3.0",
"webpack-uglify-js-plugin": "^1.1.9",
"weinre": "^2.0.0-pre-I0Z7U9OV",
"yarn": "^0.27.5"
"yarn": "^0.27.5",
"@types/moxios": "^0.4.2",
"moxios": "^0.4.0"
},
"devDependencies": {
"@types/moxios": "^0.4.2",
"jscpd": "^0.6.13",
"moxios": "^0.4.0",
"webpack-notifier": "^1.5.0"
},
"jest": {
Expand Down
1 change: 1 addition & 0 deletions src/account/__tests__/actions_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe("deleteUser()", () => {
});

it("cancels the account", (done) => {
expect.assertions(2);
API.setBaseUrl("http://example.com:80");
let thunk = deleteUser({ password: "Foo!" });
let dispatch = jest.fn();
Expand Down
18 changes: 11 additions & 7 deletions src/farm_designer/farm_events/map_state_to_props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function mapStateToProps(state: Everything): FarmEventProps {
return { calendarRows, push };
}

/** TODO: Reduce complexity, but write *good* unit tests *before* refactoring.*/
export function mapResourcesToCalendar(ri: ResourceIndex, unixNow = moment.now()): Calendar {
let x = joinFarmEventsToExecutable(ri);
let calendar = new Calendar();
Expand All @@ -30,13 +31,16 @@ export function mapResourcesToCalendar(ri: ResourceIndex, unixNow = moment.now()
.clone()
.startOf("day")
.add(regi.time_offset, "milliseconds");
if (m2.isBefore(unixNow)) { return; }
let o = occurrence(m2, fe);
let seq = findSequenceById(ri, regi.sequence_id);
let sequenceName = seq.body.name;
o.parentExecutableName = fe.executable.name;
o.childExecutableName = sequenceName;
calendar.insert(o);
if (m2.isBefore(m)) {
return;
} else {
let o = occurrence(m2, fe);
let seq = findSequenceById(ri, regi.sequence_id);
let sequenceName = seq.body.name;
o.parentExecutableName = fe.executable.name;
o.childExecutableName = sequenceName;
calendar.insert(o);
}
});
}
});
Expand Down
45 changes: 45 additions & 0 deletions src/password_reset/__tests__/password_reset_test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as React from "react";
import { mount } from "enzyme";
import { PasswordReset } from "../password_reset";
import * as moxios from "moxios";
import { API } from "../../api/api";
import { State } from "../interfaces";

describe("<PasswordReset/>", () => {
beforeEach(function () {
// import and pass your custom axios instance to this method
moxios.install();
});

afterEach(function () {
// import and pass your custom axios instance to this method
moxios.uninstall();
});

fit("resets the users password", (done) => {
expect.assertions(5);
let el = mount(<PasswordReset />);
el.setState({
password: "knocknock",
passwordConfirmation: "knocknock",
serverURL: "localhost",
serverPort: "3000"
});
el.find("form").simulate("submit", { preventDefault: jest.fn() });
moxios.wait(function () {
let request = moxios.requests.mostRecent();
request.respondWith({
status: 200,
response: {}
}).then(function (resp) {
expect(resp.config.url).toContain("api/password_resets");
expect(resp.config.method).toEqual("put");
let json: State = JSON.parse(resp.config.data);
expect(Object.keys(json)).toContain("password");
expect(Object.keys(json)).toContain("password_confirmation");
expect(json.password).toEqual("knocknock");
done();
});
});
});
});
2 changes: 1 addition & 1 deletion src/password_reset/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export interface State {
serverPort?: string;
}

export interface Props { };
export interface Props { }
3 changes: 1 addition & 2 deletions src/password_reset/password_reset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { error as log, init as logInit } from "farmbot-toastr";
import { prettyPrintApiErrors } from "../util";
import { API } from "../api";
import { State, Props } from "./interfaces";
import { hardRefresh } from "../util";
hardRefresh();

export class PasswordReset extends React.Component<Props, State> {
constructor() {
super();
Expand Down
1 change: 0 additions & 1 deletion src/regimens/list/add_button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ export function AddRegimen(props: AddRegimenProps) {
{props.children || <i className="fa fa-plus" />}
</button>;
}

4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3056,14 +3056,14 @@ js-tokens@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7"

js-yaml@3.6.1:
js-yaml@3.6.1, js-yaml@>=3.4.x:
version "3.6.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30"
dependencies:
argparse "^1.0.7"
esprima "^2.6.0"

js-yaml@>=3.4.x, js-yaml@^3.7.0, js-yaml@~3.7.0:
js-yaml@^3.7.0, js-yaml@~3.7.0:
version "3.7.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80"
dependencies:
Expand Down

0 comments on commit 743ebe7

Please sign in to comment.