Skip to content

Commit

Permalink
Merge branch 'master' into db/prisma
Browse files Browse the repository at this point in the history
  • Loading branch information
ggwadera committed Mar 24, 2021
2 parents 542be21 + 8216416 commit daa76a0
Show file tree
Hide file tree
Showing 58 changed files with 485 additions and 983 deletions.
22 changes: 22 additions & 0 deletions __tests__/pages/404.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import {
render,
waitFor,
waitForElementToBeRemoved
} from '@testing-library/react'
import { MockedProvider } from '@apollo/client/testing'
import NotFound from '../../pages/404'

describe('404 Error Page', () => {
it('should render', async () => {
const { container, queryByRole } = render(
<MockedProvider>
<NotFound />
</MockedProvider>
)
await waitForElementToBeRemoved(() =>
queryByRole('heading', { name: /loading/i })
)
await waitFor(() => expect(container).toMatchSnapshot())
})
})
22 changes: 22 additions & 0 deletions __tests__/pages/500.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import {
render,
waitFor,
waitForElementToBeRemoved
} from '@testing-library/react'
import { MockedProvider } from '@apollo/client/testing'
import InternalServerError from '../../pages/500'

describe('500 Error Page', () => {
it('should render', async () => {
const { container, queryByRole } = render(
<MockedProvider>
<InternalServerError />
</MockedProvider>
)
await waitForElementToBeRemoved(() =>
queryByRole('heading', { name: /loading/i })
)
await waitFor(() => expect(container).toMatchSnapshot())
})
})
149 changes: 149 additions & 0 deletions __tests__/pages/__snapshots__/404.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`404 Error Page should render 1`] = `
<div>
<nav
class="navbar navbar-expand-lg navbar-light justify-content-between bg-white"
>
<div
class="container"
>
<a
class="navbar-brand text-primary font-weight-bold"
href="/"
>
C0D3
</a>
<div
id="navbarNav"
>
<div
class="navbar-nav collapse navbar-collapse"
>
<div
class="navbar-nav collapse navbar-collapse"
>
<a
class="nav-item nav-link"
href="/curriculum"
>
Curriculum
</a>
<a
class="nav-item nav-link"
href="https://github.com/garageScript/c0d3-app"
rel="noopener noreferrer"
target="_blank"
>
Repo
</a>
<a
class="nav-item nav-link"
href="https://www.notion.so/Table-of-Contents-a83980f81560429faca3821a9af8a5e2"
rel="noopener noreferrer"
target="_blank"
>
Journey
</a>
<a
class="nav-item nav-link"
href="https://chat.c0d3.com"
rel="noopener noreferrer"
target="_blank"
>
Help
</a>
<a
class="nav-item nav-link"
href="/contributors"
>
Contributors
</a>
</div>
</div>
</div>
<div>
<a
class="btn btn-secondary border mr-3"
href="/login"
>
Login
</a>
<a
class="btn btn-secondary border mr-3"
href="/signup"
>
Signup
</a>
</div>
</div>
</nav>
<div
class="container"
>
<div
class="container"
>
<div
class="row"
>
<div
class="d-flex col-sm-3 align-items-center justify-content-center"
>
<div
class="text-center mt-3"
>
<div
style="color: rgb(41, 41, 41); font-size: 1.5rem;"
>
<strong>
Page not found
</strong>
</div>
<div
style="color: rgb(41, 41, 41); font-size: 1rem;"
>
Page not found
</div>
<a
class="btn btn-primary py-3 px-5 mt-3"
href="/"
>
<h3
class="font-weight-bold"
>
Back
</h3>
</a>
</div>
</div>
<div
class="mb-3 col-sm-9"
>
<div
style="display: block; overflow: hidden; position: relative; box-sizing: border-box; margin: 0px;"
>
<div
style="display: block; box-sizing: border-box; padding-top: 100%;"
/>
<img
decoding="async"
sizes="100vw"
src="/_next/image?url=%2Fassets%2Ferrors%2F404.svg&w=3840&q=75"
srcset="/_next/image?url=%2Fassets%2Ferrors%2F404.svg&w=640&q=75 640w, /_next/image?url=%2Fassets%2Ferrors%2F404.svg&w=750&q=75 750w, /_next/image?url=%2Fassets%2Ferrors%2F404.svg&w=828&q=75 828w, /_next/image?url=%2Fassets%2Ferrors%2F404.svg&w=1080&q=75 1080w, /_next/image?url=%2Fassets%2Ferrors%2F404.svg&w=1200&q=75 1200w, /_next/image?url=%2Fassets%2Ferrors%2F404.svg&w=1920&q=75 1920w, /_next/image?url=%2Fassets%2Ferrors%2F404.svg&w=2048&q=75 2048w, /_next/image?url=%2Fassets%2Ferrors%2F404.svg&w=3840&q=75 3840w"
style="visibility: inherit; position: absolute; top: 0px; left: 0px; bottom: 0px; right: 0px; box-sizing: border-box; padding: 0px; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%; object-fit: contain;"
/>
</div>
</div>
</div>
</div>
</div>
<footer
class="mt-5 font-weight-light text-center pb-5 text-muted"
>
© Copyright 2020 GarageScript
<br />
All Rights Reserved
</footer>
</div>
`;
147 changes: 147 additions & 0 deletions __tests__/pages/__snapshots__/500.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`500 Error Page should render 1`] = `
<div>
<nav
class="navbar navbar-expand-lg navbar-light justify-content-between bg-white"
>
<div
class="container"
>
<a
class="navbar-brand text-primary font-weight-bold"
href="/"
>
C0D3
</a>
<div
id="navbarNav"
>
<div
class="navbar-nav collapse navbar-collapse"
>
<div
class="navbar-nav collapse navbar-collapse"
>
<a
class="nav-item nav-link"
href="/curriculum"
>
Curriculum
</a>
<a
class="nav-item nav-link"
href="https://github.com/garageScript/c0d3-app"
rel="noopener noreferrer"
target="_blank"
>
Repo
</a>
<a
class="nav-item nav-link"
href="https://www.notion.so/Table-of-Contents-a83980f81560429faca3821a9af8a5e2"
rel="noopener noreferrer"
target="_blank"
>
Journey
</a>
<a
class="nav-item nav-link"
href="https://chat.c0d3.com"
rel="noopener noreferrer"
target="_blank"
>
Help
</a>
<a
class="nav-item nav-link"
href="/contributors"
>
Contributors
</a>
</div>
</div>
</div>
<div>
<a
class="btn btn-secondary border mr-3"
href="/login"
>
Login
</a>
<a
class="btn btn-secondary border mr-3"
href="/signup"
>
Signup
</a>
</div>
</div>
</nav>
<div
class="container"
>
<div
class="container"
>
<div
class="row"
>
<div
class="d-flex col-sm-3 align-items-center justify-content-center"
>
<div
class="text-center mt-3"
>
<div
style="color: rgb(41, 41, 41); font-size: 1.5rem;"
>
<strong>
Internal server error
</strong>
</div>
<div
style="color: rgb(41, 41, 41); font-size: 1rem;"
/>
<a
class="btn btn-primary py-3 px-5 mt-3"
href="/"
>
<h3
class="font-weight-bold"
>
Back
</h3>
</a>
</div>
</div>
<div
class="mb-3 col-sm-9"
>
<div
style="display: block; overflow: hidden; position: relative; box-sizing: border-box; margin: 0px;"
>
<div
style="display: block; box-sizing: border-box; padding-top: 100%;"
/>
<img
decoding="async"
sizes="100vw"
src="/_next/image?url=%2Fassets%2Ferrors%2F500.svg&w=3840&q=75"
srcset="/_next/image?url=%2Fassets%2Ferrors%2F500.svg&w=640&q=75 640w, /_next/image?url=%2Fassets%2Ferrors%2F500.svg&w=750&q=75 750w, /_next/image?url=%2Fassets%2Ferrors%2F500.svg&w=828&q=75 828w, /_next/image?url=%2Fassets%2Ferrors%2F500.svg&w=1080&q=75 1080w, /_next/image?url=%2Fassets%2Ferrors%2F500.svg&w=1200&q=75 1200w, /_next/image?url=%2Fassets%2Ferrors%2F500.svg&w=1920&q=75 1920w, /_next/image?url=%2Fassets%2Ferrors%2F500.svg&w=2048&q=75 2048w, /_next/image?url=%2Fassets%2Ferrors%2F500.svg&w=3840&q=75 3840w"
style="visibility: inherit; position: absolute; top: 0px; left: 0px; bottom: 0px; right: 0px; box-sizing: border-box; padding: 0px; margin: auto; display: block; width: 0px; height: 0px; min-width: 100%; max-width: 100%; min-height: 100%; max-height: 100%; object-fit: contain;"
/>
</div>
</div>
</div>
</div>
</div>
<footer
class="mt-5 font-weight-light text-center pb-5 text-muted"
>
© Copyright 2020 GarageScript
<br />
All Rights Reserved
</footer>
</div>
`;
25 changes: 3 additions & 22 deletions __tests__/pages/curriculum.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,11 @@ import { MockedProvider } from '@apollo/client/testing'
import GET_APP from '../../graphql/queries/getApp'
import dummyLessonData from '../../__dummy__/lessonData'
import dummySessionData from '../../__dummy__/sessionData'
import expectLoading from '../utils/expectLoading'

describe('Curriculum Page', () => {
test('Should render Loading Spinner when loading', async () => {
const mocks = [
{
request: { query: GET_APP },
result: {
data: {
lessons: dummyLessonData,
session: dummySessionData,
alerts: []
}
}
}
]

const { findByRole } = render(
<MockedProvider mocks={mocks} addTypename={false}>
<Curriculum />
</MockedProvider>
)

const element = await findByRole('heading', { name: /loading/i })
expect(element).toBeTruthy()
test('Should render Loading Spinner when loading', () => {
expectLoading(<Curriculum />)
})

test('Should render Bad Data when no lessons', async () => {
Expand Down
Loading

0 comments on commit daa76a0

Please sign in to comment.