Skip to content

closes #389 - Create api/lessons page that returns object of lessons data #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 8, 2020

Conversation

anthonykhoa
Copy link
Collaborator

@anthonykhoa anthonykhoa commented Sep 7, 2020

This page needs to be created, as the API is used in examples in the c0d3 curriculum

This PR will:

  • Create an api/lessons page that returns an object containing the same data the lessons API for version 1 of code returned.
  • Create tests for the api page

@vercel
Copy link

vercel bot commented Sep 7, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/c0d3/c0d3-app/ggpmwfy6z
✅ Preview: https://c0d3-app-git-lessonsapi.c0d3.vercel.app

@codecov
Copy link

codecov bot commented Sep 7, 2020

Codecov Report

Merging #390 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #390   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           81        82    +1     
  Lines         1030      1037    +7     
  Branches       231       231           
=========================================
+ Hits          1030      1037    +7     
Impacted Files Coverage Δ
pages/api/lessons.ts 100.00% <100.00%> (ø)

@anthonykhoa anthonykhoa marked this pull request as ready for review September 7, 2020 19:40
…ns function from graphql/queryResolvers folder upon import
export default async (_: LoggedRequest, res: NextApiResponse) => {
try {
const allLessons = await lessons()
res.status(200)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by default, res.json already has status 200, so unnecessary.

throw new Error('Error occured :(')
})
await lessonsAPI(null, res)
expect(res.json).toBeCalledWith('Error occured :(')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and previous test could be combined


test('should respond with 200 status code when there is no error', async () => {
await lessonsAPI(null, res)
expect(res.status).toBeCalledWith(200)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need

@songz songz merged commit 34f61a6 into master Sep 8, 2020
@ggwadera ggwadera deleted the lessonsapi branch April 10, 2021 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants