"use strict";

var ControlArea = require('./control-area');
var building2016 = {
  codeYear: 2016,
  fireSuppressionCoverage: true
};
var building2001 = {
  codeYear: 2001,
  fireSuppressionCoverage: true
};
describe('Control Area', function () {
  it('should assign occupancy B based on room occupancies of A', function () {
    var area = new ControlArea({
      rooms: [{
        occupancy: 'A'
      }, {
        occupancy: 'A'
      }]
    });
    expect(area.occupancy).toEqual('B');
  });
  it('should assign occupancy B based on room occupancies of B, L, S, H3', function () {
    var area = new ControlArea({
      rooms: [{
        occupancy: 'L'
      }, {
        occupancy: 'B'
      }, {
        occupancy: 'M'
      }, {
        occupancy: 'L'
      }, {
        occupancy: 'S'
      }, {
        occupancy: 'H3'
      }]
    }, building2016);
    expect(area.occupancy).toEqual('B');
  });
  it('should assign occupancy L based on room occupancies of L & M', function () {
    var area = new ControlArea({
      isOutdoor: false,
      rooms: [{
        occupancy: 'L'
      }, {
        occupancy: 'M'
      }, {
        occupancy: 'L'
      }]
    }, building2016);
    expect(area.occupancy).toEqual('L');
  });
  it('should assign occupancy B based on room occupancies of L without surpression coverage', function () {
    var area = new ControlArea({
      isOutdoor: false,
      rooms: [{
        occupancy: 'L'
      }, {
        occupancy: 'L'
      }]
    }, {
      codeYear: 2016,
      fireSuppressionCoverage: false
    });
    expect(area.occupancy).toEqual('B');
  });
  it('should assign occupancy M based on room occupancies of M & H3', function () {
    var area = new ControlArea({
      rooms: [{
        occupancy: 'M'
      }, {
        occupancy: 'H3'
      }]
    }, building2016);
    expect(area.occupancy).toEqual('M');
  });
  it('should assign occupancy H8 based on 2001 code year', function () {
    var area = new ControlArea({
      rooms: [{
        occupancy: 'H8'
      }]
    }, building2001);
    expect(area.occupancy).toEqual('H8');
  });
  it('should assign occupancy B based on 2001 code year and room occupancies of B & H8', function () {
    var area = new ControlArea({
      rooms: [{
        occupancy: 'H8'
      }, {
        occupancy: 'B'
      }]
    }, building2001);
    expect(area.occupancy).toEqual('B');
  });
  it('should assign occupancy B for area with no rooms', function () {
    var area = new ControlArea({
      rooms: []
    });
    expect(area.occupancy).toEqual('B');
  });
  it('should default rooms to possible occupancies based on code year', function () {
    var area = new ControlArea({
      rooms: [{
        occupancy: 'H8'
      }, {
        occupancy: 'FOO'
      }]
    }, building2016);
    expect(area.occupancy).toEqual('B');
  });
  it('should default H8 to B when outdoor', function () {
    var area = new ControlArea({
      isOutdoor: true,
      rooms: [{
        occupancy: 'H8'
      }]
    }, building2001);
    expect(area.occupancy).toEqual('B');
  });
});