pull/1061/head
Rick Carlino 2018-12-05 17:01:51 -06:00
parent 9219126e95
commit 3af0875530
2 changed files with 34 additions and 3 deletions

View File

@ -10,7 +10,8 @@ import { saveOK } from "../actions";
import { hasId, arrayUnwrap } from "../util";
import {
fakeWebcamFeed,
fakeSequence
fakeSequence,
fakePlant
} from "../../__test_support__/fake_state/resources";
import * as _ from "lodash";
import { resourceReducer } from "../reducer";
@ -136,6 +137,14 @@ describe("findPlant()", () => {
expect(find).toThrowError();
expect(console.warn).toBeCalled();
});
it("finds a plant", () => {
const plant = fakePlant();
plant.body.id = 333;
const result = Selector
.findPlant(buildResourceIndex([plant]).index, plant.uuid);
expect(result.uuid).toBe(plant.uuid);
});
});
describe("selectCurrentToolSlot()", () => {
@ -153,7 +162,29 @@ describe("getSequenceByUUID()", () => {
expect(console.warn).toBeCalled();
});
});
describe("getUserAccountSettings", () => {
it("throws exceptions when user is not loaded", () => {
const boom = () => Selector
.getUserAccountSettings(buildResourceIndex([]).index);
expect(boom)
.toThrow("PROBLEM: Tried to fetch user before it was available.");
});
});
describe("maybeGetSequence", () => {
it("returns undefined", () => {
const i = buildResourceIndex([]);
const result = Selector.maybeGetSequence(i.index, undefined);
expect(result).toBe(undefined);
});
it("returns a sequence", () => {
const s = fakeSequence();
const i = buildResourceIndex([s]);
const result = Selector.maybeGetSequence(i.index, s.uuid);
expect(result).toBeTruthy();
result && expect(result.uuid).toBe(s.uuid);
});
})
describe("findAllById()", () => {
it("returns", () => {
const result = Selector.findAllById(fakeIndex, [23], "Sequence");

View File

@ -86,8 +86,8 @@ export class RefactoredExecuteBlock extends React.Component<ExecBlockParams, {}>
extractParent(resources, calleeUuid) : undefined;
const whatever: VariableDeclaration | undefined =
(this.props.currentStep.body || [])[0];
const selectedParameter =
whatever ? whatever.args.data_value : EMPTY_COORD;
const selectedParameter = whatever ?
whatever.args.data_value : EMPTY_COORD;
return <StepWrapper>
<StepHeader
className={className}