1'use strict'; 2 3import { Asset } from 'expo-asset'; 4 5export const name = 'Asset'; 6 7export async function test(t) { 8 t.describe(name, () => { 9 [ 10 { 11 module: require('../assets/black-128x256.png'), 12 name: 'black-128x256', 13 type: 'png', 14 width: 128, 15 height: 256, 16 }, 17 { 18 module: require('../assets/comic.ttf'), 19 name: 'comic', 20 type: 'ttf', 21 }, 22 ].forEach(({ module, name, type, ...more }) => 23 t.describe(`${name}.${type}`, () => { 24 t.it(`has correct name, type, ${Object.keys(more).join(', ')}`, async () => { 25 const asset = Asset.fromModule(module); 26 await asset.downloadAsync(); 27 t.expect(asset.name).toMatch(new RegExp(`${name}.*\.${type}`)); 28 t.expect(asset.type).toBe(type); 29 console.log(asset); 30 Object.keys(more).forEach((member) => t.expect(asset[member]).toBe(more[member])); 31 }); 32 33 t.it("when downloaded, has a 'file://' localUri", async () => { 34 const asset = Asset.fromModule(module); 35 await asset.downloadAsync(); 36 t.expect(asset.localUri).toMatch(new RegExp(`.*\.${type}`)); 37 }); 38 }) 39 ); 40 }); 41} 42