Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(blp): add tests for BLP util functions #25

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/spec/blp/util.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { calcLevelCount, getSizeAtMipLevel } from '../../lib/blp/util.js';
import { describe, expect, test } from 'vitest';

describe('util', () => {
describe('calcLevelCount', () => {
test('should return expected level count for 512x512 dimensions', () => {
expect(calcLevelCount(512, 512)).toBe(10);
});

test('should return expected level count for 16x16 dimensions', () => {
expect(calcLevelCount(16, 16)).toBe(5);
});

test('should return expected level count for 1x1 dimensions', () => {
expect(calcLevelCount(1, 1)).toBe(1);
});

test('should return expected level count for 128x64 dimensions', () => {
expect(calcLevelCount(128, 64)).toBe(8);
});
});

describe('getSizeAtMipLevel', () => {
test('should return expected size given initial size of 512 and mip level of 0', () => {
expect(getSizeAtMipLevel(512, 0)).toBe(512);
});

test('should return expected size given initial size of 512 and mip level of 1', () => {
expect(getSizeAtMipLevel(512, 1)).toBe(256);
});

test('should return expected size given initial size of 512 and mip level of 9', () => {
expect(getSizeAtMipLevel(512, 9)).toBe(1);
});

test('should return expected size given initial size of 2 and mip level of 1', () => {
expect(getSizeAtMipLevel(2, 1)).toBe(1);
});
});
});