Skip to content

Commit

Permalink
Improved test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksi Asikainen committed May 14, 2016
1 parent f20dcf0 commit c266ca5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -3,7 +3,7 @@
"name": "ip-subnet-calculator",
"description": "Calculate optimal subnet masks for standard and non-standard IP ranges",
"homepage": "https://github.com/franksrevenge/IPSubnetCalculator",
"version": "1.1.6",
"version": "1.1.7",
"files": [
"lib",
"examples"
Expand Down
54 changes: 54 additions & 0 deletions test/ip-subnet-calculator.js
Expand Up @@ -295,6 +295,60 @@ describe( 'IP Subnet Calculator',
}
);


it( 'should fail calculate() if start IP is higher than end IP',
function()
{
should.equal( ipsc.calculate( '10.1.0.0', '10.0.0.0' ), null );
}
);


it( 'should fail calculateSubnetMask() if IP is invalid',
function()
{
should.equal( ipsc.calculateSubnetMask( 'helloworld', 24 ), null );
}
);


it( 'should fail calculateCIDRPrefix() if IP is invalid',
function()
{
should.equal( ipsc.calculateCIDRPrefix( 'helloworld', '255.255.255.255' ), null );
}
);


it( 'should pass decimal IPs through toDecimal()',
function()
{
ipsc.toDecimal( 4026531840 ).should.be.exactly( 4026531840 );
}
);


it( 'should pass string IPs through toString()',
function()
{
ipsc.toString( '127.0.0.1' ).should.be.exactly( '127.0.0.1' );
}
);


it( 'should reject converting invalid numeric IPs to strings',
function()
{
(
function()
{
ipsc.toString( -1 );
}
)
.should.throw();
}
);

}
);

Expand Down

0 comments on commit c266ca5

Please sign in to comment.