UNPKG

aviation-model

Version:

Public methods for querying the information from aviation-pg

54 lines (37 loc) 1.64 kB
"use strict"; var assert = require("assert"); var _ = require("lodash"); var methods = require("../src/index.js"); var getDestinations = methods.getDestinations; describe("Airline_destinations\n", function() { it("should have the required number of destinations, checked by length.", function (done) { getDestinations("Adria_Airways", function(err, destinations) { if (err) {throw err;} var destinationsObject = {}; _.map(destinations, function(value) { if (destinationsObject[value.airline_id] === undefined) { destinationsObject[value.airline_id] = []; } destinationsObject[value.airline_id].push(value.airport_id); }); assert.equal(destinationsObject.Adria_Airways.length, 55, "length calculated with lodash."); done(); }); }); it("should return multiple airlines destinations.", function(done) { var expectedDestinations = require("./fixtures/destinations_%air_test.json"); getDestinations("%air", function(err, destinations) { if (err) {throw err;} var destinationsObject = _.reduce(destinations, function(result, destination) { if (result[destination.airline_id] === undefined) { result[destination.airline_id] = []; } result[destination.airline_id].push(destination.airport_id); return result; }, {}); assert.equal(Object.keys(destinationsObject).length, 17, "the number of destinations has been changed."); assert.deepEqual(Object.keys(destinationsObject), expectedDestinations, "the destinations have changed."); done(); }); }); });