lundi 16 octobre 2017

nodejs restify test with mocha and chai : lost method getSettings()

Im developing in a app with restify there is a part where is not my code is in the test part there is a line that i dont understand is server.getSetting i don't know where this method comes
the line this  

chai.expect(parseInt(server.getSettings().port)).is.eq(parseInt(server.address().port));

the imports of the test file are

    'use strict';
    var chai = require('chai');
    var mocha = require('mocha');
    var logger = require('winston');
    var httpStatus = require('http-status-codes');
    var template = require('es6-template-strings');

here is the test server code

describe('App Server', function () {
    var app = require(__dirname + "/../../dist/app");
    var server = null;
    var $server = require(__dirname + "/../drivers/server");

    before(function (done) {
        app.run({
            port: 4001,
            env: "TEST",
            name: 'api'
        }).then(function (instance) {
            server = instance;
            $server.setServerInstance(server);
            done();
        })
    });
    after(function () {
        if (server) {
            server.close();
        }
    });
    beforeEach(function () {});


    it('should listen on configurated port in settings', function (done) {
        chai.expect(parseInt(server.getSettings().port)).is.eq(parseInt(server.address().port));
        done();
    });
});

and here is when i call getSettings

  it('should listen on configurated port in settings', function (done) {
      chai.expect(parseInt(server.getSettings().port)).is.eq(parseInt(server.address().port));
      done();
  });

the imports of the Server in the driver folder are

'use strict';
var supertest = require('supertest');
var logger = require('winston');
var server = null;

how i said i dont know where method getSettings comes

Aucun commentaire:

Enregistrer un commentaire