/** * @jest-environment node */ import * as fs from 'fs' import * as path from 'path' import { parseLut } from '../src' import { Lut } from '../src/typings' let lut: Lut describe('Parsing an Adobe .cube file', () => { const filePath = path.resolve(__dirname, './example.CUBE') const cube = fs.readFileSync(filePath) it('From a buffer', async () => { lut = await parseLut(cube) expect(lut).toBeDefined() }) it('From an ArrayBuffer', async () => { lut = await parseLut(cube.buffer) expect(lut).toBeDefined() }) it('From a Uint8Array', async () => { lut = await parseLut(new Uint8Array(cube.buffer)) expect(lut).toBeDefined() }) it('From a file path', async () => { lut = await parseLut(filePath) expect(lut).toBeDefined() }) it('Returns correctly parsed data', () => { expect(lut.title).toEqual('lol') expect(lut.size).toEqual(32) expect(lut.type).toEqual('3d') expect(lut.data.length).toEqual(32768) expect(lut.domain.min).toEqual([0, 0, 0]) expect(lut.domain.max).toEqual([1, 1, 1]) // Pick arbitrary points and test them expect(lut.data[0]).toEqual([0.001434, 0.001434, 0.001434]) expect(lut.data[lut.data.length - 1]).toEqual([1.0, 1.0, 1.0]) }) })