Skip to content

Commit

Permalink
Merge pull request #2 from cianclarke/master
Browse files Browse the repository at this point in the history
Add unit tests
  • Loading branch information
cianclarke committed Aug 16, 2012
2 parents 1e44a95 + 192e892 commit 491b93d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<!-- Config -->
<script type="text/javascript">var exports={};</script>
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript" src="js/app.js"></script>

<!-- Model -->
Expand Down
5 changes: 5 additions & 0 deletions client/default/js/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var CONFIG = {
sampleLocation: false,
sampleStores: false,
fakeServerTimeout: 0,
};
3 changes: 0 additions & 3 deletions shared/config.js → cloud/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
var CONFIG = {
sampleLocation: false,
sampleStores: false,
fakeServerTimeout: 0,
storeLimit: 0, // Limit on number of stores to show in search results. 0 = no limit
boundingBox: true, // Whether or not to apply a lat/lon bounding box restriction on store location queries
boundingBoxLat: 0.1,
Expand Down
3 changes: 3 additions & 0 deletions cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"name": "fh-app",
"version": "0.1.0",
"dependencies" : {
},
"scripts": {
"test" : "node test/tests.js"
}
}
4 changes: 2 additions & 2 deletions cloud/storesController.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var CONFIG = require("config.js");
var sampleResponse = require("sampledata.js").sampleResponse;
var CONFIG = require("./config.js");
var sampleResponse = require("./sampledata.js").sampleResponse;

/*
* Get all stores that match the given query
Expand Down
17 changes: 17 additions & 0 deletions cloud/test/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var main = require('../main'),
assert = require('assert');

main.findStores({ query: '' }, function(err, res){
console.log("findStores: Running tests");
assert.ok(!err);
assert.ok(res);
assert.ok(res.data);
assert.ok(res.data.length > 0);
var data = res.data,
aRecord = data[0];
assert.ok(aRecord);
assert.ok(aRecord.county);
assert.ok(aRecord.address && typeof aRecord.address === "object");
assert.ok(aRecord.distance && typeof aRecord.distance === "number");
console.log("findStores: Tests passed OK.");
});

0 comments on commit 491b93d

Please sign in to comment.