@mibuilder/colors
Version:
Standard colors for MiBuilder CLI
53 lines (47 loc) • 1.65 kB
JavaScript
;
var _ = require(".");
describe('umbrella', () => {
it('should not blow up requiring the module itself', () => {
require('.');
});
});
describe('colors', () => {
beforeEach(() => {
jest.resetModules();
});
it('should be enabled by default', () => {
expect(_.color.enabled).toBe(true);
});
it('should not print any colors if disabled', () => {
_.color.enabled = false;
const str = 'test';
expect(_.color.green(str)).toBe(str);
});
it('should provide Standard colors', () => {
['gray', 'grey', 'dim', 'attachment', 'addon', 'configVar', 'release', 'cmd', 'pipeline', 'important', 'error', 'success', 'deprecated', 'app'].forEach(_color => {
expect(_.color[_color]('test')).toBeDefined();
});
});
it('should provide additional colors beyond the standard ones', () => {
['red', 'green', 'yellow', 'blue'].forEach(_color => {
expect(_.color[_color]('test')).toBeDefined();
});
});
it('should contain icon for app color if enabled', () => {
_.color.enabled = true;
const result = _.color.app('My App');
expect(result).toEqual(expect.any(String));
expect(result).toEqual(expect.stringContaining('⬢ '));
});
it('should not contain icon for app color if disabled', () => {
_.color.enabled = false;
const result = _.color.app('My App');
expect(result).toEqual(expect.any(String));
expect(result).toEqual(expect.not.stringContaining('⬢ '));
});
it('should throw if an prop other than enabled will be set', () => {
expect(() => {
_.color.anyOtherProp = true;
}).toThrow('cannot set property');
});
});