@@ -393,4 +393,86 @@ describe("loader", () => {
393393 expect ( loader . unload ( { name : "nope" , type : "tmx" } ) ) . toBe ( false ) ;
394394 expect ( loader . unload ( { name : "nope" , type : "video" } ) ) . toBe ( false ) ;
395395 } ) ;
396+
397+ it ( "should call onerror for invalid image sources" , async ( ) => {
398+ await expect (
399+ new Promise ( ( resolve , reject ) => {
400+ loader . load (
401+ {
402+ name : "bad_image" ,
403+ type : "image" ,
404+ src : "nonexistent/path/image.png" ,
405+ } ,
406+ ( ) => {
407+ reject ( new Error ( "should not succeed" ) ) ;
408+ } ,
409+ ( ) => {
410+ resolve ( true ) ;
411+ } ,
412+ ) ;
413+ } ) ,
414+ ) . resolves . toBe ( true ) ;
415+ } ) ;
416+
417+ it ( "should call onerror for invalid JSON sources" , async ( ) => {
418+ await expect (
419+ new Promise ( ( resolve , reject ) => {
420+ loader . load (
421+ {
422+ name : "bad_json" ,
423+ type : "json" ,
424+ src : "nonexistent/path/data.json" ,
425+ } ,
426+ ( ) => {
427+ reject ( new Error ( "should not succeed" ) ) ;
428+ } ,
429+ ( ) => {
430+ resolve ( true ) ;
431+ } ,
432+ ) ;
433+ } ) ,
434+ ) . resolves . toBe ( true ) ;
435+ } ) ;
436+
437+ it ( "should call onerror for invalid binary sources" , async ( ) => {
438+ await expect (
439+ new Promise ( ( resolve , reject ) => {
440+ loader . load (
441+ {
442+ name : "bad_binary" ,
443+ type : "binary" ,
444+ src : "nonexistent/path/data.bin" ,
445+ } ,
446+ ( ) => {
447+ reject ( new Error ( "should not succeed" ) ) ;
448+ } ,
449+ ( ) => {
450+ resolve ( true ) ;
451+ } ,
452+ ) ;
453+ } ) ,
454+ ) . resolves . toBe ( true ) ;
455+ } ) ;
456+
457+ it ( "should handle inline TMX data and return 1" , ( ) => {
458+ const result = loader . load (
459+ {
460+ name : "inline_tmx" ,
461+ type : "tmx" ,
462+ data : {
463+ width : 1 ,
464+ height : 1 ,
465+ tilewidth : 32 ,
466+ tileheight : 32 ,
467+ orientation : "orthogonal" ,
468+ renderorder : "right-down" ,
469+ version : "1.10" ,
470+ layers : [ ] ,
471+ tilesets : [ ] ,
472+ } ,
473+ } ,
474+ ( ) => { } ,
475+ ) ;
476+ expect ( result ) . toBe ( 1 ) ;
477+ } ) ;
396478} ) ;
0 commit comments