{"size": 2608, "ext": "js", "max_stars_repo_path": "src/person-tracking/test/test-basics.js", "max_stars_repo_name": "01org/node-realsense", "max_stars_repo_stars_event_min_datetime": "2017-02-27T14:10:12.000Z", "max_stars_repo_stars_event_max_datetime": "2017-09-25T08:02:07.000Z", "max_issues_repo_path": "src/person-tracking/test/test-basics.js", "max_issues_repo_name": "01org/node-realsense", "max_issues_repo_issues_event_min_datetime": "2017-02-22T08:02:38.000Z", "max_issues_repo_issues_event_max_datetime": "2017-09-27T09:26:24.000Z", "max_forks_repo_path": "src/person-tracking/test/test-basics.js", "max_forks_repo_name": "01org/node-realsense", "max_forks_repo_forks_event_min_datetime": "2017-02-22T09:05:42.000Z", "max_forks_repo_forks_event_max_datetime": "2017-09-21T07:52:40.000Z"}
{"max_stars_count": 12, "max_issues_count": 209, "max_forks_count": 18, "avg_line_length": 37.2571428571, "max_line_length": 90, "alphanum_fraction": 0.625}
// Copyright (c) 2016 Intel Corporation. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.

'use strict';

/* global describe, it */
const spawnNpmInstall = require('spawn-npm-install');
const testNpmInstall = require('../common/scripts/test-npm-install.js');
const tmp = require('tmp');
const addon = require('bindings')('realsense_person_tracking');
const assert = require('assert');

describe('Person Tracking Test Suite - Basics', function() {
  it('Make the tarball', function() {
    return testNpmInstall.makeTarball();
  });

  it('Make sure can be installed via npm install <tarball>', function() {
    // eslint-disable-next-line
    this.timeout(600*1000);

    return testNpmInstall.installFromTarball(tmp, spawnNpmInstall);
  });

  it('Make sure methods are all there', function(done) {
    let g = {
      PersonRecognition: ['getAllRecognitionIDs', 'clearDatabase', 'exportDatabase',
                        'importDatabase', 'recognizeAllPersons', 'registerPerson',
                        'unRegisterPerson', 'recognitionIDExist', 'reinforceRegistration',
                        'recognizePerson', 'querySimilarityScoreFromPerson',
                        'removePersonDescriptor', 'getPersonDescriptorIDs'],
      PersonTracking: ['startTrackingPerson', 'stopTrackingPerson', 'resetTracking'],
      PersonTracker: ['start', 'stop', 'getPersonTrackerOptions',
                      'setPersonTrackerOptions', 'pause', 'resume', 'reset',
                      'getCameraOptions', 'setCameraOptions', 'getPersonInfo'],
    };
    // eslint-disable-next-line
    for(let k in g) {
      let Instance = addon[k];
      g[k].forEach((methodName) => {
        assert.equal(typeof Instance.prototype[methodName], 'function');
      });
    }
    done();
  });

  it('Make sure PersonTracker properties are all there', function() {
    // eslint-disable-next-line no-invalid-this
    this.timeout(30000);
    return new Promise((resolve, reject) => {
      addon.createPersonTracker().then(function(instance) {
        let g = {
          // attributeName: [type, writable]
          personRecognition: ['object', false],
          personTracking: ['object', false],
          state: ['string', false],
        };
        // eslint-disable-next-line
        for(let k in g) {
          assert(instance.hasOwnProperty(k));
          assert.equal(typeof instance[k], g[k][0]);
          assert.equal(Object.getOwnPropertyDescriptor(instance, k).writable, g[k][1]);
        };
        resolve();
      });
    });
  });
});
