-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(blp): add tests for BLP util functions (#25)
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 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
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); | ||
}); | ||
}); | ||
}); |