
'use strict';

var should = require('should');


describe('ddata', function ( ) {
  // var cage = require('../lib/plugins/cannulaage')();
  var sandbox = require('../lib/sandbox')();
  var env = require('../env')();
  var ctx = {};
  ctx.ddata = require('../lib/data/ddata')();
  it('should be a module', function (done) {
    var libddata = require('../lib/data/ddata');
    // should.be.Function(libddata);
    var ddata = libddata( );
    should.exist(ddata);
    ddata = ctx.ddata.clone( );
    should.exist(ddata);
    done( );
  });
  it('has #clone( )', function (done) {
    var ddata = ctx.ddata.clone( );
    should.exist(ddata);
    done( );
  });
});

describe('some garbage', function ( ) {
  var cage = require('../lib/plugins/cannulaage')();
  var sandbox = require('../lib/sandbox')();
  var env = require('../env')();
  var ctx = {};
  ctx.ddata = require('../lib/data/ddata')();
  ctx.notifications = require('../lib/notifications')(env, ctx);

  function prepareSandbox ( ) {
    var sbx = require('../lib/sandbox')().serverInit(env, ctx);
    sbx.offerProperty('iob', function () {
      return {iob: 0};
    });
    return sbx;
  }
  it('should should work', function (done) {
    var foo = {bar: true };
    // foo.should.exist( );
    // foo.should.be.ok( );
    done( );
  });
});


@@ -272,16 +272,17 @@
 ta')();%0A
+%0A
   it('sh
@@ -454,24 +454,85 @@
 ist(ddata);%0A
+    should.exist(libddata);%0A    should.exist(libddata.call);%0A
     ddata = 
@@ -595,16 +595,17 @@
 ;%0A  %7D);%0A
+%0A
   it('ha
@@ -644,37 +644,41 @@
     
-var ddata = ctx.ddata.clone( 
+should.exist(ctx.ddata.treatments
 );%0A 
@@ -697,461 +697,549 @@
 ist(
+ctx.
 ddata
+.sgvs
 );%0A    
-done( );%0A  %7D);%0A%7D);%0A%0Adescribe('some garbage', function ( ) %7B%0A  var cage = require('../lib/plugins/cannulaage')();%0A  var sandbox = require('../lib/sandbox')();%0A  var env = require('../env')(
+should.exist(ctx.ddata.mbgs);%0A    should.exist(ctx.ddata.cals);%0A    should.exist(ctx.ddata.profiles);%0A    should.exist(ctx.ddata.devicestatus);%0A    should.exist(ctx.ddata.lastUpdated
 );%0A
+  
   var 
-ctx = %7B%7D;%0A  ctx.ddata = require('../lib/data/
+ddata = ctx.ddata.clone( );%0A    should.exist(
 ddata
-')(
 );%0A  
-ctx.notifications = require('../lib/notifications')(env, ctx);%0A%0A  function prepareSandbox ( ) %7B%0A    var sbx = require('../lib/sandbox')().serverInit(env, ctx);%0A    sbx.offerProperty('iob
+  should.exist(ddata.treatments);%0A    should.exist(ddata.sgvs);%0A    should.exist(ddata.mbgs);%0A    should.exist(ddata.cals);%0A    should.exist(ddata.profiles);%0A    should.exist(ddata.devicestatus);%0A    should.exist(ddata.lastUpdated);%0A    done( );%0A  %7D);%0A%0A  it('has #split( )
 ', f
@@ -1247,24 +1247,28 @@
 nction (
+done
 ) %7B%0A    
   return
@@ -1263,202 +1263,646 @@
     
-  return %7Biob: 0%7D;%0A    %7D);%0A    return sbx;%0A  %7D%0A  it('should should work', function (done) %7B%0A    var foo = %7Bbar: true %7D;%0A    // foo.should.exist( );%0A    // foo.should.be.ok( );%0A    done( );%0A  %7D);
+var date = new Date( );%0A    var time = date.getTime( );%0A    var cutoff = 1000 * 60 * 5;%0A    var max = 1000 * 60 * 60 * 24 * 2;%0A    var pieces = ctx.ddata.split(time, cutoff, max);%0A    should.exist(pieces);%0A    should.exist(pieces.first);%0A    should.exist(pieces.last);%0A    should.exist(pieces.rest);%0A%0A    done( );%0A  %7D);%0A%0A  // TODO: ensure partition function gets called via:%0A  // Properties%0A  // * ddata.devicestatus%0A  // * ddata.mbgs%0A  // * ddata.sgvs%0A  // * ddata.treatments%0A  // * ddata.profiles%0A  // * ddata.lastUpdated%0A  // Methods%0A  // * ddata.processTreatments%0A  // * ddata.processDurations%0A  // * ddata.clone%0A  // * ddata.split%0A %0A
 %0A%7D);

add slightly more tests for ddata