1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | jest.mock('util');
|
4 | const util = require('util');
|
5 | util.deprecate.mockImplementation((fn) => (...args) => fn(...args));
|
6 | const color_1 = require("./color");
|
7 | beforeEach(() => {
|
8 | color_1.default.enabled = true;
|
9 | });
|
10 | afterEach(() => {
|
11 | color_1.default.enabled = false;
|
12 | });
|
13 | test('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 | });
|
17 | test('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 | });
|
22 | test('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 | });
|
27 | test('cannot set things', () => {
|
28 | expect(() => (color_1.default.foo = 'bar')).toThrowError(/cannot set property foo/);
|
29 | });
|
30 | test('stripColor', () => {
|
31 | expect(color_1.default.stripColor(color_1.default.red('foo'))).toEqual('foo');
|
32 | expect(util.deprecate).toBeCalled();
|
33 | });
|