@@ -2,8 +2,6 @@ open Jest
22open Expect
33open ! Expect .Operators
44
5- open Belt
6-
75describe ("making tinycolor" , () => {
86 test ("fromString() returns valid from string" , () => {
97 let black = TinyColor .makeFromString ("black" )
@@ -75,9 +73,7 @@ describe("making tinycolor", () => {
7573 let input : TinyColor .rgbaRatio = {r : 0.1 , g : 0.5 , b : 0.7 , a : 0.7 }
7674 let a = TinyColor .makeFromRgbaRatio (input )
7775
78- expect (Option .map (a , TinyColor .getOriginalInput ))-> toEqual (
79- Some (TinyColor .rgbaRatioToJs (input )),
80- )
76+ expect (Option .map (a , TinyColor .getOriginalInput ))-> toEqual (Some (TinyColor .rgbaRatioToJs (input )))
8177 })
8278
8379 test ("makeFromHsl() returns valid" , () => {
@@ -112,9 +108,7 @@ describe("making tinycolor", () => {
112108 let input : TinyColor .hslaRatio = {h : 0.1 , s : 0.5 , l : 0.7 , a : 0.7 }
113109 let a = TinyColor .makeFromHslaRatio (input )
114110
115- expect (Option .map (a , TinyColor .getOriginalInput ))-> toEqual (
116- Some (TinyColor .hslaRatioToJs (input )),
117- )
111+ expect (Option .map (a , TinyColor .getOriginalInput ))-> toEqual (Some (TinyColor .hslaRatioToJs (input )))
118112 })
119113
120114 test ("makeFromHsv() returns valid" , () => {
@@ -149,9 +143,7 @@ describe("making tinycolor", () => {
149143 let input : TinyColor .hsvaRatio = {h : 0.1 , s : 0.5 , v : 0.7 , a : 0.7 }
150144 let a = TinyColor .makeFromHsvaRatio (input )
151145
152- expect (Option .map (a , TinyColor .getOriginalInput ))-> toEqual (
153- Some (TinyColor .hsvaRatioToJs (input )),
154- )
146+ expect (Option .map (a , TinyColor .getOriginalInput ))-> toEqual (Some (TinyColor .hsvaRatioToJs (input )))
155147 })
156148 test ("makeFromCmyk() returns valid" , () => {
157149 let a = TinyColor .makeFromCmyk ({c : 0 , m : 100 , y : 100 , k : 0 })
@@ -217,9 +209,7 @@ describe("onBackground()", () => {
217209 switch (blue , red ) {
218210 | (Some (blue ), Some (red )) =>
219211 let bluePartlyTransparent = TinyColor .setAlpha (0.5 , blue )
220- expect (
221- TinyColor .onBackground (bluePartlyTransparent , red )-> TinyColor .toHexString ,
222- ) == "#800080"
212+ expect (TinyColor .onBackground (bluePartlyTransparent , red )-> TinyColor .toHexString ) == "#800080"
223213 | _ => expect (true ) == false
224214 }
225215 )
@@ -354,68 +344,70 @@ describe("color modification tests", () => {
354344
355345 test ("lighten(int, t)" , () =>
356346 optionMapTwo (red , c => TinyColor .lighten (~value = 10 , c ), TinyColor .toHexString )
357- -> expect
358- -> toEqual (Some ("#ff3333" ))
347+ -> expect
348+ -> toEqual (Some ("#ff3333" ))
359349 )
360350
361351 test ("lighten(int, t) does not change original instance" , () =>
362352 optionMapTwo (red , c => TinyColor .lighten (~value = 10 , c ), TinyColor .toHex8String )
363- -> expect
364- -> not_
365- -> toEqual (Option .map (red , TinyColor .toHex8String ))
353+ -> expect
354+ -> not_
355+ -> toEqual (Option .map (red , TinyColor .toHex8String ))
366356 )
367357
368358 test ("brighten(int, t)" , () =>
369359 optionMapTwo (red , c => TinyColor .brighten (~value = 10 , c ), TinyColor .toHexString )
370- -> expect
371- -> toEqual (Some ("#ff1919" ))
360+ -> expect
361+ -> toEqual (Some ("#ff1919" ))
372362 )
373363
374364 test ("brighten(int, t) dose not change original instance" , () =>
375365 optionMapTwo (red , c => TinyColor .brighten (~value = 10 , c ), TinyColor .toString )
376- -> expect
377- -> not_
378- -> toEqual (Option .map (red , TinyColor .toString ))
366+ -> expect
367+ -> not_
368+ -> toEqual (Option .map (red , TinyColor .toString ))
379369 )
380370
381371 test ("darken(int, t)" , () =>
382372 optionMapTwo (red , c => TinyColor .darken (~value = 10 , c ), TinyColor .toHexString )
383- -> expect
384- -> toEqual (Some ("#cc0000" ))
373+ -> expect
374+ -> toEqual (Some ("#cc0000" ))
385375 )
386376
387377 test ("tint(int, t)" , () =>
388378 optionMapTwo (red , c => TinyColor .tint (~value = 10 , c ), TinyColor .toHexString )
389- -> expect
390- -> toEqual (Some ("#ff1a1a" ))
379+ -> expect
380+ -> toEqual (Some ("#ff1a1a" ))
391381 )
392382
393383 test ("shade(int, t)" , () =>
394384 optionMapTwo (red , c => TinyColor .shade (~value = 10 , c ), TinyColor .toHexString )
395- -> expect
396- -> toEqual (Some ("#e60000" ))
385+ -> expect
386+ -> toEqual (Some ("#e60000" ))
397387 )
398388
399389 test ("desaturate(int, t)" , () =>
400390 optionMapTwo (red , c => TinyColor .desaturate (~value = 10 , c ), TinyColor .toHexString )
401- -> expect
402- -> toEqual (Some ("#f20d0d" ))
391+ -> expect
392+ -> toEqual (Some ("#f20d0d" ))
403393 )
404394
405395 test ("saturate(int, t)" , () =>
406396 optionMapTwo (red , c => TinyColor .saturate (~value = 10 , c ), TinyColor .toHexString )
407- -> expect
408- -> toEqual (Some ("#ff0000" ))
397+ -> expect
398+ -> toEqual (Some ("#ff0000" ))
409399 )
410400
411401 test ("spin(int, t)" , () =>
412- Option .map (red , c => TinyColor .spin (~value = 180 , c ))-> Option .map (TinyColor .toHex8String )
413- -> expect === Some ("#00ffffff" )
402+ Option .map (red , c => TinyColor .spin (~value = 180 , c ))
403+ -> Option .map (TinyColor .toHex8String )
404+ -> expect === Some ("#00ffffff" )
414405 )
415406
416407 test ("spin(int, t) with value 360 does not change" , () =>
417- Option .map (red , c => TinyColor .spin (~value = 360 , c ))-> Option .map (TinyColor .toHex8String )
418- -> expect === Option .map (red , TinyColor .toHex8String )
408+ Option .map (red , c => TinyColor .spin (~value = 360 , c ))
409+ -> Option .map (TinyColor .toHex8String )
410+ -> expect === Option .map (red , TinyColor .toHex8String )
419411 )
420412
421413 test ("mix(int, t)" , () => {
@@ -424,66 +416,68 @@ describe("color modification tests", () => {
424416
425417 switch (color1 , color2 ) {
426418 | (Some (c1 ), Some (c2 )) =>
427- TinyColor .mix (~value = 50 , c1 , c2 )-> Option .map (TinyColor .toHexString )
428- -> expect
429- -> toEqual (Some ("#808080" ))
419+ TinyColor .mix (~value = 50 , c1 , c2 )
420+ -> Option .map (TinyColor .toHexString )
421+ -> expect
422+ -> toEqual (Some ("#808080" ))
430423 | _ => expect (false ) === true
431424 }
432425 })
433426
434427 test ("greyscale(t)" , () =>
435- Option .map (red , TinyColor .greyscale )-> Option .map (TinyColor .toHex8String )
436- -> expect === Some ("#808080ff" )
428+ Option .map (red , TinyColor .greyscale )
429+ -> Option .map (TinyColor .toHex8String )
430+ -> expect === Some ("#808080ff" )
437431 )
438432})
439433
440434describe ("color combinations" , () => {
441435 let mapAndReturnHexArray = (color , fn ) =>
442- Option .map (color , fn )-> Option .getWithDefault ([])-> Array .map (TinyColor .toHexString )
436+ Option .map (color , fn )-> Option .getOr ([])-> Belt . Array .map (TinyColor .toHexString )
443437
444438 test ("analogous()" , () =>
445439 TinyColor .makeFromString ("#f00" )
446- -> Option .getExn
440+ -> Option .getOrThrow
447441 -> TinyColor .analogous ()
448442 -> Array .map (TinyColor .toHexString )
449- -> expect
450- -> toEqual (["#ff0000" , "#ff0066" , "#ff0033" , "#ff0000" , "#ff3300" , "#ff6600" ])
443+ -> expect
444+ -> toEqual (["#ff0000" , "#ff0066" , "#ff0033" , "#ff0000" , "#ff3300" , "#ff6600" ])
451445 )
452446
453447 test ("monochromatic()" , () =>
454448 TinyColor .makeFromString ("#f00" )
455- -> Option .getExn
449+ -> Option .getOrThrow
456450 -> TinyColor .monochromatic ()
457451 -> Array .map (TinyColor .toHexString )
458- -> expect
459- -> toEqual (["#ff0000" , "#2a0000" , "#550000" , "#800000" , "#aa0000" , "#d40000" ])
452+ -> expect
453+ -> toEqual (["#ff0000" , "#2a0000" , "#550000" , "#800000" , "#aa0000" , "#d40000" ])
460454 )
461455
462456 test ("splitcomplement()" , () =>
463457 mapAndReturnHexArray (TinyColor .makeFromString ("#f00" ), TinyColor .splitcomplement )
464- -> expect
465- -> toEqual (["#ff0000" , "#ccff00" , "#0066ff" ])
458+ -> expect
459+ -> toEqual (["#ff0000" , "#ccff00" , "#0066ff" ])
466460 )
467461
468462 test ("triad()" , () =>
469463 mapAndReturnHexArray (TinyColor .makeFromString ("#f00" ), TinyColor .triad )
470- -> expect
471- -> toEqual (["#ff0000" , "#00ff00" , "#0000ff" ])
464+ -> expect
465+ -> toEqual (["#ff0000" , "#00ff00" , "#0000ff" ])
472466 )
473467
474468 test ("tetrad()" , () =>
475469 mapAndReturnHexArray (TinyColor .makeFromString ("#f00" ), TinyColor .tetrad )
476- -> expect
477- -> toEqual (["#ff0000" , "#80ff00" , "#00ffff" , "#7f00ff" ])
470+ -> expect
471+ -> toEqual (["#ff0000" , "#80ff00" , "#00ffff" , "#7f00ff" ])
478472 )
479473
480474 test ("polyad()" , () =>
481475 TinyColor .makeFromString ("#f00" )
482- -> Option .getExn
476+ -> Option .getOrThrow
483477 -> TinyColor .polyad (~n = 4 , ())
484478 -> Array .map (TinyColor .toHexString )
485- -> expect
486- -> toEqual (["#ff0000" , "#80ff00" , "#00ffff" , "#7f00ff" ])
479+ -> expect
480+ -> toEqual (["#ff0000" , "#80ff00" , "#00ffff" , "#7f00ff" ])
487481 )
488482
489483 test ("complement()" , () => {
@@ -500,14 +494,14 @@ describe("color utils", () => {
500494 let a = TinyColor .makeFromString ("red" )
501495 let b = TinyColor .makeFromRgb ({r : 255 , g : 0 , b : 0 })
502496
503- expect (Option .eq (a , b , TinyColor .equals )) === true
497+ expect (Option .equal (a , b , TinyColor .equals )) === true
504498 })
505499
506500 test ("equals() returns false for unequal colors" , () => {
507501 let a = TinyColor .makeFromString ("red" )
508502 let b = TinyColor .makeFromString ("blue" )
509503
510- expect (Option .eq (a , b , TinyColor .equals )) === false
504+ expect (Option .equal (a , b , TinyColor .equals )) === false
511505 })
512506
513507 test ("random()" , () => {
@@ -525,31 +519,31 @@ describe("color utils", () => {
525519
526520 test ("randomMultiple() returns empty array for count=0" , () => {
527521 let a = TinyColor .randomMultiple (~count = 0 , ())
528- expect (Array .length (a ))-> toBe (0 )
522+ expect (Belt . Array .length (a ))-> toBe (0 )
529523 })
530524
531525 test ("randomMultiple() returns single element in array" , () => {
532526 let a = TinyColor .randomMultiple (~count = 1 , ())
533527
534- expect (Array .length (a ))-> toBe (1 )
528+ expect (Belt . Array .length (a ))-> toBe (1 )
535529 })
536530
537531 test ("randomMultiple() returns many elements" , () => {
538532 let a = TinyColor .randomMultiple (~count = 15 , ())
539533
540- expect (Array .length (a ))-> toBe (15 )
534+ expect (Belt . Array .length (a ))-> toBe (15 )
541535 })
542536
543537 test ("randomMultiple() returns all different colors" , () => {
544538 let a = TinyColor .randomMultiple (~count = 4 , ())
545539
546540 expect (
547- ! TinyColor .equals (Array .getExn (a , 0 ), Array .getExn (a , 1 )) &&
548- (! TinyColor .equals (Array .getExn (a , 0 ), Array .getExn (a , 2 )) &&
549- (! TinyColor .equals (Array .getExn (a , 0 ), Array .getExn (a , 3 )) &&
550- (! TinyColor .equals (Array .getExn (a , 1 ), Array .getExn (a , 2 )) &&
551- (! TinyColor .equals (Array .getExn (a , 1 ), Array .getExn (a , 3 )) &&
552- ! TinyColor .equals (Array .getExn (a , 2 ), Array .getExn (a , 3 )))))),
541+ ! TinyColor .equals (Belt . Array .getExn (a , 0 ), Belt . Array .getExn (a , 1 )) &&
542+ (! TinyColor .equals (Belt . Array .getExn (a , 0 ), Belt . Array .getExn (a , 2 )) &&
543+ (! TinyColor .equals (Belt . Array .getExn (a , 0 ), Belt . Array .getExn (a , 3 )) &&
544+ (! TinyColor .equals (Belt . Array .getExn (a , 1 ), Belt . Array .getExn (a , 2 )) &&
545+ (! TinyColor .equals (Belt . Array .getExn (a , 1 ), Belt . Array .getExn (a , 3 )) &&
546+ ! TinyColor .equals (Belt . Array .getExn (a , 2 ), Belt . Array .getExn (a , 3 )))))),
553547 ) === true
554548 })
555549
0 commit comments