Add mock data and unit tests for Channels and Members APIs
This commit is contained in:
31
test/unit/lang/assertUnreachable.test.ts
Normal file
31
test/unit/lang/assertUnreachable.test.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import {describe, expect, it} from 'bun:test';
|
||||
import assertUnreachable from '../../../src/lang/assertUnreachable';
|
||||
|
||||
describe('assertUnreachable', () => {
|
||||
describe('when called with an unexpected value', () => {
|
||||
it('should throw an error containing the value', () => {
|
||||
const unreachableValue = 'unexpected' as never;
|
||||
|
||||
expect(() => assertUnreachable(unreachableValue)).toThrow('Unreachable code: unexpected');
|
||||
});
|
||||
|
||||
it('should handle numeric values in the error message', () => {
|
||||
const numericValue = 42 as never;
|
||||
|
||||
expect(() => assertUnreachable(numericValue)).toThrow('Unreachable code: 42');
|
||||
});
|
||||
|
||||
it('should always throw and never return', () => {
|
||||
const value = 'test' as never;
|
||||
let didThrow = false;
|
||||
|
||||
try {
|
||||
assertUnreachable(value);
|
||||
} catch {
|
||||
didThrow = true;
|
||||
}
|
||||
|
||||
expect(didThrow).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user