Skip to content

Commit e7d6519

Browse files
maxsxuagnivade
authored andcommitted
Add new theme colors and test case.
1 parent 192f159 commit e7d6519

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

lib/config.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,19 @@ function validateThemeItem(field, key) {
7272
'hidden',
7373
'black',
7474
'red',
75+
'redBright',
7576
'green',
77+
'greenBright',
7678
'yellow',
79+
'yellowBright',
7780
'blue',
81+
'blueBright',
7882
'magenta',
83+
'magentaBright',
7984
'cyan',
85+
'cyanBright',
8086
'white',
87+
'whiteBright',
8188
'gray',
8289
'bgBlack',
8390
'bgRed',
@@ -86,7 +93,15 @@ function validateThemeItem(field, key) {
8693
'bgBlue',
8794
'bgMagenta',
8895
'bgCyan',
89-
'bgWhite'
96+
'bgWhite',
97+
'bgBlackBright',
98+
'bgRedBright',
99+
'bgGreenBright',
100+
'bgYellowBright',
101+
'bgBlueBright',
102+
'bgMagentaBright',
103+
'bgCyanBright',
104+
'bgWhiteBright'
90105
];
91106
let errMsg = [];
92107
for (let fieldKey of Object.keys(field)) {
@@ -101,4 +116,4 @@ function validateThemeItem(field, key) {
101116
return null;
102117
}
103118
return errMsg.join('\n');
104-
}
119+
}

test/theme.spec.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,45 @@ describe('Theme', () => {
4545
chalk.yellow.dim.underline('text'));
4646
});
4747
});
48+
49+
describe('Rendering with new theme colors', () => {
50+
51+
let theme = new Theme({
52+
commandName: 'greenBright, bold',
53+
mainDescription: 'greenBright, bold',
54+
exampleDescription: 'greenBright',
55+
exampleCode: 'redBright',
56+
exampleToken: 'white'
57+
});
58+
59+
it('should render name with greenBright and bold', () => {
60+
theme.renderCommandName('text')
61+
.should.equal(
62+
chalk.greenBright.bold('text'));
63+
});
64+
65+
it('should render description with greenBright and bold', () => {
66+
theme.renderMainDescription('text')
67+
.should.equal(
68+
chalk.greenBright.bold('text'));
69+
});
70+
71+
it('should render example description with greenBright', () => {
72+
theme.renderExampleDescription('text')
73+
.should.equal(
74+
chalk.greenBright('text'));
75+
});
76+
77+
it('should render example code with redBright', () => {
78+
theme.renderExampleCode('text')
79+
.should.equal(
80+
chalk.redBright('text'));
81+
});
82+
83+
it('should render example argument with white', () => {
84+
theme.renderExampleToken('text')
85+
.should.equal(
86+
chalk.white('text'));
87+
});
88+
});
4889
});

0 commit comments

Comments
 (0)