| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- var assert = require("assert"),
- LimitDocumentSource = require("../../../../lib/pipeline/documentSources/LimitDocumentSource");
- module.exports = {
- "LimitDocumentSource": {
- "constructor()": {
- "should not throw Error when constructing without args": function testConstructor(){
- assert.doesNotThrow(function(){
- new LimitDocumentSource();
- });
- }
- },
- "#getSourceName()": {
- "should return the correct source name; $limit": function testSourceName(){
- var lds = new LimitDocumentSource();
- assert.strictEqual(lds.getSourceName(), "$limit");
- }
- },
- "#getFactory()": {
- "should return the constructor for this class": function factoryIsConstructor(){
- assert.strictEqual(new LimitDocumentSource().getFactory(), LimitDocumentSource);
- }
- },
- /*
- "#coalesce()": {
- "should return false if nextSource is not $skip": function dontSkip(){
- },
- "should return true if nextSource is $skip": function changeLimit(){
- }
- },
- "#eof()": {
- "should return true if there are no more sources": function noSources(){
- },
- "should return true if limit is hit": function hitLimit(){
- }
- },
- "#getCurrent()": {
- "should return the current document source": function currSource(){
- var lds = new LimitDocumentSource();
- lds.limit = 1;
- lds.pSource = { item:1 };
- assert.strictEqual(lds.getCurrent(), { item:1 });
- }
- },
- "#advance()": {
- "should return true for moving to the next source": function nextSource(){
- },
- "should return false for no sources remaining": function noMoar(){
- }
- },
- */
- "#sourceToJson()": {
- "should create an object with a key $limit and the value equal to the limit": function sourceToJsonTest(){
- var lds = new LimitDocumentSource();
- lds.limit = 9;
- var t = {};
- lds.sourceToJson(t, false);
- assert.deepEqual(t, { "$limit": 9 });
- }
- },
- "#createFromJson()": {
- "should return a new LimitDocumentSource object from an input number": function createTest(){
- var lds = new LimitDocumentSource();
- var t = lds.createFromJson(5);
- assert.strictEqual(t, LimitDocumentSource);
- assert.strictEqual(t.limit, 5);
- }
- }
- }
- };
- if (!module.parent)(new(require("mocha"))()).ui("exports").reporter("spec").addFile(__filename).run(process.exit);
|