(function() { var chai = require('chai'), should = chai.should(), expect = chai.expect, sinon = require('sinon'); var GoogleGeocoder = require('../../lib/geocoder/googlegeocoder.js'); var HttpAdapter = require('../../lib/httpadapter/httpadapter.js'); var mockedHttpAdapter = { get: function() { return {}; }, supportsHttps: function() { return true; } }; describe('GoogleGeocoder', function() { describe('#constructor' , function() { it('an http adapter must be set', function() { expect(function() {new GoogleGeocoder();}).to.throw(Error, 'GoogleGeocoder need an httpAdapter'); }); it('if a clientId is specified an apiKey must be set', function() { expect(function() {new GoogleGeocoder(mockedHttpAdapter, {clientId: 'CLIENT_ID'});}).to.throw(Error, 'You must specify a apiKey (privateKey)'); }); it('Should be an instance of GoogleGeocoder if an http adapter is provided', function() { var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); googleAdapter.should.be.instanceof(GoogleGeocoder); }); it('Should be an instance of GoogleGeocoder if an http adapter, clientId, and apiKer are provided', function() { var googleAdapter = new GoogleGeocoder(mockedHttpAdapter, {clientId: 'CLIENT_ID', apiKey: 'API_KEY'}); googleAdapter.should.be.instanceof(GoogleGeocoder); }); }); describe('#geocode' , function() { it('Should not accept IPv4', function() { var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); expect(function() { googleAdapter.geocode('127.0.0.1'); }).to.throw(Error, 'GoogleGeocoder does not support geocoding IPv4'); }); it('Should not accept IPv6', function() { var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); expect(function() { googleAdapter.geocode('2001:0db8:0000:85a3:0000:0000:ac1f:8001'); }).to.throw(Error, 'GoogleGeocoder does not support geocoding IPv6'); }); it('Should call httpAdapter get method', function() { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').withArgs('https://maps.googleapis.com/maps/api/geocode/json', { address: "1 champs élysée Paris", sensor: false }).once().returns({then: function() {}}); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); googleAdapter.geocode('1 champs élysée Paris'); mock.verify(); }); it('Should call httpAdapter get method with language if specified', function() { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').withArgs('https://maps.googleapis.com/maps/api/geocode/json', { address: "1 champs élysée Paris", sensor: false, language: "fr" }).once().returns({then: function() {}}); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter, { language: 'fr' }); googleAdapter.geocode('1 champs élysée Paris'); mock.verify(); }); it('Should call httpAdapter get method with region if specified', function() { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').withArgs('https://maps.googleapis.com/maps/api/geocode/json', { address: "1 champs élysée Paris", sensor: false, region: "fr" }).once().returns({then: function() {}}); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter, { region: 'fr' }); googleAdapter.geocode('1 champs élysée Paris'); mock.verify(); }); it('Should call httpAdapter get method with components if called with object', function() { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').withArgs('https://maps.googleapis.com/maps/api/geocode/json', { address: "1 champs élysée Paris", sensor: false, components: "country:FR|postal_code:75008" }).once().returns({then: function() {}}); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); googleAdapter.geocode({ address: '1 champs élysée Paris', zipcode: '75008', country: 'FR' }); mock.verify(); }); it('Should call httpAdapter get method with key if specified', function() { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').withArgs('https://maps.googleapis.com/maps/api/geocode/json', { address: "1 champs élysée Paris", sensor: false, key: "hey-you-guys" }).once().returns({then: function() {}}); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter, { apiKey: 'hey-you-guys' }); googleAdapter.geocode('1 champs élysée Paris'); mock.verify(); }); it('Should return geocoded address', function(done) { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().callsArgWith(2, false, { status: "OK", results: [{ geometry: {location : { lat: 37.386, lng: -122.0838 }}, address_components: [ {types: ['country'], long_name: 'France', short_name: 'Fr' }, {types: ['locality'], long_name: 'Paris' }, {types: ['postal_code'], long_name: '75008' }, {types: ['route'], long_name: 'Champs-Élysées' }, {types: ['street_number'], long_name: '1' }, {types: ['administrative_area_level_1'], long_name: 'Île-de-France', short_name: 'IDF'} ], country_code: 'US', country_name: 'United States', locality: 'Mountain View', }]} ); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); googleAdapter.geocode('1 champs élysées Paris', function(err, results) { err.should.to.equal(false); results[0].should.to.deep.equal({ "latitude" : 37.386, "longitude" : -122.0838, "country" : "France", "city" : "Paris", "zipcode" : "75008", "streetName" : "Champs-Élysées", "streetNumber": "1", "countryCode" : "Fr", "state" : "Île-de-France", "stateCode" : "IDF", "extra": { "premise": null, "subpremise": null, "neighborhood": null, "establishment": null, "googlePlaceId": null }, "formattedAddress": null }); results.raw.should.deep.equal({ status: "OK", results: [{ geometry: {location : { lat: 37.386, lng: -122.0838 }}, address_components: [ {types: ['country'], long_name: 'France', short_name: 'Fr' }, {types: ['locality'], long_name: 'Paris' }, {types: ['postal_code'], long_name: '75008' }, {types: ['route'], long_name: 'Champs-Élysées' }, {types: ['street_number'], long_name: '1' }, {types: ['administrative_area_level_1'], long_name: 'Île-de-France', short_name: 'IDF'} ], country_code: 'US', country_name: 'United States', locality: 'Mountain View', }]}); mock.verify(); done(); }); }); it('Should handle a not "OK" status', function(done) { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().callsArgWith(2, false, { status: "OVER_QUERY_LIMIT", error_message: "You have exceeded your rate-limit for this API.", results: [] }); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); googleAdapter.geocode('1 champs élysées Paris', function(err, results) { err.message.should.to.equal("Status is OVER_QUERY_LIMIT. You have exceeded your rate-limit for this API."); results.raw.should.deep.equal({ status: "OVER_QUERY_LIMIT", error_message: "You have exceeded your rate-limit for this API.", results: [] }); mock.verify(); done(); }); }); it('Should handle a not "OK" status and no error_message', function(done) { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().callsArgWith(2, false, { status: "INVALID_REQUEST", results: [] }); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); googleAdapter.geocode('1 champs élysées Paris', function(err, results) { err.message.should.to.equal("Status is INVALID_REQUEST."); mock.verify(); done(); }); }); }); describe('#reverse' , function() { it('Should call httpAdapter get method', function() { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().returns({then: function() {}}); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); googleAdapter.reverse({lat:10.0235,lon:-2.3662}); mock.verify(); }); it('Should return geocoded address', function(done) { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().callsArgWith(2, false, { status: "OK", results: [{ geometry: {location : { lat: 40.714232, lng: -73.9612889 }}, address_components: [ {types: ['country'], long_name: 'United States', short_name: 'US' }, {types: ['locality'], long_name: 'Brooklyn' }, {types: ['postal_code'], long_name: '11211' }, {types: ['route'], long_name: 'Bedford Avenue' }, {types: ['street_number'], long_name: '277' }, {types: ['administrative_area_level_1'], long_name: 'État de New York', short_name: 'NY'} ], country_code: 'US', country_name: 'United States', locality: 'Mountain View', }]} ); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); googleAdapter.reverse({lat:40.714232,lon:-73.9612889}, function(err, results) { err.should.to.equal(false); results[0].should.to.deep.equal({ "latitude" : 40.714232, "longitude" : -73.9612889, "country" : "United States", "city" : "Brooklyn", "zipcode" : "11211", "streetName" : "Bedford Avenue", "streetNumber": "277", "countryCode" : "US", "state" : "État de New York", "stateCode" : "NY", "extra": { "premise": null, "subpremise": null, "neighborhood": null, "establishment": null, "googlePlaceId": null }, "formattedAddress": null }); results.raw.should.deep.equal({ status: "OK", results: [{ geometry: {location : { lat: 40.714232, lng: -73.9612889 }}, address_components: [ {types: ['country'], long_name: 'United States', short_name: 'US' }, {types: ['locality'], long_name: 'Brooklyn' }, {types: ['postal_code'], long_name: '11211' }, {types: ['route'], long_name: 'Bedford Avenue' }, {types: ['street_number'], long_name: '277' }, {types: ['administrative_area_level_1'], long_name: 'État de New York', short_name: 'NY'} ], country_code: 'US', country_name: 'United States', locality: 'Mountain View', }]}); mock.verify(); done(); }); }); it('Should handle a not "OK" status', function(done) { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().callsArgWith(2, false, { status: "OVER_QUERY_LIMIT", error_message: "You have exceeded your rate-limit for this API.", results: [] }); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); googleAdapter.reverse({lat:40.714232,lon:-73.9612889}, function(err, results) { err.message.should.to.equal("Status is OVER_QUERY_LIMIT. You have exceeded your rate-limit for this API."); mock.verify(); done(); }); }); it('Should handle a not "OK" status and no error_message', function(done) { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().callsArgWith(2, false, { status: "INVALID_REQUEST", results: [] }); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter); googleAdapter.reverse({lat:40.714232,lon:-73.9612889}, function(err, results) { err.message.should.to.equal("Status is INVALID_REQUEST."); mock.verify(); done(); }); }); it('Should call httpAdapter get method with signed url if clientId and apiKey specified', function() { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').withArgs('https://maps.googleapis.com/maps/api/geocode/json', { address: "1 champs élysée Paris", client: "raoul", sensor: false, signature: "PW1yyLFH9lN16B-Iw7EXiAeMKX8=" }).once().returns({then: function() {}}); var googleAdapter = new GoogleGeocoder(mockedHttpAdapter, {clientId: 'raoul', apiKey: 'foo'}); googleAdapter.geocode('1 champs élysée Paris'); mock.verify(); }); it('Should generate signatures with all / characters replaced with _', function() { var googleAdapter = new GoogleGeocoder(mockedHttpAdapter, {clientId: 'james', apiKey: 'foo'}); var params = { sensor: false, client: 'james', address: 'qqslfzxytfr' }; googleAdapter._signedRequest('https://maps.googleapis.com/maps/api/geocode/json', params); expect(params.signature).to.equal('ww_ja1wA8YBE_cfwmx9EQ_5y2pI='); }); it('Should generate signatures with all + characters replaced with -', function() { var googleAdapter = new GoogleGeocoder(mockedHttpAdapter, {clientId: 'james', apiKey: 'foo'}); var params = { sensor: false, client: 'james', address: 'lomxcefgkxr' }; googleAdapter._signedRequest('https://maps.googleapis.com/maps/api/geocode/json', params); expect(params.signature).to.equal('zLXE-mmcsjp2RobIXjMd9h3P-zM='); }); }); }); })();
describe('OSNP', function() { var chai = require('chai'); var osnp = require('../lib/osnp.js'); chai.should(); osnp.setPANID(new Buffer([0xfe, 0xca])); osnp.setShortAddress(new Buffer([0xbe, 0xba])); osnp.setEUI(new Buffer([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])); describe('#parseFrame', function() { it('should parse a frame and return an OSNPFrame object', function() { var frame = new Buffer([0x61, 0x88, 0x01, 0xfe, 0xca, 0xef, 0xbe, 0xbe, 0xba, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00]); var osnpFrame = osnp.parseFrame(frame); osnpFrame.frameControlLow.should.equal(0x61); osnpFrame.frameControlHigh.should.equal(0x88); osnpFrame.sequenceNumber.should.equal(0x01); osnpFrame.destinationPAN.should.deep.equal(new Buffer([0xfe, 0xca])); osnpFrame.destinationAddress.should.deep.equal(new Buffer([0xef, 0xbe])); osnpFrame.sourcePAN.should.deep.equal(new Buffer([0xfe, 0xca])); osnpFrame.sourceAddress.should.deep.equal(new Buffer([0xbe, 0xba])); osnpFrame.payload.should.deep.equal(new Buffer([0x74, 0x65, 0x73, 0x74])); }); it('should parse a frame with security return an OSNPFrame object', function() { var frame = new Buffer([0x69, 0x88, 0x01, 0xfe, 0xca, 0xef, 0xbe, 0xbe, 0xba, 0x01, 0x00, 0x00, 0x00, 0x01, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00]); var osnpFrame = osnp.parseFrame(frame); osnpFrame.frameControlLow.should.equal(0x69); osnpFrame.frameControlHigh.should.equal(0x88); osnpFrame.hasSecurityEnabled().should.equal(true); osnpFrame.sequenceNumber.should.equal(0x01); osnpFrame.destinationPAN.should.deep.equal(new Buffer([0xfe, 0xca])); osnpFrame.destinationAddress.should.deep.equal(new Buffer([0xef, 0xbe])); osnpFrame.sourcePAN.should.deep.equal(new Buffer([0xfe, 0xca])); osnpFrame.sourceAddress.should.deep.equal(new Buffer([0xbe, 0xba])); osnpFrame.frameCounter.should.equal(1); osnpFrame.keyCounter.should.equal(1); osnpFrame.payload.should.deep.equal(new Buffer([0x74, 0x65, 0x73, 0x74])); }); }); describe('#encode', function() { it('should encode an OSNPFrame object to a Buffer', function() { var frame = new Buffer([0x61, 0x88, 0x01, 0xfe, 0xca, 0xef, 0xbe, 0xbe, 0xba, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00]); var osnpFrame = osnp.parseFrame(frame); osnpFrame.encode().should.deep.equal(frame.slice(0, frame.length - 2)); }); it('should encode a frame with security to a Buffer', function() { var frame = new Buffer([0x69, 0x88, 0x01, 0xfe, 0xca, 0xef, 0xbe, 0xbe, 0xba, 0x01, 0x00, 0x00, 0x00, 0x01, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00]); var osnpFrame = osnp.parseFrame(frame); osnpFrame.encode().should.deep.equal(frame.slice(0, frame.length - 2)); }); }); describe('#createFrame', function() { it('should create a frame with the given options and populate source addressing options', function() { var osnpFrame = osnp.createFrame(0x61, 0x88); osnpFrame.destinationPAN.should.deep.equal(new Buffer([0xfe, 0xca])); osnpFrame.sourcePAN.should.deep.equal(new Buffer([0xfe, 0xca])); osnpFrame.sourceAddress.should.deep.equal(new Buffer([0xbe, 0xba])); }); }); describe('#makeFrameControlLow', function() { it('should format a control low byte with the given parameters', function() { var frameControlLow = osnp.makeFrameControlLow(osnp.FrameType.DATA, false, false, true, true); frameControlLow.should.equal(0x61); }); }); describe('#makeFrameControlHigh', function() { it('should format a control high byte with the given parameters', function() { var frameControlHigh = osnp.makeFrameControlHigh(osnp.AddressingMode.SHORT_ADDRESS, osnp.AddressingMode.SHORT_ADDRESS); frameControlHigh.should.equal(0x88); }); }); });
"use strict"; require('traceur'); var textToStreamable = $traceurRuntime.assertObject(require('quiver-stream-util')).textToStreamable; var loadSimpleHandler = $traceurRuntime.assertObject(require('quiver-component')).loadSimpleHandler; var $__0 = $traceurRuntime.assertObject(require('../lib/define.js')), simpleHandler = $__0.simpleHandler, argsFilter = $__0.argsFilter, errorFilter = $__0.errorFilter, router = $__0.router; var chai = require('chai'); var chaiAsPromised = require('chai-as-promised'); chai.use(chaiAsPromised); var should = chai.should(); describe('define dsl test', (function() { it('basic test', (function() { var fooHandler = simpleHandler('my foo handler', (function(args) { args.path.should.equal('/foo'); return 'foo'; }), 'void', 'text').done(); var barHandler = simpleHandler('my bar handler', (function(args) { args.path.should.equal('/subpath'); args.id.should.equal('baz'); args.bazInjected.should.equal('baz'); return 'bar'; }), 'void', 'text').argsFilter((function(args) { args.id.should.equal('baz'); args.bazInjected = 'baz'; return args; })).done(); var mainRouter = router('my main router').staticRoute(fooHandler, '/foo').paramRoute(barHandler, '/bar/:id/:restpath').errorFilter((function(err) { return textToStreamable('error page');
before(function () { this.bowerCopy = new BowerCopy({}, {destination: 'abc', source: 'def'}); chai.should(); });
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Geohash Test Harness (c) Chris Veness 2014-2016 / MIT Licence */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 'use strict' const chai = require('chai'); // BDD/TDD assertion library const Geohash = require('./latlon-geohash.js'); const should = chai.should(); describe('latlon-geohash', function() { it('encodes Jutland', function() { Geohash.encode(57.648, 10.410, 6).should.equal('u4pruy'); }); it('decodes Jutland', function() { Geohash.decode('u4pruy').should.deep.equal({ lat: 57.648, lon: 10.410 }); }); it('encodes Curitiba', function() { Geohash.encode(-25.38262, -49.26561, 8).should.equal('6gkzwgjz'); }); it('decodes Curitiba', function() { Geohash.decode('6gkzwgjz').should.deep.equal({ lat: -25.38262, lon: -49.26561 }); }); it('fetches neighbours', function() { Geohash.neighbours('ezzz').should.deep.equal({ n:'gbpb', ne:'u000', e:'spbp', se:'spbn', s:'ezzy', sw:'ezzw', w:'ezzx', nw:'gbp8' }); }); it('matches geohash.org', function() { Geohash.encode(37.25, 123.75, 12).should.equal('wy85bj0hbp21'); }); // (also PostGIS; thx Jussi Nieminen) }); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
global.document = jsdom('<!doctype html><html><body></body></html>'); global.window = document.defaultView; global.navigator = window.navigator; function propagateToGlobal() { for (var key in window) { if (!window.hasOwnProperty(key)) continue; if (key in global) continue; global[key] = window[key]; } window.matchMedia = window.matchMedia || function () { return { matches: false, addListener: function addListener() {}, removeListener: function removeListener() {} }; }; } propagateToGlobal(); var sinon = require('sinon'); global.sinon = sinon; var chai = require('chai'); chai.use(require('sinon-chai')); global.expect = chai.expect; // https://github.com/chaijs/chai/issues/107 global.should = undefined; global.should = chai.should();
(function() { var chai = require('chai'), should = chai.should(), expect = chai.expect, sinon = require('sinon'); var AGOLGeocoder = require('../../lib/geocoder/agolgeocoder.js'); var mockedHttpAdapter = { get: function() { return {}; } }; var mockedRequestifyAdapter = { requestify: function() { return {}; }, get: function() { return {}; } }; var mockedAuthHttpAdapter = { requestify: function() { return {}; }, get: function() { return { 'err': false, 'result': { 'access_token':"ABCD", 'expires_in': 10000 } }; } }; var mockedOptions = { 'client_id': "CLIENT_ID", 'client_secret': "CLIENT_SECRET" }; describe('AGOLGeocoder', function() { describe('#constructor' , function() { it('an http adapter must be set', function() { expect(function() {new AGOLGeocoder();}).to.throw(Error, 'ArcGis Online Geocoder requires a httpAdapter to be defined'); }); it('requires requestify (for HTTPS support)', function() { expect(function() {new AGOLGeocoder(mockedHttpAdapter, {client_secret: 'CLIENT_SECRET'});}).to.throw(Error, 'The AGOL geocoder requires HTTPS support that is available in requestify'); }); it('client_id should be set', function() { expect(function() {new AGOLGeocoder(mockedRequestifyAdapter, {client_secret: 'CLIENT_SECRET'});}).to.throw(Error, 'You must specify the client_id and the client_secret'); }); it('client_secret should be set', function() { expect(function() {new AGOLGeocoder(mockedRequestifyAdapter, {client_id: 'CLIENT_ID'});}).to.throw(Error, 'You must specify the client_id and the client_secret'); }); it('expect an error if HTTPAdapter is provided while options are not', function() { expect( function() { new AGOLGeocoder(mockedRequestifyAdapter); }).to.throw( Error,'You must specify the client_id and the client_secret'); }); it('Should be an instance of AGOLGeocoder if an http adapter and proper options are supplied', function() { var geocoder = new AGOLGeocoder(mockedRequestifyAdapter, mockedOptions); geocoder.should.be.instanceof(AGOLGeocoder); }); }); describe('#geocode' , function() { it('Should not accept Ipv4', function() { var geocoder = new AGOLGeocoder(mockedRequestifyAdapter,mockedOptions); expect(function() { geocoder.geocode('127.0.0.1'); }).to.throw(Error, 'The AGOL geocoder does not support IP addresses'); }); it('Should not accept Ipv6', function() { var geocoder = new AGOLGeocoder(mockedRequestifyAdapter,mockedOptions); expect(function() { geocoder.geocode('2001:0db8:0000:85a3:0000:0000:ac1f:8001'); }).to.throw(Error, 'The AGOL geocoder does not support IP addresses'); }); it('Should call out for authentication', function() { var mock = sinon.mock(mockedAuthHttpAdapter); mock.expects('get').withArgs("https://www.arcgis.com/sharing/oauth2/token", { 'client_id': mockedOptions.client_id, 'grant_type': 'client_credentials', 'client_secret': mockedOptions.client_secret }).once().returns({then: function (err,result) {}}); var geocoder = new AGOLGeocoder(mockedAuthHttpAdapter,mockedOptions); geocoder.geocode('1 champs élysée Paris'); mock.verify(); }); it('Should return cached token', function() { var geocoder = new AGOLGeocoder(mockedAuthHttpAdapter,mockedOptions); geocoder._getToken(function(err,token) { token.should.equal("ABCD"); }); geocoder._getToken(function(err,token) { token.should.equal("ABCD"); }); }); it('Should assume cached token is invalid', function() { var geocoder = new AGOLGeocoder(mockedAuthHttpAdapter,mockedOptions); geocoder.cache.token = "AAA"; geocoder.cache.tokenExp = ((new Date).getTime() - 2000); //Verify token is old geocoder.cache.token.should.equal("AAA"); //Verify that expired token is replaced geocoder._getToken(function(err,token) { token.should.equal("ABCD"); }); }); it('Should return geocoded adress', function(done) { var mock = sinon.mock(mockedRequestifyAdapter); mock.expects('get').once().callsArgWith(2, false, '{"spatialReference":{"wkid":4326,"latestWkid":4326},"locations":[{"name":"380 New York St, Redlands, California, 92373","extent":{"xmin":-117.196701,"ymin":34.055489999999999,"xmax":-117.19470099999999,"ymax":34.057490000000001},"feature":{"geometry":{"x":-117.19566584280369,"y":34.056490727765947},"attributes":{"AddrNum":"","StPreDir":"","StName":"New York","StType":"St","City":"Redlands","Postal":"92373","Region":"California","Country":"USA"}}}]}' ); var geocoder = new AGOLGeocoder(mockedRequestifyAdapter,mockedOptions); //Force valid tokens (this was tested separately) geocoder._getToken = function(callback) { callback(false,"ABCD"); }; geocoder.geocode('380 New York St, Redlands, CA 92373', function(err, results) { err.should.to.equal(false); results[0].should.to.deep.equal({ latitude: -117.19566584280369, longitude: 34.05649072776595, country: 'USA', city: 'Redlands', state: 'California', stateCode: null, zipcode: '92373', streetName: ' New York St', streetNumber: '', countryCode: 'USA' }); mock.verify(); done(); }); }); it('Should handle a not "OK" status', function(done) { var mock = sinon.mock(mockedRequestifyAdapter); mock.expects('get').once().callsArgWith(2, false, '{"error":{"code":498,"message":"Invalid Token","details":[]}}' ); var geocoder = new AGOLGeocoder(mockedRequestifyAdapter,mockedOptions); //Force valid tokens (this was tested separately) geocoder._getToken = function(callback) { callback(false,"ABCD"); }; geocoder.geocode('380 New York St, Redlands, CA 92373', function(err, results) { //err.should.to.equal(false); err.should.to.deep.equal({"code":498,"message":"Invalid Token","details":[]}); mock.verify(); done(); }); }); }); describe('#reverse' , function() { it('Should call httpAdapter get method', function() { var mock = sinon.mock(mockedRequestifyAdapter); mock.expects('get').once().returns({then: function() {}}); var geocoder = new AGOLGeocoder(mockedRequestifyAdapter,mockedOptions); geocoder.reverse(10.0235,-2.3662); mock.verify(); }); it('Should return geocoded adress', function(done) { var mock = sinon.mock(mockedRequestifyAdapter); mock.expects('get').once().callsArgWith(2, false, '{"address":{"Address":"1190 E Kenyon Ave","Neighborhood":null,"City":"Englewood","Subregion":null,"Region":"Colorado","Postal":"80113","PostalExt":null,"CountryCode":"USA","Loc_name":"USA.PointAddress"},"location":{"x":-104.97389993455704,"y":39.649423090952013,"spatialReference":{"wkid":4326,"latestWkid":4326}}}' ); var geocoder = new AGOLGeocoder(mockedRequestifyAdapter,mockedOptions); //Force valid tokens (this was tested separately) geocoder._getToken = function(callback) { callback(false,"ABCD"); }; geocoder.reverse(-104.98469734299971,39.739146640000456, function(err, results) { err.should.to.equal(false); results[0].should.to.deep.equal({ latitude: -104.97389993455704, longitude: 39.64942309095201, country: 'USA', city: 'Englewood', state: 'Colorado', zipcode: '80113', countryCode: 'USA', address: '1190 E Kenyon Ave', neighborhood: null, loc_name: 'USA.PointAddress' }); mock.verify(); done(); }); }); it('Should handle a not "OK" status', function(done) { var mock = sinon.mock(mockedRequestifyAdapter); mock.expects('get').once().callsArgWith(2, false, '{"error":{"code":42,"message":"Random Error","details":[]}}' ); var geocoder = new AGOLGeocoder(mockedRequestifyAdapter,mockedOptions); //Force valid tokens (this was tested separately) geocoder._getToken = function(callback) { callback(false,"ABCD"); }; geocoder.reverse(40.714232,-73.9612889, function(err, results) { err.should.to.deep.equal({"code":42,"message":"Random Error","details":[]}); mock.verify(); done(); }); }); }); }); })();
import chai from 'chai'; import sinon from 'sinon'; import sinonChai from 'sinon-chai'; import promised from 'chai-as-promised'; import * as core from '../../server/core.module'; import routes from '../../server/routes/core.server.routes'; import express from 'express'; chai.use(promised); chai.use(sinonChai); let expect = chai.expect; let should = chai.should(); describe('/modules/core/server/core.module.js', () => { describe('export', () => { it('should export default', () => { return core.default.should.be.an.object; }); it('should export init', () => { return core.default.should.be.a.function; }); describe('init()', () => { let mockRoutes, app; describe('success', () => {
/* eslint-disable no-process-exit */ import gulp from "gulp"; import mocha from "gulp-mocha"; import istanbul from "gulp-babel-istanbul"; import paths from "../paths.json"; import chai from "chai"; chai.should(); // This enables should-style syntax gulp.task("test-coverage", ["build"], callback => { gulp.src(paths.source.javascript) .pipe(istanbul()) // Covering files .pipe(istanbul.hookRequire()) // Force `require` to return covered files .on("finish", () => { gulp.src(paths.source.allSpec) .pipe(mocha()) .pipe(istanbul.writeReports({dir: `${__dirname}/../coverage`, reporters: ["html", "text"]})) // Creating the reports after tests ran // .pipe(istanbul.enforceThresholds({ thresholds: { global: 100 } })) // Enforce a coverage of 100% .once("end", error => { callback(error); // Required to end the test due to // interactive CLI testing process.exit(0); }); }); });
* * TestHarness includes Test-Execution-Engine and Test-Data-Repository * * * ping 127.0.0.1 * https://semaphoreci.com/community/tutorials/getting-started-with-node-js-and-mocha * webapplog.com/tdd * chaijs.com/guide/stylis * visionmedia.github.io/superagent * visionmedia.github.io/superagent/#parsing-respons-bodies * expect(1 + 1).to.equal(2); */ var request = require("superagent"); var chai = require("chai"), assert = chai.assert, // JUnit, TDD => with/wihout - optional message expect = chai.expect, // BDD should = chai.should(); // BDD describe("### superagent-test-mean-mvc.js ==> http://localhost:3000 ###", function () { it("returns status 200 for /", function (done) { request .get("http://127.0.0.1:3000") .end(function (err, res) { // we expect error to not exist should.not.exist(err); // we expect res to exist be an object should.exist(res); res.should.be.an('object'); expect(res.status).equal(200); done(); }); });
//Unless required by applicable law or agreed to in writing, software //distributed under the License is distributed on an "AS IS" BASIS, //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //See the License for the specific language governing permissions and //limitations under the License. // /*jshint expr: true*/ 'use strict'; var rootDirectory = '../../../..'; var chai = require('chai'); var should = chai.should(); // jshint ignore:line var expect = chai.expect; var sinonChai = require('sinon-chai'); chai.use(sinonChai); var controller = require(rootDirectory + '/spa/admin/controllers/OrgLister.js'); var MockResourceServiceClassFactory = require('../../MockResourceServiceClassFactory'); describe('OrgLister controller for listing organizations', function () { it('retrieves a list of organizations and stores it in scope', function (done) { var $scope = {}; var testOrganizations = ['org1', 'org2']; controller($scope, MockResourceServiceClassFactory(testOrganizations)); // jshint ignore:line
(function() { 'use strict'; var fs = require('fs'); var request = require('request'); var sinon = require('sinon'); var chai = require('chai'); var should = chai.should(); var ICC = require('./../src/ICC.js'); describe('ICC', function() { it('should be defined', function() { ICC.should.not.be.undefined; }); describe('finger', function() { var stub; var FINGER_URL = 'http://www6.chessclub.com/finger/'; before(function(done) { stub = sinon.stub(request, 'get'); stub.yields(null, 200, ''); done(); }); after(function(done){ request.get.restore(); done(); }); it('should make a request to chessclub.com/finger', function(done) { var handle = 'handle'; ICC.finger(handle, function(exists, name, title, rating, profileUrl){ request.get.calledWith(FINGER_URL + handle).should.equal(true); done(); }); }); describe('with publicinfo', function() { var handle = 'capilanobridge'; before(function(done) { var fixture = __dirname + '/fixtures/' + handle + '.html'; fs.readFile(fixture, 'utf8', function(err, data) { if (err) { throw err; } stub.withArgs(FINGER_URL + handle).yields(null, 200, data); done(); }); }); it('should have a name, title, rating and fide profile url', function(done) { ICC.finger(handle, function(exists, name, title, rating, profileUrl) { exists.should.be.true; name.should.have.length.above(0); rating.should.have.length.above(0); profileUrl.should.not.be.undefined; done(); }); }); }); }); }); })();
'use strict'; const chai = require('chai'); const chaiAsPromised = require('chai-as-promised'); const sinonChai = require('sinon-chai'); const nock = require('nock'); chai.should(); // Enable should syntax chai.use(chaiAsPromised); chai.use(sinonChai); nock.disableNetConnect(); global.chaiAsPromised = chaiAsPromised; global.expect = chai.expect; global.AssertionError = chai.AssertionError; global.Assertion = chai.Assertion; global.assert = chai.assert;
var chai = require('chai') var sinonChai = require('sinon-chai') chai.use(sinonChai) GLOBAL.should = chai.should() GLOBAL.assert = chai.assert
it('should ignore invalid query paths against objects', () => { chai.should(new PathRef('!').use({bar: 'fail'}).get()).not.throw })
import app from '../bin/server' import supertest from 'supertest' import { expect, should } from 'chai' import { cleanDb } from './utils' should() const request = supertest.agent(app.listen()) const context = {} describe('Users', () => { before((done) => { cleanDb() done() }) describe('POST /users', () => { it('should reject signup when data is incomplete', (done) => { request .post('/users') .set('Accept', 'application/json') .send({ username: '******' }) .expect(422, done) }) it('should sign up', (done) => { request .post('/users') .set('Accept', 'application/json') .send({ user: { username: '******', password: '******' } }) .expect(200, (err, res) => { if (err) { return done(err) }
(function() { var chai = require('chai'), should = chai.should(), expect = chai.expect, sinon = require('sinon'); var OpenStreetMapGeocoder = require('../../lib/geocoder/openstreetmapgeocoder.js'); var mockedHttpAdapter = { get: function() {} }; describe('OpenStreetMapGeocoder', function() { describe('#constructor' , function() { it('an http adapter must be set', function() { expect(function() {new OpenStreetMapGeocoder();}).to.throw(Error, 'OpenStreetMapGeocoder need an httpAdapter'); }); it('Should be an instance of OpenStreetMapGeocoder', function() { var osmAdapter = new OpenStreetMapGeocoder(mockedHttpAdapter); osmAdapter.should.be.instanceof(OpenStreetMapGeocoder); }); }); describe('#geocode' , function() { it('Should not accept IPv4', function() { var osmAdapter = new OpenStreetMapGeocoder(mockedHttpAdapter); expect(function() { osmAdapter.geocode('127.0.0.1'); }).to.throw(Error, 'OpenStreetMapGeocoder does not support geocoding IPv4'); }); it('Should not accept IPv6', function() { var osmAdapter = new OpenStreetMapGeocoder(mockedHttpAdapter); expect(function() { osmAdapter.geocode('2001:0db8:0000:85a3:0000:0000:ac1f:8001'); }).to.throw(Error, 'OpenStreetMapGeocoder does not support geocoding IPv6'); }); it('Should call httpAdapter get method', function() { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().returns({then: function() {}}); var osmAdapter = new OpenStreetMapGeocoder(mockedHttpAdapter); osmAdapter.geocode('1 champs élysée Paris'); mock.verify(); }); it('Should return geocoded address', function(done) { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().callsArgWith(2, false, [{ lat: 48.86841815, lon: 2.30700964746136, address: { country_code: 'FR', country: 'France', city: 'Paris', state: '', postcode: "75008", road: 'Champs-Élysées', house_number: "1" } }] ); var osmAdapter = new OpenStreetMapGeocoder(mockedHttpAdapter); osmAdapter.geocode('1 champ-élysées Paris', function(err, results) { err.should.to.equal(false); results[0].should.to.deep.equal({ "latitude": 48.86841815, "longitude": 2.30700964746136, "country": "France", "city": "Paris", "state": "", "zipcode": "75008", "streetName": "Champs-Élysées", "streetNumber": "1", "countryCode": "FR" }); mock.verify(); done(); }); }); }); describe('#reverse' , function() { it('Should return geocoded address', function(done) { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().callsArgWith(2, false, { lat: 40.714232, lon: -73.9612889, address: { country_code: 'US', country: 'United States', city: 'Brooklyn', state: 'New York', postcode: "11211", road: 'Bedford Avenue', house_number: "277" } } ); var osmAdapter = new OpenStreetMapGeocoder(mockedHttpAdapter); osmAdapter.reverse(40.714232,-73.9612889, function(err, results) { err.should.to.equal(false); results[0].should.to.deep.equal({ "latitude": 40.714232, "longitude": -73.9612889, "country": "United States", "state": "New York", "city": "Brooklyn", "zipcode": "11211", "streetName": "Bedford Avenue", "streetNumber": "277", "countryCode": "US" }); mock.verify(); done(); }); }); }); }); })();
(function() { var chai = require('chai'), should = chai.should(), expect = chai.expect, sinon = require('sinon'); var FreegeoipGeocoder = require('../../lib/geocoder/freegeoipgeocoder.js'); var mockedHttpAdapter = { get: function() {} }; describe('FreegeoipGeocoder', function() { describe('#constructor' , function() { it('an http adapter must be set', function() { expect(function() {new FreegeoipGeocoder();}).to.throw(Error, 'FreegeoipGeocoder need an httpAdapter'); }); it('Should be an instance of FreegeoipGeocoder', function() { var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter); freegeoipgeocoder.should.be.instanceof(FreegeoipGeocoder); }); }); describe('#geocode' , function() { it('Should not accept adress', function() { var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter); expect(function() {freegeoipgeocoder.geocode('1 rue test');}) .to .throw(Error, 'FreegeoipGeocoder suport only ip geocoding'); }); it('Should call httpAdapter get method', function() { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().returns({then: function() {}}); var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter); freegeoipgeocoder.geocode('127.0.0.1'); mock.verify(); }); it('Should return a geocoded adress', function(done) { var mock = sinon.mock(mockedHttpAdapter); mock.expects('get').once().callsArgWith(2, false, { latitude: 37.386, longitude: -122.0838, country_code: 'US', country_name: 'United States', city: 'Mountain View', } ); var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter); freegeoipgeocoder.geocode('66.249.64.0', function(err, results) { err.should.to.equal(false); results[0].should.to.deep.equal({ "latitude": 37.386, "longitude": -122.0838, "country": "United States", "city": "Mountain View", "zipcode": null, "streetName": null, "streetNumber": null, "countryCode": "US" }); mock.verify(); done(); }); }); }); describe('#reverse' , function() { it('Should throw an error', function() { var freegeoipgeocoder = new FreegeoipGeocoder(mockedHttpAdapter); expect(function() {freegeoipgeocoder.reverse(10.0235,-2.3662);}) .to .throw(Error, 'FreegeoipGeocoder no support reverse geocoding'); }); }); }); })();
const mdToDraftjs = require('../src/mdToDraftjs.js').mdToDraftjs; const chai = require('chai'); const expect = chai.expect; // eslint-disable-line no-unused-vars const should = chai.should(); // eslint-disable-line no-unused-vars describe('mdToDraftjs', () => { it('returns empty text correctly', () => { const markdown = ''; const expectedDraftjs = { blocks: [{ text: '', type: 'unstyled', depth: 0, inlineStyleRanges: [], entityRanges: [] }], entityMap: { type: '', mutability: '', data: '' } }; mdToDraftjs(markdown).should.deep.equal(expectedDraftjs); }); it('returns unstyled text correctly', () => { const markdown = 'There is no styling anywhere in this text.'; const expectedDraftjs = { blocks: [{ text: 'There is no styling anywhere in this text.', type: 'unstyled',
var penthouse = require('../lib/'), chai = require('chai'), should = chai.should(),// extends Object.prototype (so ignore unused warnings) css = require('css'), fs = require('fs'), read = fs.readFileSync, path = require('path'); process.setMaxListeners(0); describe('penthouse functionality tests', function () { var page1cssPath = path.join(__dirname, 'static-server', 'page1.css'), page1 = path.join(__dirname, 'static-server', 'page1.html'); // phantomjs takes a while to start up this.timeout(5000); it('should save css to a file', function (done) { penthouse({ url: page1, css: page1cssPath }, function (err, result) { if (err) { done(err); return; } try { css.parse(result); done(); } catch (ex) { done(ex);
it('should reset previousSearchTerm and searchTermTag to null', () => { chai.should().not.exist(newState.previousSearchTerm) chai.should().not.exist(newState.searchTermTag) })
var longurl = require('../lib/longurl') , chai = require('chai') , should = chai.should() , bitlyshort = 'http://bit.ly/MNwVVo' , expectedA = 'http://joel.is/post/29186927028/how-to-name-your-startup' describe("bit.ly", function() { it("should expand", function(done) { longurl(bitlyshort, function(url) { if (!url) throw "unable to lookup " + bitlyshort; url.should.equal(expectedA); done(); }) }); it("should fail", function(done) { longurl('http://bit.ly/_FAIL_MNwVVo' + 'FAIL', done || function(url) { url.should.equal(expectedA); done(); }) }); it("should be null", function(done) { longurl('http://bit.ly/_FAIL_MNwVVoX' + 'FAIL', function(url) { (url==null).should.equal(true); done(); }) }); });
/* global describe, it*/ var chai = require('chai') var sinon = require('sinon') var sinonChai = require('sinon-chai') var _ = require('../lib/util') chai.should() chai.use(sinonChai) chai.should() describe('Test utilities', function () { it('Test isArray function', function () { _.isArray([]).should.be.true }) it('Checking object type', function () { _.type({}).should.be.equal('Object') }) it('Test each function', function () { var spy = sinon.spy() var list = [1, 2, 3, 4, 5] _.each(list, spy) spy.callCount.should.be.equal(5) }) it('Test toArray function', function () { var list = [1, 2, 3, 4, 5] var list2 = _.toArray(list) list.should.be.deep.equal(list2)
import fs from 'fs'; import Schema from '../src/schema'; import OrganizationSchema from '../src/organization-schema'; import V1 from '../src/schemas/postgres-query-v1'; import V2 from '../src/schemas/postgres-query-v2'; // import V1 from '../src/schemas/sqlite-query-v1'; // import V2 from '../src/schemas/sqlite-query-v2'; import Metadata from '../src/metadata'; import sqldiff from 'sqldiff'; import chai from 'chai'; chai.should(); const SchemaDiffer = sqldiff.SchemaDiffer; const Postgres = sqldiff.Postgres; const Sqlite = sqldiff.Sqlite; // import _ from 'underscore'; // const shouldBeNull = function(value) { // return (value === null).should.be["true"]; // }; // const shouldHaveNoValue = function(value) { // return (value === NO_VALUE).should.be["true"]; // }; // const shouldBeUndefined = function(value) { // return (value === void 0).should.be["true"]; // };
describe('MatchEndpoint Testsuite', function () { 'use strict'; const MatchEndpoint = require('../../lib/endpoints/MatchEndpoint'); const chai = require("chai"); const chaiAsPromised = require("chai-as-promised"); const should = chai.should; const expect = chai.expect; chai.use(chaiAsPromised); chai.should(); const TestUtil = require('../TestUtil'); let mergedConfig = TestUtil.getTestConfig(); const mock_summoner = TestUtil.mocks.summoners.Colorfulstan; let endpoint; beforeEach(function () { let {per10, per600, allowBursts} = mergedConfig.limits; endpoint = new MatchEndpoint(mergedConfig, TestUtil.createRateLimiter(per10, per600, allowBursts)); }); it('has its name added to default retryEndpoints', function () { endpoint.config.limits.retryEndpoints.should.include(endpoint.name); }); describe('gettingById', function () { it('Using "forAccountId" it contains the player information for the provided accountID (and ONLY that)', function () { return endpoint.gettingById(mock_summoner.gameId, mock_summoner.platformId, {forAccountId: mock_summoner.accountId, forPlatformId: mock_summoner.platformId}) .then(matchDto => { let numParticipantIdentityPlayers = 0; let participantPlayer; matchDto.participantIdentities.forEach(identity => { if (identity.player) { numParticipantIdentityPlayers++; participantPlayer = identity.player; } }); expect(numParticipantIdentityPlayers).to.equal(1); expect(participantPlayer.accountId).to.equal(mock_summoner.accountId); }); }); it('can request a specific match for an accountId', function () { return endpoint.gettingById(mock_summoner.gameId, mock_summoner.platformId) .should.eventually.have.property('gameId'); }); }); describe('gettingListByAccount', function () { it('can request the matchlist for an account', function () { return endpoint.gettingListByAccount(mock_summoner.accountId, mock_summoner.platformId) .should.eventually.have.property('matches') .an('Array') .with.length(100); }); it('can request the matchlist for multiple summoners in parallel', function () { this.timeout(0); const accountIds = [ 24885403, 42347345, 21977757, 33121340, 31385891, 28631306, 22242237 ]; const platformId = 'euw1'; function gettingFirstMatchFromMatchList(accountId, platformId){ // console.log(accountId, platformId); return endpoint.gettingListByAccount(accountId, platformId) .then(matchListDto => { // console.log(accountId, platformId); // console.log(matchListDto.matches[0]); return endpoint.gettingById(matchListDto.matches[0].gameId, matchListDto.matches[0].platformId); }); } return Promise.all([ gettingFirstMatchFromMatchList(accountIds[0], platformId), gettingFirstMatchFromMatchList(accountIds[1], platformId), gettingFirstMatchFromMatchList(accountIds[2], platformId), gettingFirstMatchFromMatchList(accountIds[3], platformId), gettingFirstMatchFromMatchList(accountIds[4], platformId), gettingFirstMatchFromMatchList(accountIds[5], platformId), gettingFirstMatchFromMatchList(accountIds[6], platformId)]).then(matchDtos => { matchDtos.forEach((matchDto, index)=>{ // console.log(accountIds[index], matchDto.participantIdentities.map(identity => identity.player)); let playerFound = matchDto.participantIdentities.find(identity => (identity.player.currentAccountId === accountIds[index] || identity.player.accountId === accountIds[index])); expect(playerFound).to.exist; }); }); }); }); describe('gettingListByAccountWithoutPagination', function () { it.skip('can request the matchlist for an account', function () { return endpoint.gettingListByAccountWithoutPagination(mock_summoner.accountId, mock_summoner.platformId) .should.eventually.have.property('matches') .an('Array') .with.length(100); }); it('can request less then 100 matches', function () { return endpoint.gettingListByAccountWithoutPagination(mock_summoner.accountId, mock_summoner.platformId, {endIndex:10}) .should.eventually.have.property('matches') .an('Array') .with.length(10); }); it('can request exactly 100 matches', function () { return endpoint.gettingListByAccountWithoutPagination(mock_summoner.accountId, mock_summoner.platformId, {beginIndex:53, endIndex:153}) .should.eventually.have.property('matches') .an('Array') .with.length(100); }); it('can request more then 100 matches', function () { this.timeout(0); return endpoint.gettingListByAccountWithoutPagination(mock_summoner.accountId, mock_summoner.platformId, {beginIndex:132, endIndex:453}) .should.eventually.have.property('matches') .an('Array') .with.length(453-132); }); it('can request the matchlist for multiple summoners in parallel', function () { this.timeout(0); const accountIds = [ 24885403, 42347345, 21977757, 33121340, 31385891, 28631306, 22242237 ]; const platformId = 'euw1'; function gettingFirstMatchFromMatchList(accountId, platformId){ // console.log(accountId, platformId); return endpoint.gettingListByAccountWithoutPagination(accountId, platformId, {endIndex:1}) .then(matchListDto => { // console.log(accountId, platformId); // console.log(matchListDto.matches[0]); return endpoint.gettingById(matchListDto.matches[0].gameId, matchListDto.matches[0].platformId); }); } return Promise.all([ gettingFirstMatchFromMatchList(accountIds[0], platformId) , gettingFirstMatchFromMatchList(accountIds[1], platformId) , gettingFirstMatchFromMatchList(accountIds[2], platformId) , gettingFirstMatchFromMatchList(accountIds[3], platformId) , gettingFirstMatchFromMatchList(accountIds[4], platformId) , gettingFirstMatchFromMatchList(accountIds[5], platformId) , gettingFirstMatchFromMatchList(accountIds[6], platformId) ]).then(matchDtos => { matchDtos.forEach((matchDto, index)=>{ // console.log(accountIds[index], matchDto.participantIdentities.map(identity => identity.player)); let playerFound = matchDto.participantIdentities.find(identity => (identity.player.currentAccountId === accountIds[index] || identity.player.accountId === accountIds[index])); expect(playerFound).to.exist; }); }); }); }); describe('gettingRecentListByAccount', function () { it('can request the most recent matches for an account', function () { return endpoint.gettingRecentListByAccount(mock_summoner.accountId, mock_summoner.platformId) .should.eventually.have.property('matches') .an('Array') .with.length.of.at.most(20); }); }); describe('gettingTimelineById', function () { it('can request the timeline for a given match', function () { return endpoint.gettingTimelineById(mock_summoner.gameId, mock_summoner.platformId) .should.eventually.have.property('frames'); }); }); describe.skip('Tournament related', function () { describe('gettingIdsByTournament', function () { // TODO: get tournament api-key to test this it('can request the match ids for a tournament', function () { // return endpoint.gettingIdsByTournament(..., ...) // .should.eventually.be.an('Array'); }); }); describe('gettingByIdForTournament', function () { // TODO: get tournament api-key to test this it('can request a match within a tournament', function () { // return endpoint.gettingIdsByTournament(..., ...) // .should.eventually.be.an('Array'); }); }); }); });