2020-07-04 10:09:48 -07:00
|
|
|
test("constructor properties", () => {
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(Boolean).toHaveLength(1);
|
|
|
|
|
expect(Boolean.name).toBe("Boolean");
|
2020-07-04 10:09:48 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("typeof", () => {
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(typeof new Boolean()).toBe("object");
|
|
|
|
|
expect(typeof Boolean()).toBe("boolean");
|
|
|
|
|
expect(typeof Boolean(true)).toBe("boolean");
|
2020-07-05 09:27:00 -07:00
|
|
|
});
|
2020-07-04 10:09:48 -07:00
|
|
|
|
|
|
|
|
test("basic functionality", () => {
|
2020-07-06 07:37:45 -07:00
|
|
|
var foo = new Boolean(true);
|
|
|
|
|
var bar = new Boolean(true);
|
2020-04-06 22:51:16 -05:00
|
|
|
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(foo).not.toBe(bar);
|
|
|
|
|
expect(foo.valueOf()).toBe(bar.valueOf());
|
2020-07-04 10:09:48 -07:00
|
|
|
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(Boolean()).toBeFalse();
|
|
|
|
|
expect(Boolean(false)).toBeFalse();
|
|
|
|
|
expect(Boolean(null)).toBeFalse();
|
|
|
|
|
expect(Boolean(undefined)).toBeFalse();
|
|
|
|
|
expect(Boolean(NaN)).toBeFalse();
|
|
|
|
|
expect(Boolean("")).toBeFalse();
|
|
|
|
|
expect(Boolean(0.0)).toBeFalse();
|
|
|
|
|
expect(Boolean(-0.0)).toBeFalse();
|
|
|
|
|
expect(Boolean(true)).toBeTrue();
|
|
|
|
|
expect(Boolean("0")).toBeTrue();
|
|
|
|
|
expect(Boolean({})).toBeTrue();
|
|
|
|
|
expect(Boolean([])).toBeTrue();
|
|
|
|
|
expect(Boolean(1)).toBeTrue();
|
2020-07-04 10:09:48 -07:00
|
|
|
});
|