'use strict';

require('should');

describe('BG direction', function ( ) {
  function setupSandbox(data, pluginBase) {
    var ctx = {
      settings: {}
      , pluginBase: pluginBase || {}
    };


    var sandbox = require('../lib/sandbox')();
    return sandbox.clientInit(ctx, Date.now(), data);
  }

  it('set the direction property - Flat', function (done) {
    var sbx = setupSandbox({sgvs: [{direction: 'Flat'}]});

    sbx.offerProperty = function mockedOfferProperty (name, setter) {
      name.should.equal('direction');
      var result = setter();
      result.value.should.equal('Flat');
      result.label.should.equal('→');
      result.entity.should.equal('&#8594;');
      done();
    };

    var direction = require('../lib/plugins/direction')();
    direction.setProperties(sbx);

  });

  it('set the direction property Double Up', function (done) {
    var sbx = setupSandbox({sgvs: [{direction: 'DoubleUp'}]});

    sbx.offerProperty = function mockedOfferProperty (name, setter) {
      name.should.equal('direction');
      var result = setter();
      result.value.should.equal('DoubleUp');
      result.label.should.equal('⇈');
      result.entity.should.equal('&#8648;');
      done();
    };

    var direction = require('../lib/plugins/direction')();
    direction.setProperties(sbx);

  });

  it('set a pill to the direction', function (done) {
    var pluginBase = {
      updatePillText: function mockedUpdatePillText (plugin, options) {
        options.label.should.equal('→&#xfe0e;');
        done();
      }
    };

    var sbx = setupSandbox({sgvs: [{direction: 'Flat'}]}, pluginBase);
    var direction = require('../lib/plugins/direction')();
    direction.setProperties(sbx);
    direction.updateVisualisation(sbx);
  });

  it('get the info for a direction', function () {
    var direction = require('../lib/plugins/direction')();

    direction.info({direction: 'NONE'}).label.should.equal('⇼');
    direction.info({direction: 'NONE'}).entity.should.equal('&#8700;');

    direction.info({direction: 'DoubleUp'}).label.should.equal('⇈');
    direction.info({direction: 'DoubleUp'}).entity.should.equal('&#8648;');

    direction.info({direction: 'SingleUp'}).label.should.equal('↑');
    direction.info({direction: 'SingleUp'}).entity.should.equal('&#8593;');

    direction.info({direction: 'FortyFiveUp'}).label.should.equal('↗');
    direction.info({direction: 'FortyFiveUp'}).entity.should.equal('&#8599;');

    direction.info({direction: 'Flat'}).label.should.equal('→');
    direction.info({direction: 'Flat'}).entity.should.equal('&#8594;');

    direction.info({direction: 'FortyFiveDown'}).label.should.equal('↘');
    direction.info({direction: 'FortyFiveDown'}).entity.should.equal('&#8600;');

    direction.info({direction: 'SingleDown'}).label.should.equal('↓');
    direction.info({direction: 'SingleDown'}).entity.should.equal('&#8595;');

    direction.info({direction: 'DoubleDown'}).label.should.equal('⇊');
    direction.info({direction: 'DoubleDown'}).entity.should.equal('&#8650;');

    direction.info({direction: 'NOT COMPUTABLE'}).label.should.equal('-');
    direction.info({direction: 'NOT COMPUTABLE'}).entity.should.equal('&#45;');

    direction.info({direction: 'RATE OUT OF RANGE'}).label.should.equal('⇕');
    direction.info({direction: 'RATE OUT OF RANGE'}).entity.should.equal('&#8661;');
  });


});

@@ -68,16 +68,42 @@
 n ( ) %7B%0A
+%0A  var now = Date.now();%0A%0A
   functi
@@ -413,32 +413,44 @@
 andbox(%7Bsgvs: %5B%7B
+mills: now, 
 direction: 'Flat
@@ -932,32 +932,44 @@
 andbox(%7Bsgvs: %5B%7B
+mills: now, 
 direction: 'Doub
@@ -1634,16 +1634,28 @@
 sgvs: %5B%7B
+mills: now, 
 directio
@@ -1944,32 +1944,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'NONE
@@ -2021,32 +2021,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'NONE
@@ -2106,32 +2106,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Doub
@@ -2187,32 +2187,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Doub
@@ -2276,32 +2276,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Sing
@@ -2357,32 +2357,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Sing
@@ -2446,32 +2446,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Fort
@@ -2530,32 +2530,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Fort
@@ -2622,32 +2622,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Flat
@@ -2699,32 +2699,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Flat
@@ -2784,32 +2784,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Fort
@@ -2870,32 +2870,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Fort
@@ -2964,32 +2964,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Sing
@@ -3047,32 +3047,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Sing
@@ -3138,32 +3138,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Doub
@@ -3221,32 +3221,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'Doub
@@ -3312,32 +3312,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'NOT 
@@ -3399,32 +3399,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'NOT 
@@ -3492,32 +3492,44 @@
 direction.info(%7B
+mills: now, 
 direction: 'RATE
@@ -3590,16 +3590,28 @@
 n.info(%7B
+mills: now, 
 directio

fix test data for direction tests