Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
revert some accidential changes to the tests
  • Loading branch information
axe312ger committed Mar 29, 2021
commit 8f8651f4713e657f9563c59bfdb2de6e10323cd6
4 changes: 2 additions & 2 deletions packages/gatsby-source-contentful/src/__tests__/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ describe(`Displays troubleshooting tips and detailed plugin options on contentfu
it(`API 404 response handling`, async () => {
mockClient.getLocales.mockImplementation(() => {
const err = new Error(`error`)
err.status = 404
err.responseData = { status: 404 }
throw err
})

Expand Down Expand Up @@ -295,7 +295,7 @@ describe(`Displays troubleshooting tips and detailed plugin options on contentfu
it(`API authorization error handling`, async () => {
mockClient.getLocales.mockImplementation(() => {
const err = new Error(`error`)
err.status = 401
err.responseData = { status: 401 }
throw err
})

Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby-source-contentful/src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ module.exports = async function contentfulFetch({
sourceMessage: `We couldn't make a secure connection to your contentful space. Please check if you have any self-signed SSL certificates installed.`,
},
})
} else if (e.status) {
if (e.status === 404) {
} else if (e.responseData) {
if (e.responseData.status === 404) {
// host and space used to generate url
details = `Endpoint not found. Check if ${chalk.yellow(
`host`
Expand All @@ -169,7 +169,7 @@ module.exports = async function contentfulFetch({
host: `Check if setting is correct`,
spaceId: `Check if setting is correct`,
}
} else if (e.status === 401) {
} else if (e.responseData.status === 401) {
// authorization error
details = `Authorization error. Check if ${chalk.yellow(
`accessToken`
Expand Down