Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #13 from sonnym/vertical_table_docs_and_tests

Vertical table docs and tests
  • Loading branch information...
commit 7e9b5ddc1c993453016a29715c1b56820909f310 2 parents 9e8428a + 7972cc0
@rauchg rauchg authored
View
1  .gitignore
@@ -1 +1,2 @@
lib-cov
+node_modules
View
8 Makefile
@@ -1,12 +1,6 @@
test:
- @NODE_ENV=test ./support/expresso/bin/expresso \
- -I lib \
- -I support \
- -I support/should.js/lib \
- -I support/colors.js \
- $(TESTFLAGS) \
- test/*.test.js
+ @NODE_ENV=test ./node_modules/.bin/expresso $(TESTFLAGS) test/*.test.js
test-cov:
@TESTFLAGS=--cov $(MAKE) test
View
17 README.md
@@ -25,6 +25,7 @@ npm install cli-table
## How to use
+### Horizontal Tables
```javascript
var Table = require('cli-table');
@@ -40,7 +41,19 @@ table.push(
, ['First value', 'Second value']
);
-// render
+console.log(table.toString());
+```
+
+### Vertical Tables
+```javascript
+var Table = require('cli-table');
+var table = new Table();
+
+table.push(
+ { 'Some key': 'Some value' }
+ , { 'Another key': 'Another value' }
+);
+
console.log(table.toString());
```
@@ -79,4 +92,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
6 package.json
@@ -5,7 +5,11 @@
, "keywords": ["cli", "colors", "table"]
, "dependencies": {
"colors": "0.3.0"
- }
+ }
+ , "devDependencies": {
+ "expresso": "~0.9"
+ , "should": "~0.6"
+ }
, "main": "./index.js"
, "engines": { "node": ">= 0.2.0" }
}
1  support/colors.js
@@ -1 +0,0 @@
-Subproject commit b6ff10236aedd5e95bfbd94b869c329aa4c20579
1  support/expresso
@@ -1 +0,0 @@
-Subproject commit a632633104bb8da4eff0f3d0c15ca68997d5df84
1  support/should.js
@@ -1 +0,0 @@
-Subproject commit c05fac17d9894f1daeefded4db6609f962424831
View
6 test/common.js
@@ -1,6 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-require('should');
View
22 test/index.test.js
@@ -3,7 +3,7 @@
* Module requirements.
*/
-require('./common');
+require('should');
var Table = require('cli-table');
@@ -47,6 +47,24 @@ module.exports = {
});
table.width.should.eql(8);
- }
+ },
+
+ 'test vertical table output': function() {
+ var table = new Table({ style: {} }); // clear styles to prevent color output
+
+ table.push(
+ {'v0.1': 'Testing something cool'}
+ , {'v0.1': 'Testing something cool'}
+ );
+ var expected = [
+ '┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓'
+ , '┃v0.1 ┃Testing something cool┃'
+ , '┣━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━┫'
+ , '┃v0.1 ┃Testing something cool┃'
+ , '┗━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━┛'
+ ];
+
+ table.toString().should.eql(expected.join("\n"));
+ }
};
Please sign in to comment.
Something went wrong with that request. Please try again.