@@ -11,6 +11,12 @@ if ('undefined' != typeof require) {
1111// strings
1212
1313describe ( 'ms(string)' , function ( ) {
14+ it ( 'should not throw an error' , function ( ) {
15+ expect ( function ( ) {
16+ ms ( '1m' ) ;
17+ } ) . to . not . throwError ( ) ;
18+ } ) ;
19+
1420 it ( 'should preserve ms' , function ( ) {
1521 expect ( ms ( '100' ) ) . to . be ( 100 ) ;
1622 } ) ;
@@ -59,6 +65,12 @@ describe('ms(string)', function(){
5965// long strings
6066
6167describe ( 'ms(long string)' , function ( ) {
68+ it ( 'should not throw an error' , function ( ) {
69+ expect ( function ( ) {
70+ ms ( '53 milliseconds' ) ;
71+ } ) . to . not . throwError ( ) ;
72+ } ) ;
73+
6274 it ( 'should convert milliseconds to ms' , function ( ) {
6375 expect ( ms ( '53 milliseconds' ) ) . to . be ( 53 ) ;
6476 } ) ;
@@ -91,6 +103,12 @@ describe('ms(long string)', function(){
91103// numbers
92104
93105describe ( 'ms(number, { long: true })' , function ( ) {
106+ it ( 'should not throw an error' , function ( ) {
107+ expect ( function ( ) {
108+ ms ( 500 , { long : true } ) ;
109+ } ) . to . not . throwError ( ) ;
110+ } ) ;
111+
94112 it ( 'should support milliseconds' , function ( ) {
95113 expect ( ms ( 500 , { long : true } ) ) . to . be ( '500 ms' ) ;
96114 } )
@@ -127,6 +145,12 @@ describe('ms(number, { long: true })', function(){
127145// numbers
128146
129147describe ( 'ms(number)' , function ( ) {
148+ it ( 'should not throw an error' , function ( ) {
149+ expect ( function ( ) {
150+ ms ( 500 ) ;
151+ } ) . to . not . throwError ( ) ;
152+ } ) ;
153+
130154 it ( 'should support milliseconds' , function ( ) {
131155 expect ( ms ( 500 ) ) . to . be ( '500ms' ) ;
132156 } )
@@ -155,3 +179,38 @@ describe('ms(number)', function(){
155179 expect ( ms ( 234234234 ) ) . to . be ( '3d' ) ;
156180 } )
157181} )
182+
183+
184+ // invalid inputs
185+
186+ describe ( 'ms(invalid inputs)' , function ( ) {
187+ it ( 'should throw an error, when ms("")' , function ( ) {
188+ expect ( function ( ) {
189+ ms ( '' ) ;
190+ } ) . to . throwError ( ) ;
191+ } ) ;
192+
193+ it ( 'should throw an error, when ms(undefined)' , function ( ) {
194+ expect ( function ( ) {
195+ ms ( undefined ) ;
196+ } ) . to . throwError ( ) ;
197+ } ) ;
198+
199+ it ( 'should throw an error, when ms(null)' , function ( ) {
200+ expect ( function ( ) {
201+ ms ( null ) ;
202+ } ) . to . throwError ( ) ;
203+ } ) ;
204+
205+ it ( 'should throw an error, when ms([])' , function ( ) {
206+ expect ( function ( ) {
207+ ms ( [ ] ) ;
208+ } ) . to . throwError ( ) ;
209+ } ) ;
210+
211+ it ( 'should throw an error, when ms({})' , function ( ) {
212+ expect ( function ( ) {
213+ ms ( { } ) ;
214+ } ) . to . throwError ( ) ;
215+ } ) ;
216+ } ) ;
0 commit comments