@@ -16,6 +16,7 @@ test('constructor', t => {
1616 * @typedef {object } AssetTestInfo
1717 * @property {AssetType } type - The type of the asset.
1818 * @property {string } id - The asset's unique ID.
19+ * @property {DataFormat } [ext] - Optional: the asset's data format / file extension.
1920 */
2021const testAssets = [
2122 {
@@ -33,11 +34,29 @@ const testAssets = [
3334 id : 'f88bf1935daea28f8ca098462a31dbb0' , // cat1-a
3435 md5 : 'f88bf1935daea28f8ca098462a31dbb0'
3536 } ,
37+ {
38+ type : storage . AssetType . ImageVector ,
39+ id : '6e8bd9ae68fdb02b7e1e3df656a75635' , // cat1-b
40+ md5 : '6e8bd9ae68fdb02b7e1e3df656a75635' ,
41+ ext : storage . DataFormat . SVG
42+ } ,
3643 {
3744 type : storage . AssetType . ImageBitmap ,
3845 id : '7e24c99c1b853e52f8e7f9004416fa34' , // squirrel
3946 md5 : '7e24c99c1b853e52f8e7f9004416fa34'
4047 } ,
48+ {
49+ type : storage . AssetType . ImageBitmap ,
50+ id : '66895930177178ea01d9e610917f8acf' , // bus
51+ md5 : '66895930177178ea01d9e610917f8acf' ,
52+ ext : storage . DataFormat . PNG
53+ } ,
54+ {
55+ type : storage . AssetType . ImageBitmap ,
56+ id : 'fe5e3566965f9de793beeffce377d054' , // building at MIT
57+ md5 : 'fe5e3566965f9de793beeffce377d054' ,
58+ ext : storage . DataFormat . JPG
59+ } ,
4160 {
4261 type : storage . AssetType . Sound ,
4362 id : '83c36d806dc92327b9e7049a565c6bff' , // meow
@@ -59,7 +78,7 @@ test('addWebSource', t => {
5978 t . doesNotThrow ( ( ) => {
6079 storage . addWebSource (
6180 [ storage . AssetType . ImageVector , storage . AssetType . ImageBitmap , storage . AssetType . Sound ] ,
62- asset => `https://cdn.assets.scratch.mit.edu/internalapi/asset/${ asset . assetId } .${ asset . assetType . runtimeFormat } /get/`
81+ asset => `https://cdn.assets.scratch.mit.edu/internalapi/asset/${ asset . assetId } .${ asset . dataFormat } /get/`
6382 ) ;
6483 } ) ;
6584 t . end ( ) ;
@@ -82,12 +101,11 @@ test('load', t => {
82101 for ( var i = 0 ; i < testAssets . length ; ++ i ) {
83102 const assetInfo = testAssets [ i ] ;
84103
85- const promise = storage . load ( assetInfo . type , assetInfo . id ) ;
104+ var promise = storage . load ( assetInfo . type , assetInfo . id , assetInfo . ext ) ;
86105 t . type ( promise , 'Promise' ) ;
87106
107+ promise = promise . then ( asset => checkAsset ( assetInfo , asset ) ) ;
88108 promises . push ( promise ) ;
89-
90- promise . then ( asset => checkAsset ( assetInfo , asset ) ) ;
91109 }
92110
93111 return Promise . all ( promises ) ;
0 commit comments