Permalink
Browse files

Now prettyjson uses Mocha test framework instead of jasmine-node

  • Loading branch information...
1 parent f6f4a40 commit 1cc84e940dac10095494f74ed1f119377fd1e5bf @rafeca committed Feb 24, 2012
Showing with 21 additions and 19 deletions.
  1. +4 −3 package.json
  2. +17 −16 {spec → test}/prettyjson_spec.js
View
@@ -16,7 +16,7 @@
},
"main": "./lib/prettyjson",
"scripts": {
- "test": "./node_modules/jasmine-node/bin/jasmine-node spec"
+ "test": "./node_modules/mocha/bin/mocha"
},
"bin": {
"prettyjson": "./bin/prettyjson"
@@ -28,8 +28,9 @@
"colors": "0.5.x"
},
"devDependencies": {
- "jasmine-node": "1.0.x",
"releasetools": "0.1.x",
- "step": "0.0.x"
+ "step": "0.0.x",
+ "mocha": "~0.12.0",
+ "should": "~0.5.1"
}
}
@@ -1,4 +1,5 @@
var prettyjson = require('../lib/prettyjson');
+var should = require('should');
describe('prettyjson general tests', function(){
@@ -7,23 +8,23 @@ describe('prettyjson general tests', function(){
var input = 'This is a string'
var output = prettyjson.render(input);
- expect(output).toEqual(input);
+ output.should.equal(input);
});
it("should output a string with indentation", function(){
var input = 'This is a string'
var output = prettyjson.render(input, {}, 4);
- expect(output).toEqual(' ' + input);
+ output.should.equal(' ' + input);
});
it("should output an array of strings", function(){
var input = ['first string', 'second string'];
var output = prettyjson.render(input);
- expect(output).toEqual([
+ output.should.equal([
'- '.green + input[0],
'- '.green + input[1]
].join('\n'));
@@ -34,7 +35,7 @@ describe('prettyjson general tests', function(){
var input = ['first string', ['nested 1', 'nested 2'], 'second string'];
var output = prettyjson.render(input);
- expect(output).toEqual([
+ output.should.equal([
'- '.green + input[0],
'- '.green,
' ' + '- '.green + input[1][0],
@@ -48,7 +49,7 @@ describe('prettyjson general tests', function(){
var input = {param1: 'first string', param2: 'second string'};
var output = prettyjson.render(input);
- expect(output).toEqual([
+ output.should.equal([
'param1: '.green + 'first string',
'param2: '.green + 'second string',
].join('\n'));
@@ -59,7 +60,7 @@ describe('prettyjson general tests', function(){
var input = {first_param: {subparam: 'first string', subparam2: 'another string'}, second_param: 'second string'};
var output = prettyjson.render(input);
- expect(output).toEqual([
+ output.should.equal([
'first_param: '.green,
' ' + 'subparam: '.green + ' first string',
' ' + 'subparam2: '.green + 'another string',
@@ -72,7 +73,7 @@ describe('prettyjson general tests', function(){
var input = {very_large_param: 'first string', param: 'second string'};
var output = prettyjson.render(input);
- expect(output).toEqual([
+ output.should.equal([
'very_large_param: '.green + 'first string',
'param: '.green + ' second string',
].join('\n'));
@@ -96,7 +97,7 @@ describe('prettyjson general tests', function(){
var output = prettyjson.render(input);
- expect(output).toEqual([
+ output.should.equal([
'first_param: '.green,
' ' + 'subparam: '.green + ' first string',
' ' + 'subparam2: '.green + 'another string',
@@ -118,7 +119,7 @@ describe('prettyjson general tests', function(){
var input = {param1: 'first string', param2: 'second string'};
var output = prettyjson.render(input, {keysColor: 'blue'});
- expect(output).toEqual([
+ output.should.equal([
'param1: '.blue + 'first string',
'param2: '.blue + 'second string',
].join('\n'));
@@ -128,7 +129,7 @@ describe('prettyjson general tests', function(){
var input = {param_long: 'first string', param2: 'second string'};
var output = prettyjson.render(input, {keysColor: 'rainbow'});
- expect(output).toEqual([
+ output.should.equal([
'param_long: '.rainbow + 'first string',
'param2: '.rainbow + ' second string',
].join('\n'));
@@ -138,7 +139,7 @@ describe('prettyjson general tests', function(){
var input = {param: ['first string', "second string"]};
var output = prettyjson.render(input, {defaultIndentation: 4});
- expect(output).toEqual([
+ output.should.equal([
'param: '.green,
' ' + '- '.green + 'first string',
' ' + '- '.green + 'second string',
@@ -149,7 +150,7 @@ describe('prettyjson general tests', function(){
var input = [];
var output = prettyjson.render(input, {emptyArrayMsg: '(empty)'});
- expect(output).toEqual([
+ output.should.equal([
'(empty)'
].join('\n'));
});
@@ -161,25 +162,25 @@ describe('Printing numbers, booleans and other objects', function(){
var input = 12345;
var output = prettyjson.render(input, {}, 4);
- expect(output).toEqual(' ' + '12345'.blue);
+ output.should.equal(' ' + '12345'.blue);
});
it("should print booleans correctly ", function(){
var input = true;
var output = prettyjson.render(input, {}, 4);
- expect(output).toEqual(' ' + 'true'.green);
+ output.should.equal(' ' + 'true'.green);
input = false;
output = prettyjson.render(input, {}, 4);
- expect(output).toEqual(' ' + 'false'.red);
+ output.should.equal(' ' + 'false'.red);
});
it("should print a null object correctly ", function(){
var input = null;
var output = prettyjson.render(input, {}, 4);
- expect(output).toEqual(' ' + 'null'.grey);
+ output.should.equal(' ' + 'null'.grey);
});
});

0 comments on commit 1cc84e9

Please sign in to comment.