1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- var assert = require("assert"),
- ConstantExpression = require("../../../../lib/pipeline/expressions/ConstantExpression");
- module.exports = {
- "ConstantExpression": {
- "constructor() / #evaluate": {
- "should be able to construct from a value type": function testCreate(){
- assert.strictEqual(new ConstantExpression(5).evaluate({}), 5);
- }
- //TODO: CreateFromBsonElement ? ?? ???
- },
- // TODO: the constructor() tests this so not really needed here
- // "#evaluate()": {
- // },
- "#optimize()": {
- "should not optimize anything": function testOptimize(){
- var expr = new ConstantExpression(5);
- assert.strictEqual(expr, expr.optimize());
- }
- },
- "#addDependencies()": {
- "should return nothing": function testDependencies(){
- assert.strictEqual(new ConstantExpression(5).addDependencies(), undefined);
- }
- },
- "#toJson()": {
- "should output proper JSON": function testJson(){
- var expr = new ConstantExpression(5);
- assert.strictEqual(expr.toJson(), 5);
- assert.deepEqual(expr.toJson(true), {$const:5});
- }
- }
- }
- };
- if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);
|