2017-02-18 20:14:10 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* FILL IN EACH UNIT TEST BELOW COMPLETELY
|
|
|
|
* -----[Keep the tests in the same order!]----
|
|
|
|
* (if additional are added, keep them at the very end!)
|
|
|
|
*/
|
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
const chai = require('chai');
|
|
|
|
let assert = chai.assert;
|
|
|
|
const ConvertHandler = require('../controllers/convertHandler.js');
|
2017-02-18 20:14:10 +01:00
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let convertHandler = new ConvertHandler();
|
2017-02-18 20:14:10 +01:00
|
|
|
|
|
|
|
suite('Unit Tests', function(){
|
|
|
|
|
|
|
|
suite('Function convertHandler.getNum(input)', function() {
|
|
|
|
|
|
|
|
test('Whole number input', function(done) {
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let input = '32L';
|
2017-02-18 20:14:10 +01:00
|
|
|
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) {
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let input = ['gal','l','mi','km','lbs','kg','GAL','L','MI','KM','LBS','KG'];
|
2017-02-18 20:14:10 +01:00
|
|
|
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) {
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let input = ['gal','l','mi','km','lbs','kg'];
|
|
|
|
let expect = ['L','gal','km','mi','kg','lbs'];
|
2017-02-18 20:14:10 +01:00
|
|
|
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) {
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let input = [5, 'gal'];
|
|
|
|
let expected = 18.9271;
|
2017-02-18 20:14:10 +01:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|