Skip to content

Commit

Permalink
Merge pull request #22 from GHImplementationTeam/production
Browse files Browse the repository at this point in the history
tests from Production
  • Loading branch information
jamesmarlowe authored Apr 8, 2017
2 parents 582b701 + f8e6bfe commit 04ff3b0
Show file tree
Hide file tree
Showing 10 changed files with 692 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
},
"scripts": {
"debug": "node debug app.js",
"start": "node app.js"
"start": "node app.js",
"test": "node ./node_modules/mocha/bin/mocha test/bootstrap.test.js test/unit/**/*.test.js test/integration/**/*.test.js"
},
"main": "app.js",
"repository": {
Expand All @@ -66,6 +67,8 @@
"license": "",
"devDependencies": {
"babel-plugin-react-transform": "^2.0.2",
"chai": "^3.5.0",
"mocha": "^3.2.0",
"react-transform-catch-errors": "^1.0.2",
"react-transform-hmr": "^1.0.4",
"style-loader": "^0.13.1",
Expand Down
Empty file added test/bootstrap.test.js
Empty file.
Empty file added test/mocha.opts
Empty file.
115 changes: 115 additions & 0 deletions test/unit/AcuityService.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
let expect = require('chai').expect;
let calculateAcuityScore = require("../../assets/js/services/AcuityService.js").score;
let calculateAcuityRec = require("../../assets/js/services/AcuityService.js").recommendation;

describe('Calculate acuity score', () => {

it('should handle empty requests', function () {
let intended_score = 0;
let intake = {};
options = {
"intake": intake
};
let calculated_score = calculateAcuityScore(options);
let housing_recommendation = calculateAcuityRec(calculated_score);
expect(calculated_score).to.be.a('number');
expect(calculated_score).to.equal(intended_score);
expect(housing_recommendation)
.to.equal("Not recommended for a Housing and Support Assessment at this time");
});

it('should calculate the acuity score for an incomplete response set', function () {
let intended_score = 2;
let intake = JSON.parse('{"General_1": 67, "Social_7": true}');
options = {
"intake": intake
};
let calculated_score = calculateAcuityScore(options);
let housing_recommendation = calculateAcuityRec(calculated_score);
expect(calculated_score).to.be.a('number');
expect(calculated_score).to.equal(intended_score);
expect(housing_recommendation)
.to.equal("Not recommended for a Housing and Support Assessment at this time");
});

it('should calculate the minimum VI-SPDAT score', () => {
let intended_score = 0;
let fs = require('fs');
let intake = fs.readFileSync(__dirname + '/test_data/minScore.json', 'utf8');
intake = JSON.parse(intake);
options = {
"intake": intake
};
let calculated_score = calculateAcuityScore(options);
let housing_recommendation = calculateAcuityRec(calculated_score);
expect(calculated_score).to.be.a('number');
expect(calculated_score).to.equal(intended_score);
expect(housing_recommendation)
.to.equal("Not recommended for a Housing and Support Assessment at this time");
});

it('should calculate the maximum VI-SPDAT score', () => {
let intended_score = 20;
let fs = require('fs');
let intake = fs.readFileSync(__dirname + '/test_data/maxScore.json', 'utf8');
intake = JSON.parse(intake);
options = {
"intake": intake
};
let calculated_score = calculateAcuityScore(options);
let housing_recommendation = calculateAcuityRec(calculated_score);
expect(calculated_score).to.be.a('number');
expect(calculated_score).to.equal(intended_score);
expect(housing_recommendation)
.to.equal("Recommended for a Permanent Supportive Housing/Housing First Assessment");
});

it('should calculate a VI-SPDAT score that recommends no housing assessment', () => {
let intended_score = 4;
let fs = require('fs');
let intake = fs.readFileSync(__dirname + '/test_data/noRecc.json', 'utf8');
intake = JSON.parse(intake);
options = {
"intake": intake
};
let calculated_score = calculateAcuityScore(options);
let housing_recommendation = calculateAcuityRec(calculated_score);
expect(calculated_score).to.be.a('number');
expect(calculated_score).to.equal(intended_score);
expect(housing_recommendation)
.to.equal("Not recommended for a Housing and Support Assessment at this time");
});

it('should calculate a VI-SPDAT score that recommends a rapid re-housing assessment', () => {
let intended_score = 5;
let fs = require('fs');
let intake = fs.readFileSync(__dirname + '/test_data/rapidRecc.json', 'utf8');
intake = JSON.parse(intake);
options = {
"intake": intake
};
let calculated_score = calculateAcuityScore(options);
let housing_recommendation = calculateAcuityRec(calculated_score);
expect(calculated_score).to.be.a('number');
expect(calculated_score).to.equal(intended_score);
expect(housing_recommendation)
.to.equal("Recommended for a Rapid Re-Housing Assessment");
});

it('should calculate a VI-SPDAT score that recommends permanent supportive housing', () => {
let intended_score = 12;
let fs = require('fs');
let intake = fs.readFileSync(__dirname + '/test_data/permRecc.json', 'utf8');
intake = JSON.parse(intake);
options = {
"intake": intake
};
let calculated_score = calculateAcuityScore(options);
let housing_recommendation = calculateAcuityRec(calculated_score);
expect(calculated_score).to.be.a('number');
expect(calculated_score).to.equal(intended_score);
expect(housing_recommendation)
.to.equal("Recommended for a Permanent Supportive Housing/Housing First Assessment");
});

});
53 changes: 53 additions & 0 deletions test/unit/test_data/maxScore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"General_1": 60,
"Housing_1": 5,
"Housing_2": 10,
"Risks_1": 10,
"Risks_2": 10,
"Risks_3": 10,
"Risks_4": 10,
"Risks_5": 10,
"Risks_6": true,
"Risks_7": true,
"Risks_8": true,
"Risks_9": true,
"Risks_10": true,
"Risks_11": "Bus or Subway",
"Social_1": true,
"Social_2": false,
"Social_3": false,
"Social_4": false,
"Social_5": true,
"Social_6": true,
"Social_7": true,
"Wellness_1": "Does not go for care",
"Wellness_2": true,
"Wellness_3": true,
"Wellness_4": true,
"Wellness_5": true,
"Wellness_6": true,
"Wellness_7": true,
"Wellness_8": true,
"Wellness_9": true,
"Wellness_10": true,
"Wellness_11": true,
"Wellness_12": true,
"Wellness_13": true,
"Wellness_14": true,
"Wellness_15": true,
"Wellness_16": true,
"Wellness_17": true,
"Wellness_18": true,
"Wellness_19": true,
"Wellness_20": true,
"Wellness_21": true,
"Wellness_22": true,
"Wellness_23": true,
"Wellness_24": true,
"Wellness_25": true,
"Wellness_26": true,
"Wellness_27": true,
"Wellness_28": true,
"Wellness_29": true,
"Wellness_30": true
}
53 changes: 53 additions & 0 deletions test/unit/test_data/minScore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"General_1": 33,
"Housing_1": 0,
"Housing_2": 0,
"Risks_1": 0,
"Risks_2": 0,
"Risks_3": 0,
"Risks_4": 0,
"Risks_5": 0,
"Risks_6": false,
"Risks_7": false,
"Risks_8": false,
"Risks_9": false,
"Risks_10": false,
"Risks_11": "Shelter",
"Social_1": false,
"Social_2": true,
"Social_3": true,
"Social_4": true,
"Social_5": false,
"Social_6": false,
"Social_7": false,
"Wellness_1": "Hospital",
"Wellness_2": false,
"Wellness_3": false,
"Wellness_4": false,
"Wellness_5": false,
"Wellness_6": false,
"Wellness_7": false,
"Wellness_8": false,
"Wellness_9": false,
"Wellness_10": false,
"Wellness_11": false,
"Wellness_12": false,
"Wellness_13": false,
"Wellness_14": false,
"Wellness_15": false,
"Wellness_16": false,
"Wellness_17": false,
"Wellness_18": false,
"Wellness_19": false,
"Wellness_20": false,
"Wellness_21": false,
"Wellness_22": false,
"Wellness_23": false,
"Wellness_24": false,
"Wellness_25": false,
"Wellness_26": false,
"Wellness_27": false,
"Wellness_28": false,
"Wellness_29": false,
"Wellness_30": false
}
53 changes: 53 additions & 0 deletions test/unit/test_data/noRecc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"General_1": 33,
"Housing_1": 0,
"Housing_2": 0,
"Risks_1": 1,
"Risks_2": 1,
"Risks_3": 0,
"Risks_4": 1,
"Risks_5": 0,
"Risks_6": false,
"Risks_7": true,
"Risks_8": false,
"Risks_9": false,
"Risks_10": false,
"Risks_11": "Shelter",
"Social_1": false,
"Social_2": true,
"Social_3": false,
"Social_4": true,
"Social_5": false,
"Social_6": false,
"Social_7": false,
"Wellness_1": "Hospital",
"Wellness_2": false,
"Wellness_3": false,
"Wellness_4": false,
"Wellness_5": false,
"Wellness_6": false,
"Wellness_7": false,
"Wellness_8": false,
"Wellness_9": false,
"Wellness_10": false,
"Wellness_11": false,
"Wellness_12": true,
"Wellness_13": false,
"Wellness_14": false,
"Wellness_15": false,
"Wellness_16": false,
"Wellness_17": false,
"Wellness_18": false,
"Wellness_19": false,
"Wellness_20": false,
"Wellness_21": false,
"Wellness_22": false,
"Wellness_23": false,
"Wellness_24": false,
"Wellness_25": false,
"Wellness_26": false,
"Wellness_27": false,
"Wellness_28": false,
"Wellness_29": true,
"Wellness_30": true
}
53 changes: 53 additions & 0 deletions test/unit/test_data/permRecc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"General_1": 63,
"Housing_1": 2,
"Housing_2": 0,
"Risks_1": 1,
"Risks_2": 1,
"Risks_3": 2,
"Risks_4": 1,
"Risks_5": 0,
"Risks_6": false,
"Risks_7": true,
"Risks_8": false,
"Risks_9": false,
"Risks_10": false,
"Risks_11": "Shelter",
"Social_1": false,
"Social_2": true,
"Social_3": false,
"Social_4": true,
"Social_5": false,
"Social_6": false,
"Social_7": false,
"Wellness_1": "Does not go for care",
"Wellness_2": true,
"Wellness_3": false,
"Wellness_4": false,
"Wellness_5": true,
"Wellness_6": false,
"Wellness_7": false,
"Wellness_8": false,
"Wellness_9": false,
"Wellness_10": false,
"Wellness_11": false,
"Wellness_12": false,
"Wellness_13": false,
"Wellness_14": false,
"Wellness_15": false,
"Wellness_16": true,
"Wellness_17": false,
"Wellness_18": false,
"Wellness_19": false,
"Wellness_20": false,
"Wellness_21": false,
"Wellness_22": false,
"Wellness_23": true,
"Wellness_24": false,
"Wellness_25": false,
"Wellness_26": false,
"Wellness_27": false,
"Wellness_28": false,
"Wellness_29": false,
"Wellness_30": true
}
Loading

0 comments on commit 04ff3b0

Please sign in to comment.