[Pkg-javascript-commits] [node-cliui] 01/01: add tests
Paolo Greppi
paolog-guest at moszumanska.debian.org
Sat Nov 26 01:04:59 UTC 2016
This is an automated email from the git hooks/post-receive script.
paolog-guest pushed a commit to branch master
in repository node-cliui.
commit 5ec982b5fa04ce02a05dbddb1819fddbe8b7a9c6
Author: Paolo Greppi <paolo.greppi at libpf.com>
Date: Sat Nov 26 01:03:00 2016 +0000
add tests
- Add a patch to use assert rather than chai during tests
- override_dh_auto_test to run tests during packaging
- enable autopkgtest
TODOs:
- 16 out of 24 tests are failing
---
debian/changelog | 1 +
debian/patches/00-chai.diff | 274 ++++++++++++++++++++++++++++++++++++++++++++
debian/patches/series | 1 +
debian/rules | 6 +-
debian/tests/control | 3 +
test/cliui.js | 80 ++++++-------
6 files changed, 321 insertions(+), 44 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 8747f02..ce8c7ed 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
node-cliui (3.2.0-1) UNRELEASED; urgency=low
* Initial release (Closes: #845266)
+ * Add a patch to use assert rather than chai.
-- Paolo Greppi <paolo.greppi at libpf.com> Sat, 26 Nov 2016 00:30:38 +0000
diff --git a/debian/patches/00-chai.diff b/debian/patches/00-chai.diff
new file mode 100644
index 0000000..39a0b7f
--- /dev/null
+++ b/debian/patches/00-chai.diff
@@ -0,0 +1,274 @@
+Description: Change from chai to assert (chai is not yet available
+ as a Debian package).
+Forwarded: not-needed
+Author: Paolo Greppi <paolo.greppi at libpf.com>
+
+Index: node-cliui/test/cliui.js
+===================================================================
+--- node-cliui.orig/test/cliui.js
++++ node-cliui/test/cliui.js
+@@ -1,6 +1,6 @@
+ /* global describe, it */
+
+-require('chai').should()
++var assert = require('assert')
+
+ var chalk = require('chalk')
+ var cliui = require('../')
+@@ -16,7 +16,7 @@ describe('cliui', function () {
+ ui.div('i am a string that should be wrapped')
+
+ ui.toString().split('\n').forEach(function (row) {
+- row.length.should.be.lte(10)
++ assert(row.length <= 10)
+ })
+ })
+
+@@ -34,7 +34,7 @@ describe('cliui', function () {
+ // total width of all columns is <=
+ // the width cliui is initialized with.
+ ui.toString().split('\n').forEach(function (row) {
+- row.length.should.be.lte(40)
++ assert(row.length <= 40)
+ })
+
+ // it should wrap each column appropriately.
+@@ -46,7 +46,7 @@ describe('cliui', function () {
+ ' wrapped'
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+
+ it('allows for a blank row to be appended', function () {
+@@ -59,7 +59,7 @@ describe('cliui', function () {
+ // it should wrap each column appropriately.
+ var expected = ['']
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+ })
+
+@@ -70,9 +70,9 @@ describe('cliui', function () {
+ })
+ var widths = ui._columnWidths([{}, {}, {}])
+
+- widths[0].should.equal(13)
+- widths[1].should.equal(13)
+- widths[2].should.equal(13)
++ assert(widths[0] == 13)
++ assert(widths[1] == 13)
++ assert(widths[2] == 13)
+ })
+
+ it('divides width over remaining columns if first column has width specified', function () {
+@@ -81,9 +81,9 @@ describe('cliui', function () {
+ })
+ var widths = ui._columnWidths([{width: 20}, {}, {}])
+
+- widths[0].should.equal(20)
+- widths[1].should.equal(10)
+- widths[2].should.equal(10)
++ assert(widths[0] == 20)
++ assert(widths[1] == 10)
++ assert(widths[2] == 10)
+ })
+
+ it('divides width over remaining columns if middle column has width specified', function () {
+@@ -92,9 +92,9 @@ describe('cliui', function () {
+ })
+ var widths = ui._columnWidths([{}, {width: 10}, {}])
+
+- widths[0].should.equal(15)
+- widths[1].should.equal(10)
+- widths[2].should.equal(15)
++ assert(widths[0] == 15)
++ assert(widths[1] == 10)
++ assert(widths[2] == 15)
+ })
+
+ it('keeps track of remaining width if multiple columns have width specified', function () {
+@@ -103,9 +103,9 @@ describe('cliui', function () {
+ })
+ var widths = ui._columnWidths([{width: 20}, {width: 12}, {}])
+
+- widths[0].should.equal(20)
+- widths[1].should.equal(12)
+- widths[2].should.equal(8)
++ assert(widths[0] == 20)
++ assert(widths[1] == 12)
++ assert(widths[2] == 8)
+ })
+
+ it('uses a sane default if impossible widths are specified', function () {
+@@ -114,9 +114,9 @@ describe('cliui', function () {
+ })
+ var widths = ui._columnWidths([{width: 30}, {width: 30}, {padding: [0, 2, 0, 1]}])
+
+- widths[0].should.equal(30)
+- widths[1].should.equal(30)
+- widths[2].should.equal(4)
++ assert(widths[0] == 30)
++ assert(widths[1] == 30)
++ assert(widths[2] == 4)
+ })
+ })
+
+@@ -140,7 +140,7 @@ describe('cliui', function () {
+ ' wrapped'
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+
+ it('allows a column to be center aligned', function () {
+@@ -161,7 +161,7 @@ describe('cliui', function () {
+ ' wrapped'
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+ })
+
+@@ -185,7 +185,7 @@ describe('cliui', function () {
+ ' left'
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+
+ it('handles top/bottom padding', function () {
+@@ -209,7 +209,7 @@ describe('cliui', function () {
+ ''
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+
+ it('preserves leading whitespace as padding', function () {
+@@ -223,9 +223,9 @@ describe('cliui', function () {
+ ' with ansi'
+ ]
+
+- ui.toString().split('\n').map(function (l) {
++ assert(ui.toString().split('\n').map(function (l) {
+ return stripAnsi(l)
+- }).should.eql(expected)
++ }) == expected)
+ })
+ })
+
+@@ -248,7 +248,7 @@ describe('cliui', function () {
+ " '------------------'"
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+ })
+
+@@ -264,7 +264,7 @@ describe('cliui', function () {
+ {text: 'i am a third string that should not be wrapped', padding: [0, 0, 0, 2]}
+ )
+
+- ui.toString().should.equal('i am a string i am a second string i am a third string that should not be wrapped')
++ assert(ui.toString() == 'i am a string i am a second string i am a third string that should not be wrapped')
+ })
+ })
+
+@@ -287,7 +287,7 @@ describe('cliui', function () {
+ 'wrapped [required] [default: 99]'
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+
+ it('does not append the string if it does not fit on the prior row', function () {
+@@ -309,7 +309,7 @@ describe('cliui', function () {
+ 'i am a second row'
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+
+ it('always appends text to prior span if wrap is disabled', function () {
+@@ -333,7 +333,7 @@ describe('cliui', function () {
+ 'a third line'
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+
+ it('appends to prior line appropriately when strings contain ansi escape codes', function () {
+@@ -354,9 +354,9 @@ describe('cliui', function () {
+ 'wrapped [required] [default: 99]'
+ ]
+
+- ui.toString().split('\n').map(function (l) {
++ assert(ui.toString().split('\n').map(function (l) {
+ return stripAnsi(l)
+- }).should.eql(expected)
++ }) == expected)
+ })
+ })
+
+@@ -375,7 +375,7 @@ describe('cliui', function () {
+ ' <my second thing> another row a third column'
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+
+ it('turns newline into multiple rows', function () {
+@@ -393,7 +393,7 @@ describe('cliui', function () {
+ ' glob'
+ ]
+
+- ui.toString().split('\n').should.eql(expected)
++ assert(ui.toString().split('\n') == expected)
+ })
+
+ it('aligns rows appropriately when they contain ansi escape codes', function () {
+@@ -412,9 +412,9 @@ describe('cliui', function () {
+ ' glob'
+ ]
+
+- ui.toString().split('\n').map(function (l) {
++ assert(ui.toString().split('\n').map(function (l) {
+ return stripAnsi(l)
+- }).should.eql(expected)
++ }) == expected)
+ })
+
+ it('ignores ansi escape codes when measuring padding', function () {
+@@ -436,9 +436,9 @@ describe('cliui', function () {
+ ' '
+ ]
+
+- ui.toString().split('\n').map(function (l) {
++ assert(ui.toString().split('\n').map(function (l) {
+ return stripAnsi(l)
+- }).should.eql(expected)
++ }) == expected)
+ })
+
+ it('does not apply DSL if wrap is false', function () {
+@@ -451,7 +451,7 @@ describe('cliui', function () {
+ 'Usage: $0\ttwo\tthree'
+ )
+
+- ui.toString().should.eql('Usage: $0\ttwo\tthree')
++ assert(ui.toString() == 'Usage: $0\ttwo\tthree')
+ })
+ })
+ })
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..cc0d3fe
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+00-chai.diff
diff --git a/debian/rules b/debian/rules
index de57af0..3170fba 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,7 +9,5 @@
#override_dh_auto_build:
-#override_dh_auto_test:
-
-
-
+override_dh_auto_test:
+ mocha
diff --git a/debian/tests/control b/debian/tests/control
index 4e7ee60..123b961 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,2 +1,5 @@
Tests: require
Depends: node-cliui
+
+Test-Command: mocha
+Depends: @, @builddeps@
diff --git a/test/cliui.js b/test/cliui.js
index fd27f5a..9ce1081 100644
--- a/test/cliui.js
+++ b/test/cliui.js
@@ -1,6 +1,6 @@
/* global describe, it */
-require('chai').should()
+var assert = require('assert')
var chalk = require('chalk')
var cliui = require('../')
@@ -16,7 +16,7 @@ describe('cliui', function () {
ui.div('i am a string that should be wrapped')
ui.toString().split('\n').forEach(function (row) {
- row.length.should.be.lte(10)
+ assert(row.length <= 10)
})
})
@@ -34,7 +34,7 @@ describe('cliui', function () {
// total width of all columns is <=
// the width cliui is initialized with.
ui.toString().split('\n').forEach(function (row) {
- row.length.should.be.lte(40)
+ assert(row.length <= 40)
})
// it should wrap each column appropriately.
@@ -46,7 +46,7 @@ describe('cliui', function () {
' wrapped'
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
it('allows for a blank row to be appended', function () {
@@ -59,7 +59,7 @@ describe('cliui', function () {
// it should wrap each column appropriately.
var expected = ['']
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
})
@@ -70,9 +70,9 @@ describe('cliui', function () {
})
var widths = ui._columnWidths([{}, {}, {}])
- widths[0].should.equal(13)
- widths[1].should.equal(13)
- widths[2].should.equal(13)
+ assert(widths[0] == 13)
+ assert(widths[1] == 13)
+ assert(widths[2] == 13)
})
it('divides width over remaining columns if first column has width specified', function () {
@@ -81,9 +81,9 @@ describe('cliui', function () {
})
var widths = ui._columnWidths([{width: 20}, {}, {}])
- widths[0].should.equal(20)
- widths[1].should.equal(10)
- widths[2].should.equal(10)
+ assert(widths[0] == 20)
+ assert(widths[1] == 10)
+ assert(widths[2] == 10)
})
it('divides width over remaining columns if middle column has width specified', function () {
@@ -92,9 +92,9 @@ describe('cliui', function () {
})
var widths = ui._columnWidths([{}, {width: 10}, {}])
- widths[0].should.equal(15)
- widths[1].should.equal(10)
- widths[2].should.equal(15)
+ assert(widths[0] == 15)
+ assert(widths[1] == 10)
+ assert(widths[2] == 15)
})
it('keeps track of remaining width if multiple columns have width specified', function () {
@@ -103,9 +103,9 @@ describe('cliui', function () {
})
var widths = ui._columnWidths([{width: 20}, {width: 12}, {}])
- widths[0].should.equal(20)
- widths[1].should.equal(12)
- widths[2].should.equal(8)
+ assert(widths[0] == 20)
+ assert(widths[1] == 12)
+ assert(widths[2] == 8)
})
it('uses a sane default if impossible widths are specified', function () {
@@ -114,9 +114,9 @@ describe('cliui', function () {
})
var widths = ui._columnWidths([{width: 30}, {width: 30}, {padding: [0, 2, 0, 1]}])
- widths[0].should.equal(30)
- widths[1].should.equal(30)
- widths[2].should.equal(4)
+ assert(widths[0] == 30)
+ assert(widths[1] == 30)
+ assert(widths[2] == 4)
})
})
@@ -140,7 +140,7 @@ describe('cliui', function () {
' wrapped'
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
it('allows a column to be center aligned', function () {
@@ -161,7 +161,7 @@ describe('cliui', function () {
' wrapped'
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
})
@@ -185,7 +185,7 @@ describe('cliui', function () {
' left'
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
it('handles top/bottom padding', function () {
@@ -209,7 +209,7 @@ describe('cliui', function () {
''
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
it('preserves leading whitespace as padding', function () {
@@ -223,9 +223,9 @@ describe('cliui', function () {
' with ansi'
]
- ui.toString().split('\n').map(function (l) {
+ assert(ui.toString().split('\n').map(function (l) {
return stripAnsi(l)
- }).should.eql(expected)
+ }) == expected)
})
})
@@ -248,7 +248,7 @@ describe('cliui', function () {
" '------------------'"
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
})
@@ -264,7 +264,7 @@ describe('cliui', function () {
{text: 'i am a third string that should not be wrapped', padding: [0, 0, 0, 2]}
)
- ui.toString().should.equal('i am a string i am a second string i am a third string that should not be wrapped')
+ assert(ui.toString() == 'i am a string i am a second string i am a third string that should not be wrapped')
})
})
@@ -287,7 +287,7 @@ describe('cliui', function () {
'wrapped [required] [default: 99]'
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
it('does not append the string if it does not fit on the prior row', function () {
@@ -309,7 +309,7 @@ describe('cliui', function () {
'i am a second row'
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
it('always appends text to prior span if wrap is disabled', function () {
@@ -333,7 +333,7 @@ describe('cliui', function () {
'a third line'
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
it('appends to prior line appropriately when strings contain ansi escape codes', function () {
@@ -354,9 +354,9 @@ describe('cliui', function () {
'wrapped [required] [default: 99]'
]
- ui.toString().split('\n').map(function (l) {
+ assert(ui.toString().split('\n').map(function (l) {
return stripAnsi(l)
- }).should.eql(expected)
+ }) == expected)
})
})
@@ -375,7 +375,7 @@ describe('cliui', function () {
' <my second thing> another row a third column'
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
it('turns newline into multiple rows', function () {
@@ -393,7 +393,7 @@ describe('cliui', function () {
' glob'
]
- ui.toString().split('\n').should.eql(expected)
+ assert(ui.toString().split('\n') == expected)
})
it('aligns rows appropriately when they contain ansi escape codes', function () {
@@ -412,9 +412,9 @@ describe('cliui', function () {
' glob'
]
- ui.toString().split('\n').map(function (l) {
+ assert(ui.toString().split('\n').map(function (l) {
return stripAnsi(l)
- }).should.eql(expected)
+ }) == expected)
})
it('ignores ansi escape codes when measuring padding', function () {
@@ -436,9 +436,9 @@ describe('cliui', function () {
' '
]
- ui.toString().split('\n').map(function (l) {
+ assert(ui.toString().split('\n').map(function (l) {
return stripAnsi(l)
- }).should.eql(expected)
+ }) == expected)
})
it('does not apply DSL if wrap is false', function () {
@@ -451,7 +451,7 @@ describe('cliui', function () {
'Usage: $0\ttwo\tthree'
)
- ui.toString().should.eql('Usage: $0\ttwo\tthree')
+ assert(ui.toString() == 'Usage: $0\ttwo\tthree')
})
})
})
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-cliui.git
More information about the Pkg-javascript-commits
mailing list