11import { Config } from '../../src/utils/config' ;
2+ import { DataAPI , ResourceType } from '../../src/utils/data-api' ;
23import {
3- AgentRunError ,
44 HTTPError ,
5- ResourceNotExistError ,
65 ResourceAlreadyExistError ,
7- ClientError ,
6+ ResourceNotExistError ,
87} from '../../src/utils/exception' ;
9- import * as model from '../../src/utils/model' ;
10- import { mixin } from '../../src/utils/mixin' ;
118import {
12- updateObjectProperties ,
139 listAllResourcesFunction ,
14- ResourceBase ,
10+ updateObjectProperties ,
1511} from '../../src/utils/resource' ;
16- import { DataAPI , ResourceType } from '../../src/utils/data-api' ;
1712
1813describe ( 'utils - config' , ( ) => {
1914 test ( 'config defaults and data/control/devs endpoints and accountId error' , ( ) => {
@@ -59,25 +54,6 @@ describe('utils - exception', () => {
5954 } ) ;
6055} ) ;
6156
62-
63- describe ( 'utils - mixin' , ( ) => {
64- test ( 'mixin copies prototype and static properties' , ( ) => {
65- class A {
66- static staticA = 1 ;
67- protoA ( ) { return 'a' ; }
68- }
69-
70- class B { }
71-
72- const Mixed = mixin ( A as any , B as any ) as any ;
73- // static prop copied
74- expect ( Mixed . staticA ) . toBe ( 1 ) ;
75- // prototype method available
76- const inst = new Mixed ( ) ;
77- expect ( typeof inst . protoA ) . toBe ( 'function' ) ;
78- } ) ;
79- } ) ;
80-
8157describe ( 'utils - resource helpers' , ( ) => {
8258 test ( 'updateObjectProperties only copies data fields' , ( ) => {
8359 const target : any = { } ;
@@ -91,8 +67,13 @@ describe('utils - resource helpers', () => {
9167 test ( 'listAllResourcesFunction paginates and dedups' , async ( ) => {
9268 // listAllResourcesFunction uses a pageSize of 50 internally.
9369 // To exercise pagination we return 50 items on first call and a small last page on second.
94- const firstPage = Array . from ( { length : 50 } , ( _ , i ) => ( { uniqIdCallback : ( ) => `${ i + 1 } ` } ) ) ;
95- const secondPage = [ { uniqIdCallback : ( ) => '50' } , { uniqIdCallback : ( ) => '51' } ] ;
70+ const firstPage = Array . from ( { length : 50 } , ( _ , i ) => ( {
71+ uniqIdCallback : ( ) => `${ i + 1 } ` ,
72+ } ) ) ;
73+ const secondPage = [
74+ { uniqIdCallback : ( ) => '50' } ,
75+ { uniqIdCallback : ( ) => '51' } ,
76+ ] ;
9677 const pages = [ firstPage , secondPage ] ;
9778 let called = 0 ;
9879 const list = async ( params ?: any ) => {
@@ -120,14 +101,29 @@ describe('utils - data-api small surface', () => {
120101 const cfg = new Config ( { token : 'tok' , accountId : 'acct' } ) ;
121102 const d = new DataAPI ( 'name' , ResourceType . Runtime , cfg , 'ns' ) as any ;
122103
123- const r1 = await d . prepareRequest ( 'POST' , 'https://example.com/x' , { a : 1 } , { H : 'v' } ) ;
104+ const r1 = await d . prepareRequest (
105+ 'POST' ,
106+ 'https://example.com/x' ,
107+ { a : 1 } ,
108+ { H : 'v' }
109+ ) ;
124110 expect ( r1 . body ) . toBeDefined ( ) ;
125111 expect ( r1 . headers [ 'Agentrun-Access-Token' ] ) . toBe ( 'tok' ) ;
126112
127- const r2 = await d . prepareRequest ( 'PUT' , 'https://example.com/x' , Buffer . from ( 'hi' ) , { } ) ;
113+ const r2 = await d . prepareRequest (
114+ 'PUT' ,
115+ 'https://example.com/x' ,
116+ Buffer . from ( 'hi' ) ,
117+ { }
118+ ) ;
128119 expect ( Buffer . isBuffer ( r2 . body ) ) . toBe ( true ) ;
129120
130- const r3 = await d . prepareRequest ( 'PATCH' , 'https://example.com/x' , 'rawtext' , { } ) ;
121+ const r3 = await d . prepareRequest (
122+ 'PATCH' ,
123+ 'https://example.com/x' ,
124+ 'rawtext' ,
125+ { }
126+ ) ;
131127 expect ( r3 . body ) . toBe ( 'rawtext' ) ;
132128 } ) ;
133129} ) ;
0 commit comments