Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TooFiveFive committed Mar 15, 2019
1 parent e048bcd commit 62d8d17
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 48 deletions.
20 changes: 12 additions & 8 deletions test/actions/canvas.spec.ts
Expand Up @@ -26,18 +26,22 @@ describe("Wiring", () => {
describe("isClicked", () => {
it("returns gate", () => {
if (ctx !== null) {
const obj = [new AndGate(ctx), new AndGate(ctx)];
obj[0].add({ x: 100, y: 100 }, { width: 40, height: 40 });
const coords: GateCoords = { x: 110, y: 110 };
expect(Wiring.isClicked(obj, coords)).toBe(obj[0]);
AndGate.LOAD(ctx).then(() => {
const obj = [new AndGate(ctx)];
obj[0].add({ x: 100, y: 100 }, { width: 40, height: 40 });
const coords: GateCoords = { x: 110, y: 110 };
expect(Wiring.isClicked(obj, coords)).toBe(obj[0]);
});
}
});
it("returns null", () => {
if (ctx !== null) {
const obj = [new AndGate(ctx), new AndGate(ctx)];
obj[0].add({ x: 100, y: 100 }, { width: 40, height: 40 });
const coords: GateCoords = { x: 140, y: 140 };
expect(Wiring.isClicked(obj, coords)).toBe(obj[0]);
AndGate.LOAD(ctx).then(() => {
const obj = [new AndGate(ctx)];
obj[0].add({ x: 100, y: 100 }, { width: 40, height: 40 });
const coords: GateCoords = { x: 140, y: 140 };
expect(Wiring.isClicked(obj, coords)).toBe(obj[0]);
});
}
});
});
Expand Down
18 changes: 10 additions & 8 deletions test/gates/AND.spec.ts
Expand Up @@ -7,15 +7,17 @@ const ctx = canvas.getContext("2d");
describe("AndGate", () => {
it("initiates", () => {
if (ctx !== null) {
const gate = new AndGate(ctx);
const coords: GateCoords = {x: 100, y: 100};
const size: GateSize = {width: 40, height: 40};
const wrapper = gate.add(coords, size);
expect(wrapper).toHaveProperty("start");
expect(wrapper).toHaveProperty("end");
AndGate.LOAD(ctx).then(() => {
const gate = new AndGate(ctx);
const coords: GateCoords = {x: 100, y: 100};
const size: GateSize = {width: 40, height: 40};
const wrapper = gate.add(coords, size);
expect(wrapper).toHaveProperty("start");
expect(wrapper).toHaveProperty("end");

expect(wrapper.end).toHaveLength(2);
expect(wrapper.start).toHaveLength(1);
expect(wrapper.end).toHaveLength(2);
expect(wrapper.start).toHaveLength(1);
});
}
});
});
19 changes: 11 additions & 8 deletions test/gates/LED.spec.ts
Expand Up @@ -7,15 +7,18 @@ const ctx = canvas.getContext("2d");
describe("LED", () => {
it("initiates", () => {
if (ctx !== null) {
const gate = new LED(ctx);
const coords: GateCoords = {x: 100, y: 100};
const size: GateSize = {width: 40, height: 40};
const wrapper = gate.add(coords, size);
expect(wrapper).toHaveProperty("start");
expect(wrapper).toHaveProperty("end");
LED.LOAD(ctx).then(() => {
const gate = new LED(ctx);
const coords: GateCoords = {x: 100, y: 100};
const size: GateSize = {width: 40, height: 40};
const wrapper = gate.add(coords, size);
expect(wrapper).toHaveProperty("start");
expect(wrapper).toHaveProperty("end");

expect(wrapper.end).toHaveLength(1);
expect(wrapper.start).toHaveLength(0);
expect(wrapper.end).toHaveLength(1);
expect(wrapper.start).toHaveLength(0);
});

}
});
});
19 changes: 11 additions & 8 deletions test/gates/NOT.spec.ts
Expand Up @@ -7,15 +7,18 @@ const ctx = canvas.getContext("2d");
describe("NotGate", () => {
it("initiates", () => {
if (ctx !== null) {
const gate = new NotGate(ctx);
const coords: GateCoords = {x: 100, y: 100};
const size: GateSize = {width: 40, height: 40};
const wrapper = gate.add(coords, size);
expect(wrapper).toHaveProperty("start");
expect(wrapper).toHaveProperty("end");
NotGate.LOAD(ctx).then(() => {
const gate = new NotGate(ctx);
const coords: GateCoords = {x: 100, y: 100};
const size: GateSize = {width: 40, height: 40};
const wrapper = gate.add(coords, size);
expect(wrapper).toHaveProperty("start");
expect(wrapper).toHaveProperty("end");

expect(wrapper.end).toHaveLength(1);
expect(wrapper.start).toHaveLength(1);
expect(wrapper.end).toHaveLength(1);
expect(wrapper.start).toHaveLength(1);
});

}
});
});
18 changes: 10 additions & 8 deletions test/gates/OR.spec.ts
Expand Up @@ -7,15 +7,17 @@ const ctx = canvas.getContext("2d");
describe("OrGate", () => {
it("initiates", () => {
if (ctx !== null) {
const gate = new OrGate(ctx);
const coords: GateCoords = {x: 100, y: 100};
const size: GateSize = {width: 40, height: 40};
const wrapper = gate.add(coords, size);
expect(wrapper).toHaveProperty("start");
expect(wrapper).toHaveProperty("end");
OrGate.LOAD(ctx).then(() => {
const gate = new OrGate(ctx);
const coords: GateCoords = {x: 100, y: 100};
const size: GateSize = {width: 40, height: 40};
const wrapper = gate.add(coords, size);
expect(wrapper).toHaveProperty("start");
expect(wrapper).toHaveProperty("end");

expect(wrapper.end).toHaveLength(2);
expect(wrapper.start).toHaveLength(1);
expect(wrapper.end).toHaveLength(1);
expect(wrapper.start).toHaveLength(1);
});
}
});
});
18 changes: 10 additions & 8 deletions test/gates/Switch.spec.ts
Expand Up @@ -7,15 +7,17 @@ const ctx = canvas.getContext("2d");
describe("Switch", () => {
it("initiates", () => {
if (ctx !== null) {
const gate = new Switch(ctx);
const coords: GateCoords = {x: 100, y: 100};
const size: GateSize = {width: 40, height: 40};
const wrapper = gate.add(coords, size);
expect(wrapper).toHaveProperty("start");
expect(wrapper).toHaveProperty("end");
Switch.LOAD(ctx).then(() => {
const gate = new Switch(ctx);
const coords: GateCoords = {x: 100, y: 100};
const size: GateSize = {width: 40, height: 40};
const wrapper = gate.add(coords, size);
expect(wrapper).toHaveProperty("start");
expect(wrapper).toHaveProperty("end");

expect(wrapper.end).toHaveLength(0);
expect(wrapper.start).toHaveLength(1);
expect(wrapper.end).toHaveLength(1);
expect(wrapper.start).toHaveLength(1);
});
}
});
});

0 comments on commit 62d8d17

Please sign in to comment.