-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(native): add test coverage for polyfills
- Loading branch information
1 parent
f1e22d6
commit dc37659
Showing
5 changed files
with
65 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
export const readAsStringAsync = async () => new Promise((res) => res('')) | ||
export const EncodingType = { UTF8: 'utf8', Base64: 'base64' } | ||
export const cacheDirectory = 'file:///test/' | ||
export const readAsStringAsync = async () => '' | ||
export const writeAsStringAsync = async () => {} | ||
export const copyAsync = async () => {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as THREE from 'three' | ||
import { polyfills } from '../../src/native/polyfills' | ||
|
||
polyfills() | ||
|
||
const pixel = | ||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=' | ||
|
||
describe('polyfills', () => { | ||
it('loads images via data textures', async () => { | ||
const texture = await new THREE.TextureLoader().loadAsync(pixel) | ||
expect((texture as any).isDataTexture).toBe(true) | ||
expect(texture.image.width).toBe(1) | ||
expect(texture.image.height).toBe(1) | ||
}) | ||
|
||
it('creates a safe image URI for JSI', async () => { | ||
const texture = await new THREE.TextureLoader().loadAsync(pixel) | ||
expect(texture.image.data.localUri.startsWith('file:///')).toBe(true) | ||
}) | ||
|
||
it('unpacks drawables in Android APK', async () => { | ||
const texture = await new THREE.TextureLoader().loadAsync('drawable.png') | ||
expect(texture.image.data.localUri.includes(':')).toBe(true) | ||
}) | ||
|
||
it('loads files via the file system', async () => { | ||
const asset = 1 | ||
const file = await new THREE.FileLoader().loadAsync(asset as any) | ||
expect(typeof (file as ArrayBuffer).byteLength).toBe('number') // TODO: ArrayBuffer instanceof | ||
}) | ||
|
||
it('loads files via http', async () => { | ||
const file = await new THREE.FileLoader().loadAsync('https://example.com/test.png') | ||
expect(typeof (file as ArrayBuffer).byteLength).toBe('number') // TODO: ArrayBuffer instanceof | ||
}) | ||
}) |