-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Nick Colley <nick.colley@digital.cabinet-office.gov.uk>
- Loading branch information
1 parent
399dd8e
commit fb8a221
Showing
2 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* eslint-env jest */ | ||
const request = require('supertest') | ||
const app = require('../../server.js') | ||
const path = require('path') | ||
const fs = require('fs') | ||
const utils = require('../../lib/utils.js') | ||
|
||
jest.setTimeout(30000) | ||
|
||
function readFile (pathFromRoot) { | ||
return fs.readFileSync(path.join(__dirname, '../../' + pathFromRoot), 'utf8') | ||
} | ||
/** | ||
* | ||
*/ | ||
describe('The data storage', () => { | ||
// check session-data defaults file exists | ||
|
||
it.skip('file should exist', (done) => { | ||
const sessionDataDefaultsFile = readFile('app/data/session-data-defaults.js') | ||
|
||
request(app) | ||
.get(sessionDataDefaultsFile) | ||
.expect('Content-Type', /application\/javascript; charset=UTF-8/) | ||
// .expect(200) | ||
.end(function (err, res) { | ||
if (err) { | ||
done(err) | ||
} else { | ||
done() | ||
} | ||
}) | ||
}) | ||
|
||
describe('storeData function', () => { | ||
it('should add input data into session data', async () => { | ||
let initialSessionData = { | ||
'driver-name': 'Dr Emmett Brown' | ||
} | ||
|
||
const inputData = { | ||
'vehicle-registration': 'OUTATIME' | ||
} | ||
|
||
utils.storeData(inputData, initialSessionData) | ||
|
||
expect(initialSessionData).toEqual({ | ||
'driver-name': 'Dr Emmett Brown', | ||
'vehicle-registration': 'OUTATIME' | ||
}) | ||
}) | ||
|
||
it('should merge object into object', async () => { | ||
let initialSessionData = { | ||
vehicle: { | ||
'driver-name': 'Dr Emmett Brown' | ||
} | ||
} | ||
|
||
const inputData = { | ||
vehicle: { | ||
registration: 'OUTATIME' | ||
} | ||
} | ||
|
||
utils.storeData(inputData, initialSessionData) | ||
|
||
expect(initialSessionData).toEqual({ | ||
vehicle: { | ||
'driver-name': 'Dr Emmett Brown', | ||
registration: 'OUTATIME' | ||
} | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters