-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbool.test.ts
More file actions
36 lines (31 loc) · 1.03 KB
/
bool.test.ts
File metadata and controls
36 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { DataType } from '@apache-arrow/esnext-esm';
import test from 'ava';
import { Bool } from './bool.js';
[null, undefined].forEach((v) => {
test(`should set values to false when ${v} is passed`, (t) => {
const b = new Bool(v);
t.false(b.valid);
t.true(DataType.isBool(b.dataType));
});
});
[1, true, 'true', 'Y', 'y', 'TRUE', 'on', new Bool(true)].forEach((v, index) => {
test(`should support truthy value '${v}' (${index})`, (t) => {
const b = new Bool(v);
t.true(b.valid);
t.true(b.value);
t.true(DataType.isBool(b.dataType));
t.is(b.toString(), 'true');
});
});
[0, false, 'false', 'N', 'n', 'FALSE', 'off'].forEach((v, index) => {
test(`should support falsy value '${v}' (${index})`, (t) => {
const b = new Bool(v);
t.true(b.valid);
t.false(b.value);
t.true(DataType.isBool(b.dataType));
t.is(b.toString(), 'false');
});
});
test('should throw when unable to set value', (t) => {
t.throws(() => new Bool({ value: {} }), { message: 'Unable to set Bool from value' });
});