Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dataTest(filePath, expectedJSON, expectedJSONPath) {
- var app = request(targetUrl);
- describe('Comparando ' + path.basename(filePath) + ' con ' + path.basename(expectedJSONPath), function() {
- it('Debe coincidir con la respuesta esperada.', function(done) {
- this.timeout(60000);
- var aux = app
- .post(targetConfig.PATH)
- .set('accept', 'application/json')
- .set('content-type', 'application/json')
- .set('host', targetConfig.HOST)
- .send({
- "requestId": "12",
- "invoiceFileName": path.basename(filePath).replace(//+/g, ''),
- "invoiceFileContents": fs.readFileSync(filePath).toString('base64')
- });
- var aws_headers = signRequest(aux);
- aux.set('authorization', aws_headers.headers.Authorization).set('x-amz-date', aws_headers.headers['X-Amz-Date'])
- .expect(expectedJSON)
- .end(function(err, res) {
- if (err) {
- if(expectedJSON === null) {
- try {
- fs.writeFileSync(expectedJSONPath, JSON.stringify(res.body, null, 2));
- console.log('nnAVISO -> GUARDADO NUEVO JSON SIN TESTEAR EN ' + expectedJSONPath + 'n');
- return done();
- }
- catch(err) {
- return done(err);
- }
- }
- else {
- console.error(err);
- return done(err);
- }
- }
- // Success
- done();
- });
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement