metric-imperial-converter/tests/2_functional-tests.js
2017-02-18 19:14:10 +00:00

61 lines
1.4 KiB
JavaScript

/*
*
*
* FILL IN EACH FUNCTIONAL TEST BELOW COMPLETELY
* -----[Keep the tests in the same order!]-----
* (if additional are added, keep them at the very end!)
*/
var chaiHttp = require('chai-http');
var chai = require('chai');
var assert = chai.assert;
var server = require('../server');
chai.use(chaiHttp);
suite('Functional Tests', function() {
suite('Routing Tests', function() {
suite('GET /api/convert => conversion object', function() {
test('Convert 10L (valid input)', function(done) {
chai.request(server)
.get('/api/convert')
.query({input: '10L'})
.end(function(err, res){
assert.equal(res.status, 200);
assert.equal(res.body.initNum, 10);
assert.equal(res.body.initUnit, 'L');
assert.approximately(res.body.returnNum, 2.64172, 0.1);
assert.equal(res.body.returnUnit, 'gal');
done();
});
});
test('Convert 32g (invalid input unit)', function(done) {
//done();
});
test('Convert 3/7.2/4kg (invalid number)', function(done) {
//done();
});
test('Convert 3/7.2/4kilomegagram (invalid number and unit)', function(done) {
//done();
});
test('Convert kg (no number)', function(done) {
//done();
});
});
});
});