-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from BenjaminWatts/issue-27
Issue 27
- Loading branch information
Showing
54 changed files
with
25,058 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Jest Tests | ||
|
||
on: [push] # Trigger the workflow on every push to the repository | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest # You can choose a different OS if needed | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 # Checkout your code repository | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 21.1.0 # You can specify your desired Node.js version here | ||
|
||
- name: Install dependencies | ||
run: yarn | ||
|
||
- name: Run Jest unit tests | ||
run: yarn test | ||
|
||
- name: Run Jest e2e tests | ||
run: yarn run e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`atoms/maps/UnitGroupMap can render 1`] = `undefined`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { render, screen, fireEvent } from "@testing-library/react-native"; | ||
import * as c from "./cards"; | ||
import { urls } from "../services/nav"; | ||
|
||
const mockLinkingOpenURL = jest.fn(); | ||
jest.mock("react-native/Libraries/Linking/Linking", () => ({ | ||
openURL: mockLinkingOpenURL, | ||
})); | ||
|
||
let mockLondonTime = jest.fn(); | ||
jest.mock("../common/utils", () => ({ | ||
londonTime: (x: any) => mockLondonTime(x), | ||
})); | ||
|
||
describe("atoms/cards/IncompleteUnknownCategories", () => { | ||
beforeEach(() => { | ||
render(<c.IncompleteUnknownCategories />); | ||
mockLinkingOpenURL.mockClear(); | ||
}); | ||
|
||
test("renders text", () => { | ||
screen.getByText("Help us!"); | ||
screen.getByText( | ||
"This open-source app is incomplete. We need help to categorise the hundreds of individual balancing mechnism units into the right categories, giving them human readable names and plotting them on the map." | ||
); | ||
screen.getByText( | ||
"All the Unknown values represents balancing mechanism units we haven't yet categorised. We need open-source contributions to complete this work." | ||
); | ||
screen.getByText( | ||
"Please help us by contributing to the project on GitHub." | ||
); | ||
}); | ||
|
||
test("github link", () => { | ||
const githubButton = screen.getByTestId("github-repo-link"); | ||
fireEvent.press(githubButton); | ||
expect(mockLinkingOpenURL).toBeCalledWith(urls.githubRepo); | ||
}); | ||
}); | ||
|
||
describe("atoms/cards/UnknownUnitGroupCode", () => { | ||
beforeEach(() => { | ||
render(<c.UnknownUnitGroupCode />); | ||
}); | ||
|
||
test("renders text", () => { | ||
screen.getByText("Error"); | ||
screen.getByText( | ||
"Cannot find details for this generator. Please check the URL and try again." | ||
); | ||
}); | ||
}); | ||
|
||
describe("atoms/cards/MissingScreen", () => { | ||
beforeEach(() => { | ||
mockLinkingOpenURL.mockClear(); | ||
render(<c.MissingScreen />); | ||
}); | ||
|
||
test("renders expected text", () => { | ||
screen.getByText("Error"); | ||
screen.getByText("This screen does not exist."); | ||
}); | ||
|
||
test("can click on home link", () => { | ||
const homeButton = screen.getByText("Reset to Home screen"); | ||
fireEvent.press(homeButton); | ||
expect(mockLinkingOpenURL).toBeCalledWith(urls.home); | ||
}); | ||
}); | ||
|
||
describe("atoms/cards/UnitListHeader", () => { | ||
|
||
test("renders loading text with undefined now prop", () => { | ||
render(<c.UnitListHeader />); | ||
screen.getByText("Loading data for individual units"); | ||
}); | ||
|
||
test("renders live individual unit output and local time if now prop is a Date ", () => { | ||
const now = new Date(Date.parse("2023-01-01")); | ||
mockLondonTime.mockReturnValue("NOW"); | ||
render(<c.UnitListHeader now={now} />); | ||
expect(mockLondonTime).toBeCalledWith(now); | ||
screen.getByText("Live individual unit output at NOW"); | ||
}); | ||
|
||
afterAll(() => { | ||
mockLondonTime.mockRestore(); | ||
}); | ||
}); | ||
|
||
|
||
describe("atoms/cards/UnitGroupScheduleHeader", () => { | ||
|
||
test('renders bmUnit code', () => { | ||
render(<c.UnitGroupScheduleHeader bmUnit="BMU1" />); | ||
screen.getByText("BMU1"); | ||
}) | ||
|
||
test('renders Upcoming Schedule', () => { | ||
render(<c.UnitGroupScheduleHeader bmUnit="BMU1" />); | ||
screen.getByText("Upcoming Schedule"); | ||
}) | ||
|
||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.