mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
fix: /bot imports in bot pkg
This commit is contained in:
@@ -4,61 +4,35 @@ import * as colors from '../src/colors.js'
|
||||
|
||||
const arrayOfColors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']
|
||||
|
||||
describe('color.ts', () => {
|
||||
arrayOfColors.forEach((color, index) => {
|
||||
describe(`${color} function`, () => {
|
||||
it('will return colored word', () => {
|
||||
expect((colors[color as keyof typeof colors] as typeof colors.black)('testWord')).to.equal(`\x1B[${30 + index}mtestWord\x1B[39m`)
|
||||
})
|
||||
})
|
||||
describe('Colors', () => {
|
||||
it(`Color functions will return colored word`, () => {
|
||||
for (const [index, color] of arrayOfColors.entries()) {
|
||||
const value = (colors[color as keyof typeof colors] as typeof colors.black)('testWord')
|
||||
expect(value).equals(`\x1B[${30 + index}mtestWord\x1B[39m`)
|
||||
|
||||
const brightName = `bright${color.slice(0, 1).toUpperCase()}${color.slice(1)}`
|
||||
const brightValue = (colors[brightName as keyof typeof colors] as typeof colors.black)('testWord')
|
||||
expect(brightValue).to.equal(`\x1B[${90 + index}mtestWord\x1B[39m`)
|
||||
|
||||
const bgName = `bg${color.slice(0, 1).toUpperCase()}${color.slice(1)}`
|
||||
const bgValue = (colors[bgName as keyof typeof colors] as typeof colors.black)('testWord')
|
||||
expect(bgValue).to.equal(`\x1B[${40 + index}mtestWord\x1B[49m`, `Color ${color} has failed .`)
|
||||
|
||||
const bgBrightName = `bgBright${color.slice(0, 1).toUpperCase()}${color.slice(1)}`
|
||||
const bgBrightValue = (colors[bgBrightName as keyof typeof colors] as typeof colors.black)('testWord')
|
||||
expect(bgBrightValue).to.equal(`\x1B[${100 + index}mtestWord\x1B[49m`)
|
||||
}
|
||||
})
|
||||
|
||||
describe(`grey function`, () => {
|
||||
it('will return colored word', () => {
|
||||
expect(colors.gray('testWord')).to.equal(`\x1B[${90}mtestWord\x1B[39m`)
|
||||
})
|
||||
it('Will return grey colored word', () => {
|
||||
expect(colors.gray('testWord')).to.equal(`\x1B[${90}mtestWord\x1B[39m`)
|
||||
})
|
||||
arrayOfColors
|
||||
.map((color) => `bright${color.slice(0, 1).toUpperCase()}${color.slice(1)}`)
|
||||
.forEach((color, index) => {
|
||||
describe(`${color} function`, () => {
|
||||
it('will return colored word', () => {
|
||||
expect((colors[color as keyof typeof colors] as typeof colors.brightBlack)('testWord')).to.equal(`\x1B[${90 + index}mtestWord\x1B[39m`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
arrayOfColors
|
||||
.map((color) => `bg${color.slice(0, 1).toUpperCase()}${color.slice(1)}`)
|
||||
.forEach((color, index) => {
|
||||
describe(`${color} function`, () => {
|
||||
it('will return colored word', () => {
|
||||
expect((colors[color as keyof typeof colors] as typeof colors.bgBlack)('testWord')).to.equal(`\x1B[${40 + index}mtestWord\x1B[49m`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
arrayOfColors
|
||||
.map((color) => `bgBright${color.slice(0, 1).toUpperCase()}${color.slice(1)}`)
|
||||
.forEach((color, index) => {
|
||||
describe(`${color} function`, () => {
|
||||
it('will return colored word', () => {
|
||||
expect((colors[color as keyof typeof colors] as typeof colors.bgBlack)('testWord')).to.equal(`\x1B[${100 + index}mtestWord\x1B[49m`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('get and set color enabled', () => {
|
||||
it('by default color should be on', () => {
|
||||
expect(colors.getColorEnabled()).to.equal(true)
|
||||
})
|
||||
|
||||
it('Set it off and on', () => {
|
||||
expect(colors.getColorEnabled()).to.equal(true)
|
||||
colors.setColorEnabled(false)
|
||||
expect(colors.getColorEnabled()).to.equal(false)
|
||||
colors.setColorEnabled(true)
|
||||
expect(colors.getColorEnabled()).to.equal(true)
|
||||
})
|
||||
it('Set and get colors enabled value', () => {
|
||||
expect(colors.getColorEnabled()).to.equal(true)
|
||||
colors.setColorEnabled(false)
|
||||
expect(colors.getColorEnabled()).to.equal(false)
|
||||
colors.setColorEnabled(true)
|
||||
expect(colors.getColorEnabled()).to.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user