gatsby-source-nytimes-books-api
Version:
This [GatsyJS](https://gatsbyjs.org) source plugin fetches data from the [NYTimes Books API](https://developer.nytimes.com/docs/books-product/1/overview)
20 lines (16 loc) • 558 B
JavaScript
const getResults = require("../utils/getResults")
describe("getResults", () => {
test("returns response data from resp.data.results path", () => {
const results = "🥳"
const resp = { data: { results } }
expect(getResults(resp)).toBe(results)
})
test("returns FALSY if data is not set", () => {
const resp = { notData: "🚫" }
expect(getResults(resp)).toBeFalsy()
})
test("returns FALSY if data.results is not set", () => {
const resp = { data: { notResults: "🚫" } }
expect(getResults(resp)).toBeFalsy()
})
})