Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
"devDependencies": {
"chai": "4.1.2",
"coffeescript": "1.12.7",
"mocha": "5.0.4"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion scripts/bdd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
./node_modules/mocha/bin/mocha -w --reporter spec --compilers=coffee:coffeescript/register ./test/**/*-test.coffee
./node_modules/mocha/bin/mocha -w --reporter spec ./test/**/*-test.js
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
./node_modules/mocha/bin/mocha --reporter spec --compilers=coffee:coffeescript/register ./test/**/*-test.coffee
./node_modules/mocha/bin/mocha --reporter spec ./test/**/*-test.js
93 changes: 0 additions & 93 deletions test/integration/cli-test.coffee

This file was deleted.

101 changes: 101 additions & 0 deletions test/integration/cli-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
const fs = require('fs');
const { assert } = require('chai');
const { exec } = require('child_process');

const cmdPrefix = '';

describe('Command line', () => {
describe('parsing from standard input with --raw', () => {
let stdout = '';
let stderr = '';
let exitStatus = '';

before((done) => {
const cmd = 'cat ./test/fixtures/get/tracefile | ' +
'./bin/curl-trace-parser --raw';

const cli = exec(cmdPrefix + cmd, (error, out, err) => {
stdout = out;
stderr = err;
if (error) {
exitStatus = error.status;
}
done();
});

cli.on('exit', (code) => { exitStatus = code; });
});

it('should not return nothing to stderr', () => assert.equal(stderr, ''));

it('should return with exit code 0', () => assert.equal(exitStatus, 0));

it('should return parsed body to standard output', (done) => {
const expectedOutputPath = './test/fixtures/get/expected-output';
fs.readFile(expectedOutputPath, 'utf8', (err, expected) => {
assert.equal(stdout, expected);
done();
});
});
});

describe('parsing from standard input with --blueprint option', () => {
let stdout = '';
let stderr = '';
let exitStatus = '';

before((done) => {
const cmd = 'cat ./test/fixtures/post/tracefile | ' +
'./bin/curl-trace-parser --blueprint';

const cli = exec(cmdPrefix + cmd, (error, out, err) => {
stdout = out;
stderr = err;
if (error) {
exitStatus = error.status;
}
done();
});

cli.on('exit', (code) => { exitStatus = code; });
});

it('should not return nothing to stderr', () => assert.equal(stderr, ''));

it('should return with exit code 0', () => assert.equal(exitStatus, 0));

it('should return parsed body in API Blueprint format to standard output', (done) => {
const expectedOutputPath = './test/fixtures/post/expected-output.md';
fs.readFile(expectedOutputPath, 'utf8', (err, expected) => {
assert.equal(stdout, expected);
done();
});
});
});

describe('no input on stdin and no options', () => {
let stderr = '';
let exitStatus = '';

before((done) => {
const cmd = './bin/curl-trace-parser';
const cli = exec(cmdPrefix + cmd, (error, out, err) => {
stderr = err;
if (error) {
exitStatus = error.code;
}
});


cli.on('exit', (code) => {
exitStatus = code;
done();
});
});


it('should exit with status 1', () => assert.equal(exitStatus, 1));

it('should return error message to stderr', () => assert.include(stderr, 'No input on stdin'));
});
});
18 changes: 0 additions & 18 deletions test/integration/js-api-test.coffee

This file was deleted.

20 changes: 20 additions & 0 deletions test/integration/js-api-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require('fs');

const { assert } = require('chai');
const parser = require('../../lib/parser');

describe('Javascript API', () =>
describe('parsing from file', () =>

it('should return expected raw HTTP in format described in Readme', (done) => {
const traceFilePath = './test/fixtures/get/tracefile';
const expectedOutputPath = './test/fixtures/get/expected-output';

fs.readFile(traceFilePath, 'utf8', (err, trace) => {
const parsed = parser.parseToString(trace);
fs.readFile(expectedOutputPath, 'utf8', (error, expected) => {
assert.equal(parsed, expected);
done();
});
});
})));
Loading