.then((data) => { assert.isNotEmpty(data); data.forEach((pin) => assertPin(pin)); const poi = data.filter((pin) => pin.type === dvb.PIN_TYPE.poi); const ticketmachine = data.filter( (pin) => pin.type === dvb.PIN_TYPE.ticketmachine ); const stop = data.filter((pin) => pin.type === dvb.PIN_TYPE.stop); assert.isNotEmpty(poi); assert.isNotEmpty(ticketmachine); assert.isNotEmpty(stop); assert.strictEqual( poi.length + ticketmachine.length + stop.length, data.length ); }));
it("convertCoordinates", () => { const points = utils.convertCoordinates( `${gk4[0]}|${gk4[1]}|${gk4[0]}|${gk4[1]}|` ); assert.isNotEmpty(points); points.forEach(assertCoords); });
.then((data) => { assert.isNotEmpty(data); data.forEach((pin) => assertPin(pin)); const platform = data.filter( (pin) => pin.type === dvb.PIN_TYPE.platform ); const ticketmachine = data.filter( (pin) => pin.type === dvb.PIN_TYPE.ticketmachine ); assert.isNotEmpty(platform); assert.isNotEmpty(ticketmachine); assert.strictEqual( platform.length + ticketmachine.length, data.length ); }));
export function assertPin(pin: IPin, type?: PIN_TYPE) { assert.isObject(pin); assertNotEmptyString(pin.type); if (type) { assert.strictEqual(pin.type, type); } assertNotEmptyString(pin.name); assertCoords(pin.coords); if (pin.type === PIN_TYPE.platform) { assert.isString(pin.id); assertNotEmptyString(pin.platform_nr); } else { assertNotEmptyString(pin.id); assert.isUndefined(pin.platform_nr); } if (pin.type === PIN_TYPE.stop) { assert.isArray(pin.connections); if (pin.name !== "Ebertplatz") { assert.isNotEmpty(pin.connections); } pin.connections!.forEach(assertConnection); } else { assert.isUndefined(pin.connections); } if (pin.type === PIN_TYPE.parkandride) { assertNotEmptyString(pin.info); } else { assert.isUndefined(pin.info); } }
it('read', async () => { const diceWare = (await DiceWareDispatcher.get())[0]; assert.isNotEmpty(diceWare.fname); assert.isTrue(diceWare.diceCount == 5); assert.isTrue(diceWare.diceWare.size > 100); assert.isTrue(!!Array.from(diceWare.diceWare.values()).find(d => d.password == 'voice')); });
dvb.findStop("Markt").then((data) => { assert.isNotEmpty(data); data.forEach((point) => { assertPoint(point); assert.strictEqual(point.type, dvb.POI_TYPE.Stop); }); }));
it('persists original errors without a result', () => { const result = { errors: [new GraphQLError('Test error')] }; try { checkResultAndHandleErrors(result, {} as GraphQLResolveInfo, 'responseKey'); } catch (e) { assert.equal(e.message, 'Test error'); assert.isNotEmpty(e.originalError); assert.isNotEmpty(e.originalError.errors); assert.lengthOf(e.originalError.errors, result.errors.length); result.errors.forEach((error, i) => { assert.deepEqual(e.originalError.errors[i], error); }); } });
.then((pins) => { assert.isNotEmpty(pins); pins.forEach((pin) => assertPin(pin, dvb.PIN_TYPE.poi)); return dvb.coords(pins[0].id).then((coords) => { assert.deepEqual(coords, pins[0].coords); }); }));
function assertNode(node: INode) { assert.isString(node.direction); assert.isNumber(node.duration); assertMode(node.mode); if ( node.mode.name !== "Footpath" && node.mode.name !== "StayForConnection" && node.mode.name.indexOf("Stairs") === -1 ) { assert.isDefined(node.diva); assertDiva(node.diva!); assertNotEmptyString(node.line); } else { assert.isUndefined(node.diva); assert.isString(node.line); } if ( (node.mode.name === "Footpath" && !node.departure) || node.mode.name.indexOf("Stairs") > -1 ) { assert.isUndefined(node.departure); assert.isUndefined(node.arrival); assert.isArray(node.stops); assert.isEmpty(node.stops); } else { assertStopLocation(node.departure!); assertStopLocation(node.arrival!); assert.isArray(node.stops); assert.isNotEmpty(node.stops); node.stops.forEach(assertStop); } assert.isArray(node.path); if (node.mode.name !== "StayForConnection") { assert.isNotEmpty(node.path); node.path.forEach(assertCoords); } else { assert.isEmpty(node.path); } }
it("node duration should not always be 0", () => { assert.isNotEmpty(data.trips); data.trips.forEach((trip) => { let durationSum = 0; trip.nodes.forEach((node) => { durationSum += node.duration; }); assert.notEqual(0, durationSum); }); });