Skip to content

Commit

Permalink
adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brynbellomy committed Apr 27, 2015
1 parent 3a18708 commit 402741f
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions ansi-styles/ansi-styles-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/// <reference path="ansi-styles.d.ts" />

import ansi = require('ansi-styles');


var styles = [
ansi.reset,

ansi.bold,
ansi.dim,
ansi.italic,
ansi.underline,
ansi.inverse,
ansi.hidden,
ansi.strikethrough,

ansi.black,
ansi.red,
ansi.green,
ansi.yellow,
ansi.blue,
ansi.magenta,
ansi.cyan,
ansi.white,
ansi.gray,

ansi.bgBlack,
ansi.bgRed,
ansi.bgGreen,
ansi.bgYellow,
ansi.bgBlue,
ansi.bgMagenta,
ansi.bgCyan,
ansi.bgWhite
]

for (var key in styles) {
check(key, styles[key])
}

function check(key:string, escapeCodes:ansi.EscapeCodePair): void {
if (uninitialized(escapeCodes.open)) {
throw new Error('key not found ~> ' + key + '.open')
}
if (uninitialized(escapeCodes.close)) {
throw new Error('key not found ~> ' + key + '.close')
}
}

function uninitialized(val:any): boolean {
return val === null || val === undefined
}


0 comments on commit 402741f

Please sign in to comment.