UNPKG

aviation-model

Version:

Public methods for querying the information from aviation-pg

132 lines (113 loc) 3.79 kB
"use strict"; var assert = require("assert"); var methods = require("../src/index.js"); var getAirlineData = methods.getAirlineData; describe("Airlines Models.\n", function() { var expectedAirline = { name: "1time Airline", logo_url: "//upload.wikimedia.org/wikipedia/en/thumb/e/eb/1timeAirlineLogo.png/250px-1timeAirlineLogo.png", callsign: "NEXTIME", website: "http://1time.aero/", icao: "RNX", iata: "T6" }; var expectedInstance = { "airline_id": "1time_Airline", "name": "1time Airline", "logo_url": "//upload.wikimedia.org/wikipedia/en/thumb/e/eb/1timeAirlineLogo.png/250px-1timeAirlineLogo.png", "iata": "T6", "icao": "RNX", "callsign": "NEXTIME", "website": "http://1time.aero/" }; describe("getAirlineData method", function () { it("should return all the data of a single airline", function (done) { getAirlineData({ value: "1time_Airline", type: "airline_id" }, function (err, data) { if (err) {throw err;} assert.deepEqual(JSON.stringify(data, null, 2), JSON.stringify(expectedInstance,null,2), "the Name method fails. expected: " + expectedAirline.name + "but got: " + data); done(); }); }); it("should use the method: name", function (done) { getAirlineData({ value: "1time_Airline", type: "airline_id", method: "name" }, function (err, data) { if (err) {throw err;} assert.deepEqual(data, expectedAirline.name, "the Name method fails. expected: " + expectedAirline.name + "but got: " + data); done(); }); }); it("should use the method: LogoLink", function (done) { getAirlineData({ value: "1time_Airline", type: "airline_id", method: "logo_url" }, function (err, data) { if (err) {throw err;} assert.deepEqual(data, expectedAirline.logo_url, "the LogoLink method fails, expected:" + expectedAirline.logoLink + "but got: " + data); done(); }); }); it("should use the method: CallSign", function (done) { getAirlineData({ value: "1time_Airline", type: "airline_id", method: "callsign" }, function (err, data) { if (err) {throw err;} assert.deepEqual(data, expectedAirline.callsign, "the CallSign method fails, expected:" + expectedAirline.callsign + " but got: " + data); done(); }); }); it("should use the method: WebSite", function (done) { getAirlineData({ value: "1time_Airline", type: "airline_id", method: "website" }, function (err, data) { if (err) {throw err;} assert.deepEqual(data, expectedAirline.website, "the WebSite method fails, expected:" + expectedAirline.website + " but got: " + data); done(); }); }); it("should use the method: icao", function (done) { getAirlineData({ value: "1time_Airline", type: "airline_id", method: "icao" }, function (err, data) { if (err) {throw err;} assert.deepEqual(data, expectedAirline.icao, "the icao method fails, expected:" + expectedAirline.icao + " but got: " + data); done(); }); }); it("should use the method: iata", function (done) { getAirlineData({ value: "1time_Airline", type: "airline_id", method: "iata" }, function (err, data) { if (err) {throw err;} assert.deepEqual(data, expectedAirline.iata, "the iata method fails, expected:" + expectedAirline.iata + " but got: " + data); done(); }); }); }); });