This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
forked from kikito/ansicolors.lua
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial version, with colorize and specs
- Loading branch information
egarcia
committed
May 12, 2011
1 parent
2966dca
commit 523e7f2
Showing
3 changed files
with
103 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
local ansicolors = require 'ansicolors' | ||
|
||
local c27 = string.char(27) | ||
|
||
describe('ansicolors', function() | ||
|
||
describe('.colorize', function() | ||
|
||
it('should do nothing with no options', function() | ||
assert_equal(ansicolors.colorize('foo'), 'foo') | ||
end) | ||
|
||
it('should add red color to text', function() | ||
assert_equal(ansicolors.colorize('foo', 'red'), c27 .. '[31mfoo' .. c27 .. '[0m') | ||
end) | ||
|
||
it('should add red color to text with uppercase', function() | ||
assert_equal(ansicolors.colorize('foo', 'Red'), c27 .. '[31mfoo' .. c27 .. '[0m') | ||
end) | ||
|
||
it('should add red underlined text', function() | ||
assert_equal(ansicolors.colorize('foo', 'UnderlineRed'), c27 .. '[31m' .. c27 .. '[4mfoo' .. c27 .. '[0m') | ||
end) | ||
|
||
it('should parse the red background before the red foreground', function() | ||
assert_equal(ansicolors.colorize('foo', 'RedBG'), c27 .. '[41mfoo' .. c27 .. '[0m') | ||
end) | ||
|
||
it('should allow multiple attributes and spureous chars', function() | ||
assert_equal(ansicolors.colorize('foo', 'underline_redbg_yellow_dim'), c27 .. '[41m' .. c27 .. '[33m' .. c27 .. '[4m' .. c27 .. '[2mfoo' .. c27 .. '[0m') | ||
end) | ||
|
||
it('should ignore order', function() | ||
assert_equal(ansicolors.colorize('foo', 'underline_redbg_yellow'), ansicolors.colorize('foo', 'yellowRedBGUnderline')) | ||
end) | ||
|
||
end) | ||
|
||
|
||
end) |