test(rebase): adjust tests from rebase and glue them together

This commit is contained in:
Benedikt Rötsch
2017-11-06 12:35:14 +01:00
committed by Benedikt Rötsch
parent 1e271656de
commit f2f2a79670
3 changed files with 18 additions and 20 deletions

View File

@@ -10,7 +10,7 @@
"lint": "eslint ./app.js routes",
"format": "eslint --fix . bin --ignore public node_modules",
"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:integration": "jest test/integration",
"test:integration:watch": "jest test/integration --watch",

View File

@@ -29,17 +29,17 @@ describe('settings', () => {
const status = $('main .status-block.status-block--info')
expect(status.text()).toMatch(/Connected to space “.+”/)
const inputSpaceId = $('#input-space')
expect(inputSpaceId.val()).toBe(process.env.CF_SPACE)
const inputSpaceId = $('#input-space-id')
expect(inputSpaceId.val()).toBe(process.env.CONTENTFUL_SPACE_ID)
const inputCda = $('#input-cda')
expect(inputCda.val()).toBe(process.env.CF_ACCESS_TOKEN)
const inputCda = $('#input-delivery-token')
expect(inputCda.val()).toBe(process.env.CONTENTFUL_DELIVERY_TOKEN)
const inputCpa = $('#input-cpa')
expect(inputCpa.val()).toBe(process.env.CF_PREVIEW_ACCESS_TOKEN)
const inputCpa = $('#input-preview-token')
expect(inputCpa.val()).toBe(process.env.CONTENTFUL_PREVIEW_TOKEN)
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')
}
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')
}
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')
}
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')
}
})
@@ -68,7 +68,7 @@ describe('settings', () => {
const $ = cheerio.load(response.text)
const inputEditorialFeatures = $('#input-editorial-features')
expect(inputEditorialFeaturesponse.prop('checked')).toBeTruthy()
expect(inputEditorialFeatures.prop('checked')).toBeTruthy()
})
})
})

View File

@@ -9,6 +9,12 @@ const contentful = require('../../services/contentful')
const request = {}
const response = {
locals: {
settings: {
space: 'spaceId',
cda: 'cda',
cpa: 'cpa',
editorialFeatures: false
},
currentLocale: {
code: 'en-US'
},
@@ -76,14 +82,6 @@ describe('Lessons', () => {
describe('Settings', () => {
test('It should render settings', async () => {
response.locals = {
settings: {
space: 'spaceId',
cda: 'cda',
cpa: 'cpa',
editorialFeatures: false
}
}
await getSettings(request, response)
expect(response.render.mock.calls[0][0]).toBe('settings')
expect(response.render.mock.calls[0][1].title).toBe('Settings')