var should = require('should');

var BSP = require('../lib/bsp'),
    Container = require('../lib/geometry/container');

describe('BSP', function() {

  describe('Node', function() {
    var node = BSP.Node(null, Container(10, 10, 50, 50));

    it('should have the correct properties', function() {
      node.should.have.property('parent');
      node.should.have.property('depth');
      node.should.have.property('container');
      node.should.have.property('fork');
      node.should.have.property('parent');
    });

    it('should create children when forked', function() {
      node.fork('random');
      node.left.should.not.equal(null)
        .and.be.an.instanceOf(Object);

      node.right.should.not.equal(null)
        .and.be.an.instanceOf(Object);
    });
  });

  describe('BSP.Tree', function() {
    var tree = BSP.Tree(0, 0, 100, 100, 3);

    it('should have a root node', function() {
      tree.should.have.property('root');
      tree.root.should.be.instanceOf(Object);
    });
  });

  describe('BSP.strategies', function() {
    it('should be an object of strategies', function() {
      for(var name in BSP.strategies) {
        if(BSP.strategies.hasOwnProperty(name)) {
          BSP.strategies.should.have.property(name);
          BSP.strategies[name].should.be.an.instanceOf(Function);
        }
      }
    });
  });

});
