UNPKG

digipinjs

Version:

A comprehensive TypeScript library for encoding and decoding Indian geographic coordinates into DIGIPIN format (Indian Postal Digital PIN system). Features CLI tools, caching, batch processing, and Express middleware for seamless integration.

48 lines (47 loc) 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const geo_1 = require("../geo"); // Distance Validator tools // https://dac.indiapost.gov.in/mydigipin/home // https://www.gps-coordinates.net/distance describe('DigiPin Geo Functions', () => { describe('getDistance', () => { it('should return distance between two geoCodes', () => { const start = '422-35T-M8JT'; //AIG Hospital Hyd const end = '422-36L-P6J9'; //Raidurg Metro Hyd const result = (0, geo_1.getDistance)(start, end); (0, chai_1.expect)(result).to.equal(1168); }); }); describe('getPreciseDistance', () => { it('should return precise distance between two geoCodes', () => { const start = '422-35T-M8JT'; //AIG Hospital Hyd const end = '422-36L-P6J9'; //Raidurg Metro Hyd const result = (0, geo_1.getPreciseDistance)(start, end); (0, chai_1.expect)(result).to.equal(1169); }); }); describe('orderByDistance', () => { it('should return geoCodes in sorted order', () => { const start = '422-35T-M8JT'; //AIG Hospital Hyd const ends = [ '422-363-53LJ', //Yashoda Hospitals Hitech City Hyd (Second) '422-36L-P6J9', //Raidurg Metro Hyd (First) ]; const result = (0, geo_1.orderByDistance)(start, ends); (0, chai_1.expect)(result).to.deep.equal(['422-36L-P6J9', '422-363-53LJ']); }); }); describe('findNearest', () => { it('should return geoCodes in nearest geoCode', () => { const start = '422-35T-M8JT'; //AIG Hospital Hyd const ends = [ '422-363-53LJ', //Yashoda Hospitals Hitech City Hyd (Second) '422-36L-P6J9', //Raidurg Metro Hyd (First) ]; const result = (0, geo_1.findNearest)(start, ends); (0, chai_1.expect)(result).to.deep.equal('422-36L-P6J9'); }); }); });