Created
January 30, 2015 21:33
-
-
Save ashleygwilliams/21e1f012c07b1c4849c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const _ = require('underscore'); | |
const config = require('./config'); | |
const resources = config.resources; | |
var raw_template = fs.readFileSync('./test_template.js'); | |
var template = _.template(raw_template); | |
for(var i = 0; i < resources.length; i++) { | |
var resource = resources[i]; | |
var mocks = require('./mocks/'+resource); | |
fs.writeFileSync(template(resource + "_test.js", {resource: resource, mocks: mocks})); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const superagent = require('superagent'); | |
const expect = require('expect.js'); | |
const config = require('./config'); | |
describe('piep-api server', function(){ | |
var resource = <%= resource %>; | |
var mock_resource = <%= mocks.mock_resource %>; | |
var mock_update = <%= mocks.mock_update %>; | |
var collection_url = config.host + config.port + config.namespace + '/' + resource; | |
var id; | |
var element_url; | |
describe('with created instance of ' + resource, function(){ | |
beforeEach(function(done){ | |
resetDB().then(function() { | |
superagent.post(collection_url) | |
.send(mock_resource) | |
.end(function(e, res){ | |
expect(e).to.equal(null); | |
id = res.body.id; | |
element_url = collection_url + '/' + id; | |
done(); | |
}); | |
}, done); | |
}); | |
//etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment