<commit_before>'use strict';

describe('DeviceStatuses', function() {

  var $httpBackend, $httpBackend, _function, property, statusProperty, result, DeviceStatuses;
  var scope = {};

  beforeEach(module('lelylan.directives.device'));

  beforeEach(inject(function($injector) { DeviceStatuses = $injector.get('DeviceStatuses') }));
  beforeEach(inject(function($injector) { $httpBackend = $injector.get('$httpBackend') }));


  describe('when set the device status', function() {

    beforeEach(function() {
      jasmine.getFixtures().fixturesPath = 'base/test/spec/fixtures';
    });

    beforeEach(function() {
      scope.device = JSON.parse(readFixtures('device.json'));
      scope.type   = JSON.parse(readFixtures('type.json'));
    });


    describe('.set', function() {

      beforeEach(function() {
        spyOn(DeviceStatuses, 'set');
      });

      beforeEach(function() {
        DeviceStatuses.set(scope);
      });

      it('calls #setForm method for each function', function() {
        expect(DeviceStatuses.set.calls.count()).toBe(1);
      });
    });


    describe('.checkPending', function() {

      beforeEach(function() {
        property = scope.device.properties[0];
      });

      describe('with matching penging value', function() {<commit_msg>Added test on StatusDevice#passProperty<commit_after>'use strict';

describe('DeviceStatuses', function() {

  var $httpBackend, $httpBackend, _function, property, statusProperty, result, DeviceStatuses;
  var scope = {};

  beforeEach(module('lelylan.directives.device'));

  beforeEach(inject(function($injector) { DeviceStatuses = $injector.get('DeviceStatuses') }));
  beforeEach(inject(function($injector) { $httpBackend = $injector.get('$httpBackend') }));


  describe('when set the device status', function() {

    beforeEach(function() {
      jasmine.getFixtures().fixturesPath = 'base/test/spec/fixtures';
    });

    beforeEach(function() {
      scope.device = JSON.parse(readFixtures('device.json'));
      scope.type   = JSON.parse(readFixtures('type.json'));
    });


    describe('.set', function() {

      beforeEach(function() {
        spyOn(DeviceStatuses, 'set');
      });

      beforeEach(function() {
        DeviceStatuses.set(scope);
      });

      it('calls #setForm method for each function', function() {
        expect(DeviceStatuses.set.calls.count()).toBe(1);
      });
    });


    describe('.passProperty', function() {

      beforeEach(function() {
        property = scope.device.properties[1];
      });

      describe('with matching pending & values', function() {

        beforeEach(function() {
          statusProperty = { id: '1', pending: false, values: ['0.0'], ranges: [] };
        });

        beforeEach(function() {
          result = DeviceStatuses.passProperty(property, statusProperty);
        });

        it('returns true', function() {
          expect(result).toBe(true);
        });
      });

      describe('with matching pending & range', function() {

        beforeEach(function() {
          statusProperty = { id: '1', pending: false, values: [], ranges: [{ min: 0, max: 20 }] };
        });

        beforeEach(function() {
          result = DeviceStatuses.passProperty(property, statusProperty);
        });

        it('returns true', function() {
          expect(result).toBe(true);
        });
      });

      describe('with matching pending & values & range', function() {

        beforeEach(function() {
          statusProperty = { id: '1', pending: false, values: ['0.0'], ranges: [{ min: 0, max: 20 }] };
        });

        beforeEach(function() {
          result = DeviceStatuses.passProperty(property, statusProperty);
        });

        it('returns true', function() {
          expect(result).toBe(true);
        });
      });

      describe('with no matching values', function() {

        beforeEach(function() {
          statusProperty = { id: '1', pending: false, values: ['100.0'], ranges: [] };
        });

        beforeEach(function() {
          result = DeviceStatuses.passProperty(property, statusProperty);
        });

        it('returns true', function() {
          expect(result).toBe(false);
        });
      });

      describe('with no matching pending', function() {

        beforeEach(function() {
          statusProperty = { id: '1', pending: true, values: ['0.0'], ranges: [] };
        });

        beforeEach(function() {
          result = DeviceStatuses.passProperty(property, statusProperty);
        });

        it('returns true', function() {
          expect(result).toBe(false);
        });
      });

      describe('with no matching ranges', function() {

        beforeEach(function() {
          statusProperty = { id: '1', pending: false, values: [], ranges: [{ min: 10, max: 20 }] };
        });

        beforeEach(function() {
          result = DeviceStatuses.passProperty(property, statusProperty);
        });

        it('returns true', function() {
          expect(result).toBe(false);
        });
      });

      describe('with no params', function() {

        beforeEach(function() {
          statusProperty = { id: '1', pending: null, values: [], ranges: [] };
        });

        beforeEach(function() {
          result = DeviceStatuses.passProperty(property, statusProperty);
        });

        it('returns true', function() {
          expect(result).toBe(true);
        });
      });

    });


    describe('.checkPending', function() {

      beforeEach(function() {
        property = scope.device.properties[0];
      });

      describe('with matching penging value', function() {
{'fraction_non_alphanumeric': 0.16267518183430904, 'fraction_numerical': 0.005676778428241973, 'mean_word_length': 2.6586632057105777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3296466', 'n_tokens_mistral': 1577, 'n_tokens_neox': 1514, 'n_words': 291}