mongodb-expressions
Version:
MongoDB expressions for fire.js
52 lines (51 loc) • 1.53 kB
JavaScript
var vows = require('vows')
var assert = require('assert')
var FireRuntime = require('fire').Runtime
var configRuntime = require('./util').configRuntime
var dropCollection = require('./util').dropCollection
require('./runtimeExtensions.js')
vows.describe('Mongo.DropDatabase').addBatch({
"When I insert a document and the database and drop the database": {
topic: function() {
dropCollection(function() {
var self = this
var runtime = new FireRuntime()
var testExpressionName = "test_MongoInsert"
runtime.registerWellKnownExpressionDefinition({
name: testExpressionName,
json: {
"@Mongo.Insert(points)": {
x:100,
y:200
},
"@Mongo.DropDatabase": null,
"@Mongo.Find(points)": null
}
});
configRuntime(runtime, function(initError) {
if(initError) {
self.callback(initError, null)
} else {
var contextBase = {
_resultCallback: function(res) {
self.callback(null, res)
},
_loopCallback: function() {},
_inputExpression: function() {},
_variables: {},
_errorCallback: function(err) {
self.callback(err, null)
}
};
runtime._testOnly_runExpressionByName(testExpressionName, contextBase ,null)
}
})
},this,"points") // Drop database
},
"there should not be any documents in the database": function(err, result) {
assert.isNull(err)
assert.instanceOf(result, Array)
assert.isEmpty(result)
}
}
}).export(module);