describe('Popover', function () {
  'use strict';

  beforeEach(function(done) {
    var self = this;
    requirejs([
      'jquery',
      'Popover'
    ],
    function (
      $,
      Popover
    ) {
      self.$html = $(window.__html__['spec/javascripts/fixtures/Popover.html']).appendTo('body');
      self.fixture = self.$html.find('[data-dough-component="Popover"]');
      self.Popover = Popover;
      $('body')
        .height(1000)
        .width(1000);
      done();
    }, done);
  });

  afterEach(function() {
    this.$html.remove();
  });

  describe('General', function () {
    describe('Position left', function () {
      beforeEach(function (done) {
        this.component = new this.Popover(this.fixture, {
          direction: 'left'
        });
        this.component.init();
        done();
      });

      it('should position itself to the left of the trigger without overlapping viewport edge', function() {
        var $target = this.component.$target,
            $trigger = this.component.$trigger;

        $trigger.click();
        // expect(this.component.getElementBoundaries($target).right).to.be.below(this.component.$trigger.position().left);
        // expect($target.position().left).to.be.above(0);
      });
    });

    describe('Position right', function () {
      beforeEach(function (done) {
        this.component = new this.Popover(this.fixture, {
          direction: 'right'
        });
        this.component.init();
        done();
      });

      it('should position itself to the right of the trigger without overlapping viewport edge', function() {
        var $trigger = this.component.$trigger,
            $target = this.component.$target;

        $trigger.click();
        expect($target.position().left).to.be.equal(this.component.getElementBoundaries($trigger).right);
        expect($target.position().top).to.be.above(0);
      });
    });


    describe('Position Top', function () {
      beforeEach(function (done) {
        this.component = new this.Popover(this.fixture, {
          direction: 'top'
        });
        this.component.init();
        done();
      });

      it('should position itself above the trigger and without overlapping viewport edge', function() {
        var $target = this.component.$target,
            $trigger = this.component.$trigger;

        $trigger.click();
        expect(this.component.getElementBoundaries($target).bottom).to.be.equal($trigger.position().top);
        expect($target.position().top).to.be.above(0);
      });
    });

    describe('Position Bottom', function () {
      beforeEach(function (done) {
        this.component = new this.Popover(this.fixture, {
          direction: 'bottom'
        });
        this.component.init();
        done();
      });

      it('should position itself below the trigger and without overlapping viewport edge', function() {
        var $target = this.component.$target,
            $trigger = this.component.$trigger;

        $trigger.click();
        expect($target.position().top).to.be.above($trigger.position().top);
        expect(this.component.getElementBoundaries($target).bottom).to.be.below($('body').height());
      });
    });
  });
});

@@ -305,16 +305,17 @@
    self.
+$
 fixture 
@@ -365,24 +365,66 @@
 opover%22%5D');%0A
+      self.$fixture.css(%7Bwidth:'200px'%7D);%0A
       self.P
@@ -456,25 +456,16 @@
 ('body')
-%0A        
 .height(
@@ -469,25 +469,16 @@
 ht(1000)
-%0A        
 .width(1
@@ -481,16 +481,43 @@
 th(1000)
+.css(%7Bposition:'relative'%7D)
 ;%0A      
@@ -756,32 +756,33 @@
 is.Popover(this.
+$
 fixture, %7B%0A     
@@ -1425,32 +1425,33 @@
 is.Popover(this.
+$
 fixture, %7B%0A     
@@ -2073,32 +2073,33 @@
 is.Popover(this.
+$
 fixture, %7B%0A     
@@ -2723,16 +2723,17 @@
 er(this.
+$
 fixture,

Set basic styling for components in fixtures and tidy setup