print-tools-js
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1,2 +0,2 @@ | ||
var COLS, assert, p, should; | ||
var COLS, assert, escRepl, p, presetTest, should, styleTest; | ||
@@ -11,9 +11,14 @@ p = require('../utils/printer'); | ||
//: Test Success Method | ||
describe('success()', function() { | ||
//: Replace ANSI Escape Characters | ||
escRepl = function(text) { | ||
return text.replace(/\u001b\[.*?m/g, ''); | ||
}; | ||
//: Test Preset Methods | ||
presetTest = function(func, presetChar, offset = 0) { | ||
it('Return boolean', function() { | ||
return p.success('Test').should.be.a('boolean'); | ||
return func.bind(p)('Test').should.be.a('boolean'); | ||
}); | ||
it('Return string', function() { | ||
return p.success('Test', { | ||
return func.bind(p)('Test', { | ||
ret: true | ||
@@ -23,15 +28,15 @@ }).should.be.a('string'); | ||
it('Proper length', function() { | ||
return p.success('Test', { | ||
return escRepl(func.bind(p)('Test', { | ||
ret: true | ||
}).length.should.equal(COLS - 1); | ||
})).length.should.equal(COLS - offset); | ||
}); | ||
it('Proper length with args', function() { | ||
return p.success('Test', { | ||
return escRepl(func.bind(p)('Test', { | ||
ret: true, | ||
dec: 'arrow', | ||
indent: 2 | ||
}).length.should.equal(COLS - 1); | ||
})).length.should.equal(COLS - offset); | ||
}); | ||
it('Proper length without log', function() { | ||
return p.success('Test', { | ||
return escRepl(func.bind(p)('Test', { | ||
ret: true, | ||
@@ -41,18 +46,18 @@ log: false, | ||
indent: 2 | ||
}).length.should.equal(COLS - 1); | ||
})).length.should.equal(COLS - offset); | ||
}); | ||
return it('Contains preset characters', function() { | ||
return assert.equal(p.success('Test', { | ||
return assert.equal(func.bind(p)('Test', { | ||
ret: true | ||
}).indexOf('✔'), 0); | ||
}).indexOf(presetChar), 0); | ||
}); | ||
}); | ||
}; | ||
//: Test Info Method | ||
describe('info()', function() { | ||
//: Test Syle Methods | ||
styleTest = function(func, styleChar) { | ||
it('Return boolean', function() { | ||
return p.info('Test').should.be.a('boolean'); | ||
return func.bind(p)('Test').should.be.a('boolean'); | ||
}); | ||
it('Return string', function() { | ||
return p.info('Test', { | ||
return func.bind(p)('Test', { | ||
ret: true | ||
@@ -62,63 +67,39 @@ }).should.be.a('string'); | ||
it('Proper length', function() { | ||
return p.info('Test', { | ||
return escRepl(func.bind(p)('Test', { | ||
ret: true | ||
}).length.should.equal(COLS); | ||
})).length.should.equal(COLS); | ||
}); | ||
it('Proper length with args', function() { | ||
return p.info('Test', { | ||
return escRepl(func.bind(p)('Test', { | ||
ret: true, | ||
dec: 'arrow', | ||
indent: 2 | ||
}).length.should.equal(COLS); | ||
})).length.should.equal(COLS); | ||
}); | ||
it('Proper length without log', function() { | ||
return p.info('Test', { | ||
return escRepl(func.bind(p)('Test', { | ||
ret: true, | ||
log: false, | ||
dec: 'arrow', | ||
indent: 2 | ||
}).length.should.equal(COLS); | ||
})).length.should.equal(`${styleChar} Test`.length); | ||
}); | ||
return it('Contains preset characters', function() { | ||
return assert.equal(p.info('Test', { | ||
return assert.equal(func.bind(p)('Test', { | ||
ret: true | ||
}).indexOf('ℹ'), 0); | ||
}).indexOf(styleChar), 0); | ||
}); | ||
}; | ||
//: Test Success Method | ||
describe('success()', function() { | ||
return presetTest(p.success, '✔', 1); | ||
}); | ||
//: Test Info Method | ||
describe('info()', function() { | ||
return presetTest(p.info, 'ℹ', 0); | ||
}); | ||
//: Test Warning Method | ||
describe('warning()', function() { | ||
it('Return boolean', function() { | ||
return p.warning('Test').should.be.a('boolean'); | ||
}); | ||
it('Return string', function() { | ||
return p.warning('Test', { | ||
ret: true | ||
}).should.be.a('string'); | ||
}); | ||
it('Proper length', function() { | ||
return p.warning('Test', { | ||
ret: true | ||
}).replace(/\u001b\[.*?m/g, '').length.should.equal(COLS - 1); | ||
}); | ||
it('Proper length with args', function() { | ||
return p.warning('Test', { | ||
ret: true, | ||
dec: 'arrow', | ||
indent: 2 | ||
}).replace(/\u001b\[.*?m/g, '').length.should.equal(COLS - 1); | ||
}); | ||
it('Proper length without log', function() { | ||
return p.warning('Test', { | ||
ret: true, | ||
log: false, | ||
dec: 'arrow', | ||
indent: 2 | ||
}).replace(/\u001b\[.*?m/g, '').length.should.equal(COLS - 1); | ||
}); | ||
return it('Contains preset characters', function() { | ||
return assert.equal(p.warning('Test', { | ||
ret: true | ||
}).indexOf('⚠'), 0); | ||
}); | ||
return presetTest(p.warning, '⚠', 1); | ||
}); | ||
@@ -128,35 +109,3 @@ | ||
describe('error()', function() { | ||
it('Return boolean', function() { | ||
return p.error('Test').should.be.a('boolean'); | ||
}); | ||
it('Return string', function() { | ||
return p.error('Test', { | ||
ret: true | ||
}).should.be.a('string'); | ||
}); | ||
it('Proper length', function() { | ||
return p.error('Test', { | ||
ret: true | ||
}).replace(/\u001b\[.*?m/g, '').length.should.equal(COLS); | ||
}); | ||
it('Proper length with args', function() { | ||
return p.error('Test', { | ||
ret: true, | ||
dec: 'arrow', | ||
indent: 2 | ||
}).replace(/\u001b\[.*?m/g, '').length.should.equal(COLS); | ||
}); | ||
it('Proper length without log', function() { | ||
return p.error('Test', { | ||
ret: true, | ||
log: false, | ||
dec: 'arrow', | ||
indent: 2 | ||
}).replace(/\u001b\[.*?m/g, '').length.should.equal(COLS); | ||
}); | ||
return it('Contains preset characters', function() { | ||
return assert.equal(p.error('Test', { | ||
ret: true | ||
}).indexOf('💀'), 0); | ||
}); | ||
return presetTest(p.error, '💀', 0); | ||
}); | ||
@@ -166,33 +115,3 @@ | ||
describe('arrow()', function() { | ||
it('Return boolean', function() { | ||
return p.arrow('Test').should.be.a('boolean'); | ||
}); | ||
it('Return string', function() { | ||
return p.arrow('Test', { | ||
ret: true | ||
}).should.be.a('string'); | ||
}); | ||
it('Proper length', function() { | ||
return p.arrow('Test', { | ||
ret: true | ||
}).length.should.equal(COLS); | ||
}); | ||
it('Proper length with args', function() { | ||
return p.arrow('Test', { | ||
ret: true, | ||
indent: 2 | ||
}).length.should.equal(COLS); | ||
}); | ||
it('Proper length without log', function() { | ||
return p.arrow('Test', { | ||
ret: true, | ||
log: false, | ||
indent: 2 | ||
}).length.should.equal('--> Test'.length); | ||
}); | ||
return it('Contains preset characters', function() { | ||
return assert.equal(p.arrow('Test', { | ||
ret: true | ||
}).indexOf('-->'), 0); | ||
}); | ||
return styleTest(p.arrow, '-->'); | ||
}); | ||
@@ -202,33 +121,3 @@ | ||
describe('chevron()', function() { | ||
it('Return boolean', function() { | ||
return p.chevron('Test').should.be.a('boolean'); | ||
}); | ||
it('Return string', function() { | ||
return p.chevron('Test', { | ||
ret: true | ||
}).should.be.a('string'); | ||
}); | ||
it('Proper length', function() { | ||
return p.chevron('Test', { | ||
ret: true | ||
}).length.should.equal(COLS); | ||
}); | ||
it('Proper length with args', function() { | ||
return p.chevron('Test', { | ||
ret: true, | ||
indent: 2 | ||
}).length.should.equal(COLS); | ||
}); | ||
it('Proper length without log', function() { | ||
return p.chevron('Test', { | ||
ret: true, | ||
log: false, | ||
indent: 2 | ||
}).length.should.equal('>>> Test'.length); | ||
}); | ||
return it('Contains preset characters', function() { | ||
return assert.equal(p.chevron('Test', { | ||
ret: true | ||
}).indexOf('>>>'), 0); | ||
}); | ||
return styleTest(p.chevron, '>>>'); | ||
}); | ||
@@ -238,33 +127,3 @@ | ||
describe('bullet()', function() { | ||
it('Return boolean', function() { | ||
return p.bullet('Test').should.be.a('boolean'); | ||
}); | ||
it('Return string', function() { | ||
return p.bullet('Test', { | ||
ret: true | ||
}).should.be.a('string'); | ||
}); | ||
it('Proper length', function() { | ||
return p.bullet('Test', { | ||
ret: true | ||
}).length.should.equal(COLS); | ||
}); | ||
it('Proper length with args', function() { | ||
return p.bullet('Test', { | ||
ret: true, | ||
indent: 2 | ||
}).length.should.equal(COLS); | ||
}); | ||
it('Proper length without log', function() { | ||
return p.bullet('Test', { | ||
ret: true, | ||
log: false, | ||
indent: 2 | ||
}).length.should.equal('• Test'.length); | ||
}); | ||
return it('Contains preset characters', function() { | ||
return assert.equal(p.bullet('Test', { | ||
ret: true | ||
}).indexOf('•'), 0); | ||
}); | ||
return styleTest(p.bullet, '•'); | ||
}); | ||
@@ -283,11 +142,11 @@ | ||
it('Proper length', function() { | ||
return p.log('Test', { | ||
return escRepl(p.log('Test', { | ||
ret: true | ||
}).length.should.equal(COLS); | ||
})).length.should.equal(COLS); | ||
}); | ||
it('Proper length with emoji', function() { | ||
return p.log('Test', { | ||
return escRepl(p.log('Test', { | ||
ret: true, | ||
emoji: 'smile' | ||
}).length.should.equal(COLS); | ||
})).length.should.equal(COLS); | ||
}); | ||
@@ -294,0 +153,0 @@ return it('Contains text', function() { |
@@ -99,4 +99,4 @@ var Print, box, chalk, dateFormat, dec, decArgs, emoji, getEmote, logOrReturn, presetArgs, printDecoration, printPreset; | ||
cols = process.stdout.columns; | ||
time = dateFormat(new Date(), 'HH:MM:ss'); | ||
space = ' '.repeat(cols - text.replace(/\u001b\[.*?m/g, '').length - emote.length - time.length - 1 - args.offset); | ||
time = chalk.gray(dateFormat(new Date(), 'HH:MM:ss')); | ||
space = ' '.repeat(cols - text.replace(/\u001b\[.*?m/g, '').length - emote.length - time.replace(/\u001b\[.*?m/g, '').length - 1 - args.offset); | ||
output = `${text}${space}${emote} ${time}`; | ||
@@ -103,0 +103,0 @@ return logOrReturn(output, args.ret); |
{ | ||
"name": "print-tools-js", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Package: print_tools_js", | ||
@@ -5,0 +5,0 @@ "main": "./js/index.js", |
@@ -82,3 +82,3 @@ # Print Tools Js | ||
* *main* defaults to cyan color | ||
* *themeDesc* (string) - Description printed next to title | ||
* *titleDesc* (string) - Description printed next to title | ||
* *tagLine* (string) - Tag line printed below title line in grey | ||
@@ -89,3 +89,2 @@ * *author* (string) - Author name | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15151
408
88