From 7fab5e7fd050777d47582a8c02a6d40d826385ef Mon Sep 17 00:00:00 2001 From: "Nicholas Carrigan (he/him)" Date: Fri, 12 Mar 2021 08:39:21 -0800 Subject: [PATCH] Remove tests from boilerplate (#14) * Remove tests from boilerplate Signed-off-by: nhcarrigan * fix: Comment out NODE_ENV Signed-off-by: nhcarrigan --- controllers/convertHandler.js | 8 --- routes/api.js | 20 ------ sample.env | 2 +- tests/1_unit-tests.js | 118 ---------------------------------- tests/2_functional-tests.js | 50 -------------- 5 files changed, 1 insertion(+), 197 deletions(-) diff --git a/controllers/convertHandler.js b/controllers/convertHandler.js index 18a0621..90273d2 100644 --- a/controllers/convertHandler.js +++ b/controllers/convertHandler.js @@ -1,11 +1,3 @@ -/* -* -* -* Complete the handler logic below -* -* -*/ - function ConvertHandler() { this.getNum = function(input) { diff --git a/routes/api.js b/routes/api.js index fddbad9..f488327 100644 --- a/routes/api.js +++ b/routes/api.js @@ -1,11 +1,3 @@ -/* -* -* -* Complete the API routing below -* -* -*/ - 'use strict'; const expect = require('chai').expect; @@ -15,16 +7,4 @@ module.exports = function (app) { let convertHandler = new ConvertHandler(); - app.route('/api/convert') - .get(function (req, res){ - let input = req.query.input; - let initNum = convertHandler.getNum(input); - let initUnit = convertHandler.getUnit(input); - let returnNum = convertHandler.convert(initNum, initUnit); - let returnUnit = convertHandler.getReturnUnit(initUnit); - let toString = convertHandler.getString(initNum, initUnit, returnNum, returnUnit); - - //res.json - }); - }; diff --git a/sample.env b/sample.env index 1dc96d3..20ead7f 100644 --- a/sample.env +++ b/sample.env @@ -1,2 +1,2 @@ PORT= -NODE_ENV=test +# NODE_ENV=test diff --git a/tests/1_unit-tests.js b/tests/1_unit-tests.js index 2069a2b..903a7cf 100644 --- a/tests/1_unit-tests.js +++ b/tests/1_unit-tests.js @@ -1,11 +1,3 @@ -/* -* -* -* FILL IN EACH UNIT TEST BELOW COMPLETELY -* -----[Keep the tests in the same order!]---- -* (if additional are added, keep them at the very end!) -*/ - const chai = require('chai'); let assert = chai.assert; const ConvertHandler = require('../controllers/convertHandler.js'); @@ -13,115 +5,5 @@ const ConvertHandler = require('../controllers/convertHandler.js'); let convertHandler = new ConvertHandler(); suite('Unit Tests', function(){ - - suite('Function convertHandler.getNum(input)', function() { - - test('Whole number input', function(done) { - let input = '32L'; - assert.equal(convertHandler.getNum(input),32); - done(); - }); - - test('Decimal Input', function(done) { - - //done(); - }); - - test('Fractional Input', function(done) { - - //done(); - }); - - test('Fractional Input w/ Decimal', function(done) { - - //done(); - }); - - test('Invalid Input (double fraction)', function(done) { - - //done(); - }); - - test('No Numerical Input', function(done) { - - //done(); - }); - - }); - - suite('Function convertHandler.getUnit(input)', function() { - - test('For Each Valid Unit Inputs', function(done) { - let input = ['gal','l','mi','km','lbs','kg','GAL','L','MI','KM','LBS','KG']; - input.forEach(function(ele) { - //assert - }); - done(); - }); - - test('Unknown Unit Input', function(done) { - - //done(); - }); - - }); - - suite('Function convertHandler.getReturnUnit(initUnit)', function() { - - test('For Each Valid Unit Inputs', function(done) { - let input = ['gal','l','mi','km','lbs','kg']; - let expect = ['L','gal','km','mi','kg','lbs']; - input.forEach(function(ele, i) { - assert.equal(convertHandler.getReturnUnit(ele), expect[i]); - }); - done(); - }); - - }); - - suite('Function convertHandler.spellOutUnit(unit)', function() { - - test('For Each Valid Unit Inputs', function(done) { - //see above example for hint - done(); - }); - - }); - - suite('Function convertHandler.convert(num, unit)', function() { - - test('Gal to L', function(done) { - let input = [5, 'gal']; - let expected = 18.9271; - assert.approximately(convertHandler.convert(input[0],input[1]),expected,0.1); //0.1 tolerance - done(); - }); - - test('L to Gal', function(done) { - - //done(); - }); - - test('Mi to Km', function(done) { - - //done(); - }); - - test('Km to Mi', function(done) { - - //done(); - }); - - test('Lbs to Kg', function(done) { - - //done(); - }); - - test('Kg to Lbs', function(done) { - - //done(); - }); - - }); }); \ No newline at end of file diff --git a/tests/2_functional-tests.js b/tests/2_functional-tests.js index 476ff29..a318397 100644 --- a/tests/2_functional-tests.js +++ b/tests/2_functional-tests.js @@ -1,11 +1,3 @@ -/* -* -* -* FILL IN EACH FUNCTIONAL TEST BELOW COMPLETELY -* -----[Keep the tests in the same order!]----- -* (if additional are added, keep them at the very end!) -*/ - const chaiHttp = require('chai-http'); const chai = require('chai'); let assert = chai.assert; @@ -15,46 +7,4 @@ 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(); - }); - - }); - - }); - });