Skip to content

Commit

Permalink
add US-4 acceptance test #31
Browse files Browse the repository at this point in the history
add supercheck, supercheck-travis, and bleach to package.json

rename files to corresponding USs #31
  • Loading branch information
ritchellesap committed Mar 27, 2020
1 parent ccd3144 commit 1b33045
Show file tree
Hide file tree
Showing 12 changed files with 21,787 additions and 62 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ before_script:
- curl https://pre-commit.com/install-local.py | python -
- pre-commit install
script:
- pre-commit run -a
- npm install -g expo-cli --loglevel=error
- npm install --log-level=error
- echo "fakeSecret" >> secrets.js
- npm run lint
- npm run supercheck-travis
- npm test
56 changes: 24 additions & 32 deletions __tests__/custom-marker.test.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,60 @@
import CustomMarker from "../src/components/map-overlays/custom-marker.component";
import { Buildings } from "../src/constants/buildings.data";
import { BuildingId } from "../src/types/main";
import renderer from "react-test-renderer";
import React from "react";
import { shallow } from "enzyme";
import { BUILDING_MARKER_COLOR, CONCORDIA_RED } from "../src/constants/style";
import { POIInfo } from "../src/constants/poi.data";
import { BUILDING_MARKER_COLOR } from "../src/constants/style";

describe("CustomMarker component", () => {
const buildingH = Buildings[0];
const H = BuildingId[BuildingId.H];

it("should match snapshot", () => {
const tree = renderer.create(<CustomMarker />).toJSON();
const building = Buildings[0];
const tree = renderer
.create(
<CustomMarker
location={building.location}
markerType={"building"}
text={"asdf"}
onPress={null}
/>
)
.toJSON();
expect(tree).toMatchSnapshot();
});

it("should run provided function on press", () => {
const mockOnPress = jest.fn();
const building = Buildings[0];
const wrapper = shallow(
<CustomMarker
location={buildingH.location}
markerType={"building"}
text={H}
location={building.location}
markerType={"poi"}
text={"asdf"}
onPress={mockOnPress}
testID={"marker" + H}
/>
);
const marker = wrapper.find({ testID: "marker" + H });
const marker = wrapper.find({ testID: "marker" });
marker.simulate("press");
expect(mockOnPress).toHaveBeenCalledTimes(1);
});

it("should be black if it is a building marker", () => {
const building = Buildings[0];
const wrapper = shallow(
<CustomMarker
location={buildingH.location}
location={building.location}
markerType={"building"}
text={H}
text={"asdf"}
onPress={() => {}}
testID={"marker" + H}
/>
);

const bubble = wrapper.find({ testID: "marker" + H + "Bubble" }).props();
const bubble = wrapper
.find({ testID: "bubble" })
.at(0)
.props();
expect(bubble).toHaveProperty(
["style", "backgroundColor"],
BUILDING_MARKER_COLOR
);
});

it("should be red if it is a poi marker", () => {
const H801 = POIInfo[9];
const wrapper = shallow(
<CustomMarker
location={buildingH.location}
markerType={"poi"}
text={H801.displayName}
onPress={() => {}}
testID={"poi" + H801.id}
/>
);

const bubble = wrapper.find({ testID: "poi" + H801.id + "Bubble" }).props();
expect(bubble).toHaveProperty(["style", "backgroundColor"], CONCORDIA_RED);
});
});
2 changes: 1 addition & 1 deletion e2e/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"setupFilesAfterEnv": ["./init.js"],
"setupFilesAfterEnv": ["./init.ts"],
"testEnvironment": "node",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
Expand Down
8 changes: 4 additions & 4 deletions e2e/init.js → e2e/init.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const detox = require("detox");
import { cleanup, init } from 'detox';
const adapter = require('detox/runners/jest/adapter')
const config = require("../package.json").detox;
const adapter = require("detox/runners/jest/adapter");
const specReporter = require("detox/runners/jest/specReporter");

// Set the default timeout
Expand All @@ -13,7 +13,7 @@ jasmine.getEnv().addReporter(adapter);
jasmine.getEnv().addReporter(specReporter);

beforeAll(async () => {
await detox.init(config, { launchApp: false });
await init(config, { launchApp: false });
await device.launchApp({
permissions: {
location: "always"
Expand All @@ -27,5 +27,5 @@ beforeEach(async () => {

afterAll(async () => {
await adapter.afterAll();
await detox.cleanup();
await cleanup();
});
2 changes: 1 addition & 1 deletion e2e/campus-toggle.spec.js → e2e/user-story-1.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ beforeAll(async () => {
await reloadApp();
});

describe("CampusToggle: Toggling between campuses", () => {
describe("US-1: Campus Toggle", () => {
it("should show the campus toggles", async () => {
await expect(element(by.id("SGWButton"))).toBeVisible();
await expect(element(by.id("loyolaButton"))).toBeVisible();
Expand Down
39 changes: 39 additions & 0 deletions e2e/user-story-4.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const { reloadApp } = require("detox-expo-helpers");
import { by, device, expect, element, waitFor } from 'detox';

beforeAll(async () => {
await reloadApp();
});

describe("US-4: Additional campus building information", () => {
it("should show minimal building information", async () => {
// await element(by.id("mapView")).pinchWithAngle("outward", "slow", 0);
// await console.log("pinched and zoomed into mapView");

// await element(by.id("mapView")).swipe("down", "slow", 0.70);
// await console.log("swiped down");
// await element(by.id("mapView")).swipe("right", "slow", 0.50);
// await console.log("swiped right");

await element(by.id("mapView")).tapAtPoint({ x: 154, y: 308 });
await waitFor(element(by.id("panel"))).toExist().withTimeout(2000);

await expect(element(by.id("panelDisplayName"))).toBeVisible();
await expect(element(by.id("panelAddress"))).toBeVisible();

await element(by.id("panelCloseButton")).tap();
});

it("should show extensive building information", async () => {
await element(by.id("mapView")).tapAtPoint({ x: 154, y: 308 });
await waitFor(element(by.id("panel"))).toExist().withTimeout(2000);

await element(by.id("panelDisplayName")).swipe("up", "fast", 0.50);
await expect(element(by.id("scrollDepartments"))).toBeVisible();
await element(by.id("scrollDepartments")).swipe("up", "fast", 0.50);
await expect(element(by.id("scrollServices"))).toBeVisible();
await element(by.id("panelDisplayName")).swipe("down", "fast", 0.50);

await element(by.id("panelCloseButton")).tap();
});
});
Loading

0 comments on commit 1b33045

Please sign in to comment.