Skip to content

Commit

Permalink
Merge pull request #3 from JamesxX/developer
Browse files Browse the repository at this point in the history
Merge developer branch
  • Loading branch information
ARitz-Cracker authored Jun 26, 2016
2 parents cfdf493 + 56e95fa commit 2f6825a
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 6 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: node_js

# test on two node.js versions: 0.6 and 0.8
node_js:
- 4.4.5

before_install:
- npm install -g mocha
- npm install -g chai

branches:
only:
- master
- developer
script: mocha
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ Swift-Cardinal Object Notation (SCON)
A minimal node module allowing the reading and writing of data in the SCON format.
The SCON format, created by Aritz J Beobide-Cardinal (ARitz Cracker) and James R Swift, is an extendable binary file format that was created to store data more efficiantly than the popular JSON standard.

Get the module here [![npm version](https://badge.fury.io/js/scon.svg)](https://badge.fury.io/js/scon)
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Node.js Version][node-version-image]][node-version-url]
[![Build status][build-status-image]][build-status-url]
[![License][license-image]][license-url]

## Installation

Expand All @@ -28,9 +32,25 @@ Add unit tests for any new or changed functionality. Lint and test your code.

## Release History

* 1.0.3 Added TravisCI intergration and tests
* 1.0.2 Added support for NaN and 64 bit floats
* 1.0.0 Added support for arrays, booleans, and nulls!
* 0.9.2 ???
* 0.9.0 Major update in module structure, and added error handling.
* 0.8.2 Removed left over tests.
* 0.8.0 Initial release

[npm-image]: https://img.shields.io/npm/v/scon.svg
[npm-url]: https://npmjs.org/package/scon

[downloads-image]: https://img.shields.io/npm/dm/scon.svg
[downloads-url]: https://npmjs.org/package/scon

[node-version-image]: https://img.shields.io/node/v/scon.svg
[node-version-url]: https://nodejs.org/en/download/

[build-status-image]: https://travis-ci.org/JamesxX/scon.svg
[build-status-url]: https://travis-ci.org/JamesxX/scon

[license-image]: https://img.shields.io/npm/l/scon.svg?maxAge=2592000
[license-url]: LICENSE
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "scon",
"version": "1.0.2",
"version": "1.0.3",
"description": "Read and write scon files",
"main": "index.js",
"scripts": {
"test": "mocha"
"test": "./node_modules/mocha/bin/mocha"
},
"repository": {
"type": "git",
Expand Down
72 changes: 69 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,76 @@
var expect = require('chai').expect;
var scon = require('../index.js');

describe("Swift Binary Tag file format", function() {
function testKeyValueEquality( key, obj1, obj2 ){

if ( typeof obj1[ key ] == "object" ){

describe( "Testing member object '" + key + "'", function(){

for (var subkey in obj1[key]) {
testKeyValueEquality( subkey, obj1[key], obj2[key] );
}

});

} else if ( typeof obj1[ key ] == "number" && isNaN( obj1[ key ] ) ) {

it( "Key " + key + " should have the same value in both objects (NaN)", function(){
expect( obj2[ key ] ).to.be.NaN;
});

}else {

it( "Key " + key + " should have the same value in both objects", function(){
expect( obj1[ key ] ).to.equal( obj2[ key ] );
});

}

}

describe("Swift-Cardinal Object Notation file format", function() {

var testCase = {
hello: "world!!",
hi: "bye",
five: NaN,
pi: 3.14159,
object: {
amazing:true,
['true']: {
mind:"fuck"
}
},
six: 6,
arr: ["wan","too","free",{"for":4},[1,2,3,4,5]]
};

it( "should not throw errors when encoding", function(){
expect( function(){scon.encode( testCase )} ).to.not.throw( scon.Exception );
});

var encoded = scon.encode( testCase );

it("should write the magic number", function(){
expect(scon.encode( {} ).result.substring( 0, scon.magicNumber.length ) ).to.equal( scon.magicNumber );
})
expect( encoded.result.substring( 0, scon.magicNumber.length ) ).to.equal( scon.magicNumber );
});

it( "should not throw errors when decoding", function(){
expect( function(){scon.decode( encoded.result )} ).to.not.throw( scon.Exception );
});

var decoded = scon.decode( encoded.result );

describe( "testing equality of testCase and decoded object", function(){

for (var key in testCase) {

testKeyValueEquality( key, testCase, decoded.result );

}

});

});

0 comments on commit 2f6825a

Please sign in to comment.