@@ -7,6 +7,7 @@ describe("pokedex", { timeout: 30000 }, function () {
77 let p2 ;
88
99 const id = 2 ;
10+ const string = 'pokemon/33' ;
1011 const path = '/api/v2/pokemon/34' ;
1112 const url = 'https://pokeapi.co/api/v2/pokemon/35' ;
1213 const interval = { limit : 10 , offset : 34 } ;
@@ -31,6 +32,36 @@ describe("pokedex", { timeout: 30000 }, function () {
3132 } ) ;
3233 } ) ;
3334
35+ // --- Resource Methods ---
36+ describe ( ".resource()" , function ( ) {
37+ it ( "should succeed with a single path" , async function ( ) {
38+ const res = await p1 . resource ( path ) ;
39+ assert . ok ( res . height , "Response should have height" ) ;
40+ } ) ;
41+ it ( "should succeed with a single path" , async function ( ) {
42+ const res = await p1 . resource ( string ) ;
43+ assert . ok ( res . height , "Response should have height" ) ;
44+ } ) ;
45+ it ( "should succeed with an array of paths" , async function ( ) {
46+ const res = await p1 . resource ( [ path , url , string ] ) ;
47+ assert . strictEqual ( res . length , 3 ) ;
48+ assert . ok ( res [ 0 ] . height , 'Should have property height' ) ;
49+ assert . ok ( res [ 1 ] . height , 'Should have property height' ) ;
50+ assert . ok ( res [ 2 ] . height , 'Should have property height' ) ;
51+ } ) ;
52+ it ( "should succeed with an array of paths with trailing /" , async function ( ) {
53+ const res = await p1 . resource ( [ `${ path } /` , `${ url } /` , `${ string } /` ] ) ;
54+ assert . strictEqual ( res . length , 3 ) ;
55+ assert . ok ( res [ 0 ] . height , 'Should have property height' ) ;
56+ assert . ok ( res [ 1 ] . height , 'Should have property height' ) ;
57+ assert . ok ( res [ 2 ] . height , 'Should have property height' ) ;
58+ } ) ;
59+ it ( "should fail with an invalid path" , async function ( ) {
60+ const result = await p1 . resource ( 123 ) ;
61+ assert . strictEqual ( result , "String or Array is required" ) ;
62+ } ) ;
63+ } ) ;
64+
3465 // --- List Methods ---
3566 describe ( ".getPokemonsList()" , function ( ) {
3667 it ( "should succeed with default interval" , async function ( ) {
@@ -49,4 +80,26 @@ describe("pokedex", { timeout: 30000 }, function () {
4980 ) ;
5081 } ) ;
5182 } ) ;
83+
84+ // --- IndexedDB ---
85+ describe ( "IndexedDB" , function ( ) {
86+ it ( ".getCacheLength() should throw an error" , async function ( ) {
87+ await assert . rejects (
88+ p1 . getCacheLength ( ) ,
89+ Error
90+ ) ;
91+ } ) ;
92+ it ( ".clearCache() should throw an error" , async function ( ) {
93+ await assert . rejects (
94+ p1 . clearCache ( ) ,
95+ Error
96+ ) ;
97+ } ) ;
98+ it ( ".invalidateCache() should throw an error" , async function ( ) {
99+ await assert . rejects (
100+ p1 . invalidateCache ( ) ,
101+ Error
102+ ) ;
103+ } ) ;
104+ } ) ;
52105} ) ;
0 commit comments