test(rebase): adjust tests from rebase and glue them together
This commit is contained in:
committed by
Benedikt Rötsch
parent
1e271656de
commit
f2f2a79670
@@ -10,7 +10,7 @@
|
|||||||
"lint": "eslint ./app.js routes",
|
"lint": "eslint ./app.js routes",
|
||||||
"format": "eslint --fix . bin --ignore public node_modules",
|
"format": "eslint --fix . bin --ignore public node_modules",
|
||||||
"pretest": "npm run lint",
|
"pretest": "npm run lint",
|
||||||
"test": "npm run test:e2e",
|
"test": "npm run test:unit && npm run test:integration && npm run test:e2e",
|
||||||
"test:e2e": "node test/e2e/run-e2e-test.js",
|
"test:e2e": "node test/e2e/run-e2e-test.js",
|
||||||
"test:integration": "jest test/integration",
|
"test:integration": "jest test/integration",
|
||||||
"test:integration:watch": "jest test/integration --watch",
|
"test:integration:watch": "jest test/integration --watch",
|
||||||
|
|||||||
@@ -29,17 +29,17 @@ describe('settings', () => {
|
|||||||
const status = $('main .status-block.status-block--info')
|
const status = $('main .status-block.status-block--info')
|
||||||
expect(status.text()).toMatch(/Connected to space “.+”/)
|
expect(status.text()).toMatch(/Connected to space “.+”/)
|
||||||
|
|
||||||
const inputSpaceId = $('#input-space')
|
const inputSpaceId = $('#input-space-id')
|
||||||
expect(inputSpaceId.val()).toBe(process.env.CF_SPACE)
|
expect(inputSpaceId.val()).toBe(process.env.CONTENTFUL_SPACE_ID)
|
||||||
|
|
||||||
const inputCda = $('#input-cda')
|
const inputCda = $('#input-delivery-token')
|
||||||
expect(inputCda.val()).toBe(process.env.CF_ACCESS_TOKEN)
|
expect(inputCda.val()).toBe(process.env.CONTENTFUL_DELIVERY_TOKEN)
|
||||||
|
|
||||||
const inputCpa = $('#input-cpa')
|
const inputCpa = $('#input-preview-token')
|
||||||
expect(inputCpa.val()).toBe(process.env.CF_PREVIEW_ACCESS_TOKEN)
|
expect(inputCpa.val()).toBe(process.env.CONTENTFUL_PREVIEW_TOKEN)
|
||||||
|
|
||||||
const inputEditorialFeatures = $('#input-editorial-features')
|
const inputEditorialFeatures = $('#input-editorial-features')
|
||||||
expect(inputEditorialFeaturesponse.prop('checked')).toBeFalsy()
|
expect(inputEditorialFeatures.prop('checked')).toBeFalsy()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -52,15 +52,15 @@ describe('settings', () => {
|
|||||||
throw new Error('Did not set cookie value for editorial features')
|
throw new Error('Did not set cookie value for editorial features')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cookie.space !== process.env.CF_SPACE) {
|
if (cookie.spaceId !== process.env.CONTENTFUL_SPACE_ID) {
|
||||||
throw new Error('Did not set correct cookie value for SpaceID')
|
throw new Error('Did not set correct cookie value for SpaceID')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cookie.cda !== process.env.CF_ACCESS_TOKEN) {
|
if (cookie.deliveryToken !== process.env.CONTENTFUL_DELIVERY_TOKEN) {
|
||||||
throw new Error('Did not set correct cookie value for CDA access token')
|
throw new Error('Did not set correct cookie value for CDA access token')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cookie.cpa !== process.env.CF_PREVIEW_ACCESS_TOKEN) {
|
if (cookie.previewToken !== process.env.CONTENTFUL_PREVIEW_TOKEN) {
|
||||||
throw new Error('Did not set correct cookie value for CPA access token')
|
throw new Error('Did not set correct cookie value for CPA access token')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -68,7 +68,7 @@ describe('settings', () => {
|
|||||||
const $ = cheerio.load(response.text)
|
const $ = cheerio.load(response.text)
|
||||||
|
|
||||||
const inputEditorialFeatures = $('#input-editorial-features')
|
const inputEditorialFeatures = $('#input-editorial-features')
|
||||||
expect(inputEditorialFeaturesponse.prop('checked')).toBeTruthy()
|
expect(inputEditorialFeatures.prop('checked')).toBeTruthy()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ const contentful = require('../../services/contentful')
|
|||||||
const request = {}
|
const request = {}
|
||||||
const response = {
|
const response = {
|
||||||
locals: {
|
locals: {
|
||||||
|
settings: {
|
||||||
|
space: 'spaceId',
|
||||||
|
cda: 'cda',
|
||||||
|
cpa: 'cpa',
|
||||||
|
editorialFeatures: false
|
||||||
|
},
|
||||||
currentLocale: {
|
currentLocale: {
|
||||||
code: 'en-US'
|
code: 'en-US'
|
||||||
},
|
},
|
||||||
@@ -76,14 +82,6 @@ describe('Lessons', () => {
|
|||||||
|
|
||||||
describe('Settings', () => {
|
describe('Settings', () => {
|
||||||
test('It should render settings', async () => {
|
test('It should render settings', async () => {
|
||||||
response.locals = {
|
|
||||||
settings: {
|
|
||||||
space: 'spaceId',
|
|
||||||
cda: 'cda',
|
|
||||||
cpa: 'cpa',
|
|
||||||
editorialFeatures: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await getSettings(request, response)
|
await getSettings(request, response)
|
||||||
expect(response.render.mock.calls[0][0]).toBe('settings')
|
expect(response.render.mock.calls[0][0]).toBe('settings')
|
||||||
expect(response.render.mock.calls[0][1].title).toBe('Settings')
|
expect(response.render.mock.calls[0][1].title).toBe('Settings')
|
||||||
|
|||||||
Reference in New Issue
Block a user