UNPKG

1.2 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3jest.mock('util');
4const util = require('util');
5util.deprecate.mockImplementation((fn) => (...args) => fn(...args));
6const color_1 = require("./color");
7beforeEach(() => {
8 color_1.default.enabled = true;
9});
10afterEach(() => {
11 color_1.default.enabled = false;
12});
13test('enabled', () => {
14 expect(color_1.default.red('foo')).toEqual('\u001b[31mfoo\u001b[39m');
15 expect(color_1.default.attachment('foo')).toEqual('\u001b[36mfoo\u001b[39m');
16});
17test('disabled', () => {
18 color_1.default.enabled = false;
19 expect(color_1.default.red('foo')).toEqual('foo');
20 expect(color_1.default.attachment('foo')).toEqual('foo');
21});
22test('app', () => {
23 expect(color_1.default.app('foo')).toEqual('\u001b[38;5;104m⬢ foo\u001b[0m');
24 color_1.default.enabled = false;
25 expect(color_1.default.app('foo')).toEqual('foo');
26});
27test('cannot set things', () => {
28 expect(() => (color_1.default.foo = 'bar')).toThrowError(/cannot set property foo/);
29});
30test('stripColor', () => {
31 expect(color_1.default.stripColor(color_1.default.red('foo'))).toEqual('foo');
32 expect(util.deprecate).toBeCalled();
33});