Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
Update timetable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shu8 committed Jan 4, 2022
1 parent 4b5018f commit 07d34e2
Show file tree
Hide file tree
Showing 4 changed files with 534 additions and 0 deletions.
Expand Up @@ -65,4 +65,9 @@ describe(`TimetableDetailScreen`, () => {
wrapper = await render(<TimetableDetailScreen {...mockProps} />)
expect(wrapper).toMatchSnapshot()
})

it(`renders the TimetableDetailScreen with no entries`, async () => {
wrapper = await render(<TimetableDetailScreen {...mockProps} timetable={[]} />)
expect(wrapper).toMatchSnapshot()
})
})
@@ -1,3 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`TimetableDetailScreen renders the TimetableDetailScreen 1`] = `"{\\"initialRegion\\":{\\"latitude\\":51.5246586,\\"latitudeDelta\\":0.0012,\\"longitude\\":-0.1339784,\\"longitudeDelta\\":0.0071},\\"date\\":\\"2020-01-01\\",\\"contact\\":\\"Anne Oldman\\",\\"end_time\\":\\"00:01\\",\\"location\\":{\\"address\\":[\\"221C Banana Bread Street\\"],\\"name\\":\\"Waffle House\\"},\\"module\\":{\\"department_name\\":\\"Criminology\\",\\"lecturer\\":{\\"department_id\\":\\"CRIM\\",\\"name\\":\\"Jack Cloth\\"},\\"module_id\\":\\"ABC123\\"},\\"start_time\\":\\"00:00\\",\\"navigation\\":{}}"`;

exports[`TimetableDetailScreen renders the TimetableDetailScreen with no entries 1`] = `"{\\"initialRegion\\":{\\"latitude\\":51.5246586,\\"latitudeDelta\\":0.0012,\\"longitude\\":-0.1339784,\\"longitudeDelta\\":0.0071},\\"date\\":\\"2020-01-01\\",\\"navigation\\":{}}"`;
54 changes: 54 additions & 0 deletions screens/Timetable/TimetableScreen/__tests__/WeekView.test.tsx
@@ -0,0 +1,54 @@
/**
* @jest-environment jsdom
*/
import { cleanup, render } from "@testing-library/react-native"
import MockDate from 'mockdate'
import React from 'react'
import "react-native"
import { LocalisationManager } from "../../../../lib"
import WeekView from "../components/WeekView"

describe(`WeekView`, () => {
MockDate.set(`2019-11-18T08:47:21.000Z`)

afterEach(() => {
cleanup()
})

it(`renders the WeekView component`, () => {
const mockProps = {
date: LocalisationManager.getMoment().subtract(7, `days`),
isLoading: false,
navigation: {
dispatch: jest.fn(),
navigate: jest.fn(),
} as any,
onDateChanged: () => null,
onIndexChanged: () => null,
onRefresh: () => null,
timetable: [
{
contact: `Anne Oldman`,
end_time: `00:01`,
location: {
address: [
`221C Banana Bread Street`,
],
name: `Waffle House`,
},
module: {
department_name: `Criminology`,
lecturer: {
department_id: `CRIM`,
name: `Jack Cloth`,
},
module_id: `ABC123`,
},
start_time: `00:00`,
},
],
}
const wrapper = render(<WeekView {...mockProps} />)
expect(wrapper).toMatchSnapshot()
})
})

0 comments on commit 07d34e2

Please sign in to comment.