1- import { AGPSMessage , SCHEMA_VERSION , verify } from '../src/verify-agps-data'
2- import { apiClient , tokenAuthorization } from './api-client'
1+ import { AGPSMessage , SCHEMA_VERSION , verify } from '../src/verify-agps-data.js'
2+ import { apiClient , tokenAuthorization } from './api-client.js'
3+ import { describe , it } from 'node:test'
4+ import assert from 'node:assert/strict'
35
46const { getBinary, head } = apiClient ( {
57 endpoint : process . env . API_HOST ,
@@ -11,9 +13,9 @@ const { getBinary, head } = apiClient({
1113 } ) ,
1214} )
1315
14- describe ( 'AGPS' , ( ) => {
15- describe ( 'chunking' , ( ) => {
16- describe ( 'use HEAD request to get response size' , ( ) => {
16+ void describe ( 'AGPS' , ( ) => {
17+ void describe ( 'chunking' , ( ) => {
18+ void describe ( 'use HEAD request to get response size' , ( ) => {
1719 const agpsReq = {
1820 deviceIdentifier : 'TestClient' ,
1921 mcc : 242 ,
@@ -24,14 +26,14 @@ describe('AGPS', () => {
2426 }
2527 let chunkSize : number
2628
27- it ( 'should describe length of A-GPS data' , async ( ) => {
29+ void it ( 'should describe length of A-GPS data' , async ( ) => {
2830 const res = await head ( { resource : 'location/agps' , payload : agpsReq } )
29- chunkSize = parseInt ( res [ 'content-length' ] ?? '0' , 10 )
30- expect ( chunkSize ) . toBeGreaterThan ( 0 )
31+ chunkSize = parseInt ( res . get ( 'content-length' ) ?? '0' , 10 )
32+ assert . equal ( chunkSize > 0 , true )
3133 } )
3234
33- it ( 'should return A-GPS data' , async ( ) => {
34- expect ( chunkSize ) . toBeGreaterThan ( 0 ) // chunk size should have been set
35+ void it ( 'should return A-GPS data' , async ( ) => {
36+ assert . equal ( chunkSize > 0 , true ) // chunk size should have been set
3537 const res = await getBinary ( {
3638 resource : 'location/agps' ,
3739 payload : agpsReq ,
@@ -40,15 +42,15 @@ describe('AGPS', () => {
4042 Range : `bytes=0-${ chunkSize } ` ,
4143 } ,
4244 } )
43- expect ( res . length ) . toBe ( chunkSize )
45+ assert . equal ( res . length , chunkSize )
4446
4547 // Verify response
4648 const verified = verify ( res )
47- expect ( 'error' in verified ) . toEqual ( false )
48- expect ( ( verified as AGPSMessage ) . schemaVersion ) . toEqual ( SCHEMA_VERSION )
49+ assert . equal ( 'error' in verified , false )
50+ assert . equal ( ( verified as AGPSMessage ) . schemaVersion , SCHEMA_VERSION )
4951 } )
5052
51- it ( 'should chunk large responses' , async ( ) => {
53+ void it ( 'should chunk large responses' , async ( ) => {
5254 const res = await getBinary ( {
5355 resource : 'location/agps' ,
5456 payload : {
@@ -64,23 +66,22 @@ describe('AGPS', () => {
6466 Range : `bytes=0-2000` ,
6567 } ,
6668 } )
67- expect ( res . length ) . toBeLessThan ( 2000 )
69+ assert . equal ( res . length < 2000 , true )
6870
6971 // Verify response
7072 const verified = verify ( res )
71- expect ( 'error' in verified ) . toEqual ( false )
72- expect ( ( verified as AGPSMessage ) . schemaVersion ) . toEqual ( SCHEMA_VERSION )
73- expect ( ( verified as AGPSMessage ) . entries ) . toHaveLength ( 1 )
74- expect ( ( verified as AGPSMessage ) . entries [ 0 ] . type ) . toEqual ( 2 )
75- expect ( ( verified as AGPSMessage ) . entries [ 0 ] . items ) . toBeGreaterThan ( 0 )
73+ assert . equal ( 'error' in verified , false )
74+ assert . equal ( ( verified as AGPSMessage ) . schemaVersion , SCHEMA_VERSION )
75+ assert . equal ( ( verified as AGPSMessage ) . entries . length , 1 )
76+ assert . equal ( ( verified as AGPSMessage ) . entries [ 0 ] . type , 2 )
77+ assert . equal ( ( verified as AGPSMessage ) . entries [ 0 ] . items > 0 , true )
7678 } )
7779 } )
7880 } )
7981
80- describe ( 'should support 8 types' , ( ) => {
81- it . each ( [ [ 1 ] , [ 2 ] , [ 3 ] , [ 4 ] , [ 6 ] , [ 7 ] , [ 8 ] , [ 9 ] ] ) (
82- 'should resolve custom type %d' ,
83- async ( type ) => {
82+ void describe ( 'should support 8 types' , ( ) => {
83+ for ( const type of [ 1 , 2 , 3 , 4 , 6 , 7 , 8 , 9 ] ) {
84+ void it ( `should resolve custom type ${ type } ` , async ( ) => {
8485 const agpsReq = {
8586 mcc : 242 ,
8687 mnc : 2 ,
@@ -94,8 +95,8 @@ describe('AGPS', () => {
9495 resource : 'location/agps' ,
9596 payload : agpsReq ,
9697 } )
97- const chunkSize = parseInt ( headRes [ 'content-length' ] ?? '0' , 10 )
98- expect ( chunkSize ) . toBeGreaterThan ( 0 )
98+ const chunkSize = parseInt ( headRes . get ( 'content-length' ) ?? '0' , 10 )
99+ assert . equal ( chunkSize > 0 , true )
99100
100101 const res = await getBinary ( {
101102 resource : 'location/agps' ,
@@ -105,20 +106,20 @@ describe('AGPS', () => {
105106 Range : `bytes=0-${ chunkSize } ` ,
106107 } ,
107108 } )
108- expect ( res . length ) . toEqual ( chunkSize )
109+ assert . equal ( res . length , chunkSize )
109110
110111 // Verify response
111112 const verified = verify ( res )
112- expect ( 'error' in verified ) . toEqual ( false )
113- expect ( ( verified as AGPSMessage ) . schemaVersion ) . toEqual ( SCHEMA_VERSION )
114- expect ( ( verified as AGPSMessage ) . entries ) . toHaveLength ( 1 )
115- expect ( ( verified as AGPSMessage ) . entries [ 0 ] . type ) . toEqual ( type )
116- expect ( ( verified as AGPSMessage ) . entries [ 0 ] . items ) . toBeGreaterThan ( 0 )
117- } ,
118- )
113+ assert . equal ( 'error' in verified , false )
114+ assert . equal ( ( verified as AGPSMessage ) . schemaVersion , SCHEMA_VERSION )
115+ assert . equal ( ( verified as AGPSMessage ) . entries . length , 1 )
116+ assert . equal ( ( verified as AGPSMessage ) . entries [ 0 ] . type , type )
117+ assert . equal ( ( verified as AGPSMessage ) . entries [ 0 ] . items > 0 , true )
118+ } )
119+ }
119120 } )
120121
121- it ( 'should combine types' , async ( ) => {
122+ void it ( 'should combine types' , async ( ) => {
122123 const types = new Set ( [ 1 , 3 , 4 , 6 , 7 , 8 , 9 ] )
123124 const agpsReq = {
124125 mcc : 242 ,
@@ -133,8 +134,8 @@ describe('AGPS', () => {
133134 resource : 'location/agps' ,
134135 payload : agpsReq ,
135136 } )
136- const chunkSize = parseInt ( headRes [ 'content-length' ] ?? '0' , 10 )
137- expect ( chunkSize ) . toBeGreaterThan ( 0 )
137+ const chunkSize = parseInt ( headRes . get ( 'content-length' ) ?? '0' , 10 )
138+ assert . equal ( chunkSize > 0 , true )
138139
139140 const res = await getBinary ( {
140141 resource : 'location/agps' ,
@@ -144,15 +145,16 @@ describe('AGPS', () => {
144145 Range : `bytes=0-${ chunkSize } ` ,
145146 } ,
146147 } )
147- expect ( res . length ) . toEqual ( chunkSize )
148+ assert . equal ( res . length , chunkSize )
148149
149150 // Verify response
150151 const verified = verify ( res )
151- expect ( 'error' in verified ) . toEqual ( false )
152- expect ( ( verified as AGPSMessage ) . schemaVersion ) . toEqual ( SCHEMA_VERSION )
153- expect ( ( verified as AGPSMessage ) . entries ) . toHaveLength ( 7 )
154- expect (
152+ assert . equal ( 'error' in verified , false )
153+ assert . equal ( ( verified as AGPSMessage ) . schemaVersion , SCHEMA_VERSION )
154+ assert . equal ( ( verified as AGPSMessage ) . entries . length , 7 )
155+ assert . deepEqual (
155156 new Set ( ( verified as AGPSMessage ) . entries . map ( ( { type } ) => type ) ) ,
156- ) . toEqual ( types )
157+ types ,
158+ )
157159 } )
158160} )
0 commit comments