luma.gl/test/webgl/texture.spec.js
2017-03-15 11:24:00 -07:00

39 lines
949 B
JavaScript

import test from 'tape-catch';
import {createGLContext, Texture2D} from '../../dist/headless';
const fixture = {
gl: createGLContext()
};
test('WebGL#Texture2D construct/delete', t => {
const {gl} = fixture;
t.throws(
() => new Texture2D(),
/.*WebGLRenderingContext.*/,
'Texture2D throws on missing gl context');
const texture = new Texture2D(gl);
t.ok(texture instanceof Texture2D, 'Texture2D construction successful');
texture.delete();
t.ok(texture instanceof Texture2D, 'Texture2D delete successful');
texture.delete();
t.ok(texture instanceof Texture2D, 'Texture2D repeated delete successful');
t.end();
});
test('WebGL#Texture2D buffer update', t => {
const {gl} = fixture;
let texture = new Texture2D(gl);
t.ok(texture instanceof Texture2D, 'Texture2D construction successful');
texture = texture.delete();
t.ok(texture instanceof Texture2D, 'Texture2D delete successful');
t.end();
});