From f2f2a79670f0dccbb79e054f8022128b31b8e43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20R=C3=B6tsch?= Date: Mon, 6 Nov 2017 12:35:14 +0100 Subject: [PATCH] test(rebase): adjust tests from rebase and glue them together --- package.json | 2 +- test/integration/settings.test.js | 22 +++++++++++----------- test/unit/index.test.js | 14 ++++++-------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index dc0c988..08a0e06 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/integration/settings.test.js b/test/integration/settings.test.js index da644f8..e55b7d2 100644 --- a/test/integration/settings.test.js +++ b/test/integration/settings.test.js @@ -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() }) }) }) diff --git a/test/unit/index.test.js b/test/unit/index.test.js index 54e8b1c..1d44508 100644 --- a/test/unit/index.test.js +++ b/test/unit/index.test.js @@ -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')