Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[test] Basic test suite

  • Loading branch information...
commit e5d202cab2ca5bbadf55f251100a79680cd1c6c1 1 parent 44bebdd
@mmalecki authored
Showing with 47 additions and 0 deletions.
  1. +47 −0 test/ansispan-test.js
View
47 test/ansispan-test.js
@@ -0,0 +1,47 @@
+var assert = require('assert'),
+ vows = require('vows'),
+ ansispan = require('../');
+
+require('colors');
+
+var dataSets = {
+ simple: {
+ input: 'hello world'.green,
+ output: '<span style="color: green">hello world</span>'
+ },
+ nested: {
+ input: 'hello world'.green.red,
+ output: '<span style="color: red"><span style="color: green">hello world</span></span>'
+ },
+ many: {
+ input: 'hello '.green + 'world'.red,
+ output: '<span style="color: green">hello </span><span style="color: red">world</span>'
+ },
+ 'many same colors': {
+ input: 'hello '.green + 'world'.green,
+ output: '<span style="color: green">hello </span><span style="color: green">world</span>'
+ },
+ 'colors with \\033\\[0;Xm': {
+ input: '\033\[0;32mhello world\033\[39m',
+ output: '<span style="color: green">hello world</span>'
+ }
+};
+
+function getTopics() {
+ var topics = {};
+ Object.keys(dataSets).forEach(function (set) {
+ topics['when using ' + set + ' data set'] = {
+ topic: ansispan(dataSets[set].input),
+ 'should return correct output': function (result) {
+ assert.isString(result);
+ assert.equal(result, dataSets[set].output);
+ }
+ };
+ });
+ return topics;
+}
+
+vows.describe('ansispan').addBatch({
+ 'When using ansispan': getTopics()
+}).export(module);
+
Please sign in to comment.
Something went wrong with that request. Please try again.