@@ -115,24 +115,30 @@ describe('launder', function() {
115115 } ) ;
116116
117117 it ( 'should convert non-string/non-number to an empty string' , function ( ) {
118- assert ( launder . string ( { an : 'object' } ) === '' ) ;
119- assert ( launder . string ( function ( ) { return 'still not a string' ; } ) === '' ) ;
118+ assert ( launder . string ( { an : 'object' } ) === '' ) ;
119+ assert ( launder . string ( function ( ) {
120+ return 'still not a string' ;
121+ } ) === '' ) ;
120122 } ) ;
121123
122124 it ( 'should use a default for non-strings' , function ( ) {
123- assert ( launder . string ( { an : 'object' } , 'default' ) === 'default' ) ;
125+ assert ( launder . string ( { an : 'object' } , 'default' ) === 'default' ) ;
124126 } ) ;
125127 } ) ;
126128
127129 describe ( 'strings' , function ( ) {
128130 it ( 'should do good stuff to an array of strings' , function ( ) {
129- const s = launder . strings ( [ ' testing ' , 123 ] ) ;
131+ const s = launder . strings ( [ ' testing ' , 123 ] ) ;
130132 assert ( s [ 0 ] === 'testing' ) ;
131133 assert ( s [ 1 ] === '123' ) ;
132134 } ) ;
133135
134136 it ( 'should return an empty array if we pass in something that is not an array' , function ( ) {
135- const s = launder . strings ( { an : 'object' , is : 'not' , typeof : 'array' } ) ;
137+ const s = launder . strings ( {
138+ an : 'object' ,
139+ is : 'not' ,
140+ typeof : 'array'
141+ } ) ;
136142 assert ( Array . isArray ( s ) ) ;
137143 assert ( s . length === 0 ) ;
138144 } ) ;
@@ -248,14 +254,26 @@ describe('launder', function() {
248254
249255 describe ( 'select' , function ( ) {
250256 it ( 'should do nothing to a good choice from an array' , function ( ) {
251- assert ( launder . select ( 'n' , [ 'p' , 'u' , 'n' , 'k' ] ) === 'n' ) ;
257+ assert ( launder . select ( 'n' , [ 'p' , 'u' , 'n' , 'k' ] ) === 'n' ) ;
252258 } ) ;
253259 it ( 'should do nothing to a good choice from an object' , function ( ) {
254260 const s = launder . select ( 'n' , [
255- { name : 'Probably amazing' , value : 'p' } ,
256- { name : 'Utterly incredible' , value : 'u' } ,
257- { name : 'Never gonna give you up' , value : 'n' } ,
258- { name : 'Kind hearted' , value : 'k' }
261+ {
262+ name : 'Probably amazing' ,
263+ value : 'p'
264+ } ,
265+ {
266+ name : 'Utterly incredible' ,
267+ value : 'u'
268+ } ,
269+ {
270+ name : 'Never gonna give you up' ,
271+ value : 'n'
272+ } ,
273+ {
274+ name : 'Kind hearted' ,
275+ value : 'k'
276+ }
259277 ] ) ;
260278 assert ( s === 'n' ) ;
261279 } ) ;
@@ -266,36 +284,63 @@ describe('launder', function() {
266284 assert ( launder . select ( 'hi' , [ ] , 'bye' ) === 'bye' ) ;
267285 } ) ;
268286 it ( 'should return the default if the choice is not found in an array' , function ( ) {
269- assert ( launder . select ( 'hi' , [ 'not' , 'in' , 'here' ] , 'bye' ) === 'bye' ) ;
287+ assert ( launder . select ( 'hi' , [ 'not' , 'in' , 'here' ] , 'bye' ) === 'bye' ) ;
270288 } ) ;
271289 it ( 'should not crash if a null choice is present' , function ( ) {
272- assert ( launder . select ( 'yes' , [ 'not' , null , 'yes' ] ) === 'yes' ) ;
290+ assert ( launder . select ( 'yes' , [ 'not' , null , 'yes' ] ) === 'yes' ) ;
273291 } ) ;
274292 it ( 'should not crash if an undefined choice is present' , function ( ) {
275- assert ( launder . select ( 'yes' , [ 'not' , undefined , 'yes' ] ) === 'yes' ) ;
293+ assert ( launder . select ( 'yes' , [ 'not' , undefined , 'yes' ] ) === 'yes' ) ;
276294 } ) ;
277295 it ( 'should not crash if a null choice is present, with labels' , function ( ) {
278- assert ( launder . select ( 'yes' , [ { value : 'not' , label : 'Not' } , { value : null , label : 'broken' } , { value : 'yes' , label : 'Yes' } ] ) === 'yes' ) ;
296+ assert ( launder . select ( 'yes' , [ {
297+ value : 'not' ,
298+ label : 'Not'
299+ } , {
300+ value : null ,
301+ label : 'broken'
302+ } , {
303+ value : 'yes' ,
304+ label : 'Yes'
305+ } ] ) === 'yes' ) ;
279306 } ) ;
280307 it ( 'should not crash if an undefined choice is present, with labels' , function ( ) {
281- assert ( launder . select ( 'yes' , [ { value : 'not' , label : 'Not' } , { value : undefined , label : 'broken' } , { value : 'yes' , label : 'Yes' } ] ) === 'yes' ) ;
308+ assert ( launder . select ( 'yes' , [ {
309+ value : 'not' ,
310+ label : 'Not'
311+ } , {
312+ value : undefined ,
313+ label : 'broken'
314+ } , {
315+ value : 'yes' ,
316+ label : 'Yes'
317+ } ] ) === 'yes' ) ;
282318 } ) ;
283319 it ( 'should return the default if the choice is not found in an object' , function ( ) {
284320 const s = launder . select ( 'hi' , [
285- { name : 'Not something' , value : 'not' } ,
286- { name : 'Inside' , value : 'in' } ,
287- { name : 'Here anymore' , value : 'here' }
321+ {
322+ name : 'Not something' ,
323+ value : 'not'
324+ } ,
325+ {
326+ name : 'Inside' ,
327+ value : 'in'
328+ } ,
329+ {
330+ name : 'Here anymore' ,
331+ value : 'here'
332+ }
288333 ] , 'bye' ) ;
289334 assert ( s === 'bye' ) ;
290335 } ) ;
291336 it ( 'should return the default if the choice is not found in an array' , function ( ) {
292- assert ( launder . select ( 'hi' , [ 'not' , 'in' , 'here' ] , 'bye' ) === 'bye' ) ;
337+ assert ( launder . select ( 'hi' , [ 'not' , 'in' , 'here' ] , 'bye' ) === 'bye' ) ;
293338 } ) ;
294339 it ( 'should match a string input matching the string representation of a choice that is a number, and return the number, not the string' , function ( ) {
295- assert ( launder . select ( '5' , [ 1 , 3 , 5 ] , 1 ) === 5 ) ;
340+ assert ( launder . select ( '5' , [ 1 , 3 , 5 ] , 1 ) === 5 ) ;
296341 } ) ;
297342 it ( 'should match a number matching a choice that is a number, and return the number, not a stringification of it' , function ( ) {
298- assert ( launder . select ( 5 , [ 1 , 3 , 5 ] , 1 ) === 5 ) ;
343+ assert ( launder . select ( 5 , [ 1 , 3 , 5 ] , 1 ) === 5 ) ;
299344 } ) ;
300345 } ) ;
301346
@@ -378,9 +423,9 @@ describe('launder', function() {
378423 describe ( 'addBooleanFilterToCriteria' , function ( ) {
379424 const name = 'published' ;
380425 const criteria = { } ;
381- const optionsTrue = { ' published' : true } ;
382- const optionsFalse = { ' published' : false } ;
383- const optionsEmpty = { ' published' : '' } ;
426+ const optionsTrue = { published : true } ;
427+ const optionsFalse = { published : false } ;
428+ const optionsEmpty = { published : '' } ;
384429
385430 it ( 'should not change criteria if option is `any`' , function ( ) {
386431 launder . addBooleanFilterToCriteria ( 'any' , name , criteria ) ;
@@ -400,7 +445,7 @@ describe('launder', function() {
400445 assert ( criteria [ name ] === true ) ;
401446 const criteria2 = { } ;
402447 launder . addBooleanFilterToCriteria ( optionsFalse , name , criteria2 ) ;
403- assert ( criteria2 [ name ] [ ' $ne' ] === true ) ;
448+ assert ( criteria2 [ name ] . $ne === true ) ;
404449 } ) ;
405450 it ( 'should be able to use a boolean string `true` for options' , function ( ) {
406451 const criteria = { } ;
@@ -418,22 +463,22 @@ describe('launder', function() {
418463 assert ( criteria [ name ] === true ) ;
419464 criteria = { } ;
420465 launder . addBooleanFilterToCriteria ( false , name , criteria ) ;
421- assert ( criteria [ name ] [ ' $ne' ] === true ) ;
466+ assert ( criteria [ name ] . $ne === true ) ;
422467 } ) ;
423468 it ( 'should treat empty string as false' , function ( ) {
424469 const criteria = { } ;
425470 launder . addBooleanFilterToCriteria ( '' , name , criteria ) ;
426- assert ( criteria [ name ] [ ' $ne' ] === true ) ;
471+ assert ( criteria [ name ] . $ne === true ) ;
427472 } ) ;
428473 it ( 'should treat empty string in an object as false' , function ( ) {
429474 const criteria = { } ;
430475 launder . addBooleanFilterToCriteria ( optionsEmpty , name , criteria ) ;
431- assert ( criteria [ name ] [ ' $ne' ] === true ) ;
476+ assert ( criteria [ name ] . $ne === true ) ;
432477 } ) ;
433478 it ( 'should take a default if `options` or `options[name]` is undefined' , function ( ) {
434479 const criteria = { } ;
435480 launder . addBooleanFilterToCriteria ( { } , name , criteria , false ) ;
436- assert ( criteria [ name ] [ ' $ne' ] === true ) ;
481+ assert ( criteria [ name ] . $ne === true ) ;
437482 } ) ;
438483 } ) ;
439484
@@ -538,10 +583,10 @@ describe('launder', function() {
538583 } ) ;
539584
540585 describe ( 'tags' , function ( ) {
541- const goodTags = [ 'one' , 'two' , 'three' ] ;
542- const spaceyTags = [ ' One' , 'TWO' , ' three ' ] ;
543- const numberTags = [ 12 , 34 ] ;
544- const troubleTags = [ 'one' , 2 , { an : 'object' } , null , 'three' ] ;
586+ const goodTags = [ 'one' , 'two' , 'three' ] ;
587+ const spaceyTags = [ ' One' , 'TWO' , ' three ' ] ;
588+ const numberTags = [ 12 , 34 ] ;
589+ const troubleTags = [ 'one' , 2 , { an : 'object' } , null , 'three' ] ;
545590
546591 it ( 'should do nothing to a good array of tags' , function ( ) {
547592 const t = launder . tags ( goodTags ) ;
@@ -558,7 +603,11 @@ describe('launder', function() {
558603 assert ( t [ 2 ] === 'three' ) ;
559604 } ) ;
560605 it ( 'should return an empty array if you pass in something that is not an array' , function ( ) {
561- const t = launder . tags ( { an : 'object' , is : 'not' , typeof : 'array' } ) ;
606+ const t = launder . tags ( {
607+ an : 'object' ,
608+ is : 'not' ,
609+ typeof : 'array'
610+ } ) ;
562611 assert ( Array . isArray ( t ) ) ;
563612 assert ( t . length === 0 ) ;
564613 } ) ;
@@ -576,14 +625,18 @@ describe('launder', function() {
576625 assert ( t [ 2 ] === 'three' ) ;
577626 } ) ;
578627 it ( 'should take a filter function' , function ( ) {
579- const t = launder . tags ( numberTags , function ( tag ) { return tag + '0' ; } ) ;
628+ const t = launder . tags ( numberTags , function ( tag ) {
629+ return tag + '0' ;
630+ } ) ;
580631 assert ( t . length === 2 ) ;
581632 assert ( t [ 0 ] === '120' ) ;
582633 assert ( t [ 1 ] === '340' ) ;
583634 } ) ;
584635 it ( 'should allow a different filter function to be set during initiation' , function ( ) {
585636 const launder = require ( '../index.js' ) ( {
586- filterTag : function ( tag ) { return tag + '0' ; }
637+ filterTag : function ( tag ) {
638+ return tag + '0' ;
639+ }
587640 } ) ;
588641 const t = launder . tags ( numberTags ) ;
589642 assert ( t . length === 2 ) ;
@@ -622,7 +675,11 @@ describe('launder', function() {
622675 assert ( i [ 2 ] === '1003' ) ;
623676 } ) ;
624677 it ( 'should return an empty array if you pass in something that is not an array' , function ( ) {
625- const i = launder . ids ( { an : 'object' , is : 'not' , typeof : 'array' } ) ;
678+ const i = launder . ids ( {
679+ an : 'object' ,
680+ is : 'not' ,
681+ typeof : 'array'
682+ } ) ;
626683 assert ( Array . isArray ( i ) ) ;
627684 assert ( i . length === 0 ) ;
628685 } ) ;
0 commit comments