@@ -465,7 +465,7 @@ describe("palette", function()
465465 color15 = " #A6ADC8" ,
466466 }
467467
468- Palette .setup ({ colorscheme_file = " null" })
468+ Palette .setup ({ use_palette = " null" })
469469 local C = Palette .get ()
470470 assert .equals (C .none , expected .none )
471471 assert .equals (C .background , expected .background )
@@ -508,10 +508,12 @@ describe("palette", function()
508508 local C_dark = Palette .get (" dark" )
509509 assert .same (C_dark .color1 , " #ff0000" )
510510 assert .same (C_dark .color3 , " #ffff00" )
511+ assert .are_not .same (C_dark .color2 , " #00ff00" )
511512
512513 local C_light = Palette .get (" light" )
513514 assert .same (C_light .color2 , " #00ff00" )
514515 assert .same (C_light .color3 , " #ffff00" )
516+ assert .are_not .same (C_light .color1 , " #ff0000" )
515517 end )
516518 -- : }}}
517519 -- : setup can overwrite colors using a function {{{
@@ -538,87 +540,226 @@ describe("palette", function()
538540 local C_dark = Palette .get (" dark" )
539541 assert .same (C_dark .color1 , C_dark_old .color3 )
540542 assert .same (C_dark .color3 , C_dark_old .color4 )
543+ assert .are_not .same (C_dark .color2 , C_dark_old .color6 )
541544
542545 local C_light = Palette .get (" light" )
543546 assert .same (C_light .color2 , C_light_old .color6 )
544547 assert .same (C_light .color3 , C_light_old .color4 )
548+ assert .are_not .same (C_light .color1 , C_light_old .color3 )
545549 end )
546550 -- : }}}
547551 -- : setup can create new colors {{{
548552 it (" setup can create new colors" , function ()
549553 Palette .setup ({
550554 custom_colors = {
551- all = {
552- test_color_all = " #ff0000" ,
553- },
554555 dark = {
555556 test_color_dark = " #000000" ,
556557 },
557558 light = {
558559 test_color_light = " #ffffff" ,
559560 },
561+ all = {
562+ test_color_all = " #ff0000" ,
563+ },
560564 },
561565 })
562566
563567 local C_dark = Palette .get (" dark" )
564- assert .same (C_dark .test_color_dark , " #000000" )
565568 assert .same (C_dark .test_color_all , " #ff0000" )
569+ assert .same (C_dark .test_color_dark , " #000000" )
570+ assert .are_not .same (C_dark .test_color_light , " #ffffff" )
566571
567572 local C_light = Palette .get (" light" )
568- assert .same (C_light .test_color_light , " #ffffff" )
569573 assert .same (C_light .test_color_all , " #ff0000" )
574+ assert .same (C_light .test_color_light , " #ffffff" )
575+ assert .are_not .same (C_light .test_color_dark , " #000000" )
570576 end )
571577 -- : }}}
572578 -- : setup can create new colors using a function {{{
573579 it (" setup can create new colors using a function" , function ()
574580 Palette .setup ({
575581 custom_colors = function (C )
576582 return {
577- all = {
578- test_color_all = C .color1 ,
579- },
580583 dark = {
581584 test_color_dark = C .color0 ,
582585 },
583586 light = {
584587 test_color_light = C .color7 ,
585588 },
589+ all = {
590+ test_color_all = C .color1 ,
591+ },
586592 }
587593 end ,
588594 })
589595
590596 local C_dark = Palette .get (" dark" )
591- assert .same (C_dark .test_color_dark , C_dark .color0 )
592597 assert .same (C_dark .test_color_all , C_dark .color1 )
598+ assert .same (C_dark .test_color_dark , C_dark .color0 )
599+ assert .are_not .same (C_dark .test_color_light , C_dark .color7 )
593600
594601 local C_light = Palette .get (" light" )
595- assert .same (C_light .test_color_light , C_light .color7 )
596602 assert .same (C_light .test_color_all , C_light .color1 )
603+ assert .same (C_light .test_color_light , C_light .color7 )
604+ assert .are_not .same (C_light .test_color_dark , C_light .color0 )
597605 end )
598606 -- : }}}
599607 -- : can overwrite and export colors {{{
600608 it (" can overwrite and export colors" , function ()
601- local C = Palette .get (" dark" , false , { color1 = " #ff0000" })
602- assert .same (C .color1 , " #ff0000" )
609+ local C_dark = Palette .get (" dark" , false , {
610+ dark = { color0 = " #000000" },
611+ light = { color7 = " #ffffff" },
612+ all = { color1 = " #ff0000" },
613+ })
614+
615+ local C_light = Palette .get (" light" , false , {
616+ dark = { color6 = " #00ffff" },
617+ light = { color4 = " #0000ff" },
618+ all = { color3 = " #ffff00" },
619+ })
620+
621+ assert .same (C_dark .color1 , " #ff0000" )
622+ assert .same (C_dark .color0 , " #000000" )
623+ assert .are_not .same (C_dark .color7 , " #ffffff" )
624+
625+ assert .same (C_light .color3 , " #ffff00" )
626+ assert .same (C_light .color4 , " #0000ff" )
627+ assert .are_not .same (C_light .color6 , " #00ffff" )
603628 end )
604629 -- : }}}
605630 -- : can overwrite and export colors using a function {{{
606631 it (" can overwrite and export colors using a function" , function ()
607- local C = Palette .get (" dark" , false , function (C ) return { color1 = C .color0 } end )
608- assert .same (C .color1 , C .color0 )
632+ local C_dark_old = Palette .get (" dark" )
633+ local C_light_old = Palette .get (" light" )
634+
635+ local C_dark = Palette .get (
636+ " dark" ,
637+ false ,
638+ function (C )
639+ return {
640+ dark = {
641+ color1 = C .color0 ,
642+ },
643+ light = {
644+ color2 = C .color6 ,
645+ },
646+ all = {
647+ color3 = C .color4 ,
648+ },
649+ }
650+ end
651+ )
652+
653+ local C_light = Palette .get (
654+ " light" ,
655+ false ,
656+ function (C )
657+ return {
658+ dark = {
659+ color6 = C .color7 ,
660+ },
661+ light = {
662+ color5 = C .color8 ,
663+ },
664+ all = {
665+ color4 = C .color1 ,
666+ },
667+ }
668+ end
669+ )
670+
671+ assert .same (C_dark .color1 , C_dark_old .color0 )
672+ assert .same (C_dark .color3 , C_dark_old .color4 )
673+ assert .are_not .same (C_dark .color2 , C_dark_old .color6 )
674+
675+ assert .same (C_light .color5 , C_light .color8 )
676+ assert .same (C_light .color4 , C_light .color1 )
677+ assert .are_not .same (C_light .color6 , C_light_old .color7 )
609678 end )
610679 -- : }}}
611680 -- : can create and export new colors {{{
612681 it (" can create and export new colors" , function ()
613- local C = Palette .get (" dark" , false , { test_color = " #ff0000" })
614- assert .same (C .test_color , " #ff0000" )
682+ local C_dark = Palette .get (" dark" , false , {
683+ dark = {
684+ dark_test_color_dark = " #000000" ,
685+ },
686+ light = {
687+ dark_test_color_light = " #ffffff" ,
688+ },
689+ all = {
690+ dark_test_color_all = " #ff0000" ,
691+ },
692+ })
693+
694+ local C_light = Palette .get (" light" , false , {
695+ dark = {
696+ light_test_color_dark = " #00ffff" ,
697+ },
698+ light = {
699+ light_test_color_light = " #0000ff" ,
700+ },
701+ all = {
702+ light_test_color_all = " #ffff00" ,
703+ },
704+ })
705+
706+ assert .same (C_dark .dark_test_color_dark , " #000000" )
707+ assert .same (C_dark .dark_test_color_all , " #ff0000" )
708+ assert .are_not .same (C_dark .dark_test_color_light , " #ffffff" )
709+
710+ assert .same (C_light .light_test_color_light , " #0000ff" )
711+ assert .same (C_light .light_test_color_all , " #ffff00" )
712+ assert .are_not .same (C_light .light_test_color_dark , " #00ffff" )
615713 end )
616714 -- : }}}
617715 -- : can create and export new colors using a function {{{
618716 it (" can create and export new colors using a function" , function ()
619- --- @diagnostic disable-next-line : param-type-mismatch
620- local C = Palette .get (" dark" , false , function (C ) return { test_color = C .color1 } end )
621- assert .same (C .test_color , C .color1 )
717+ local C_dark_old = Palette .get (" dark" )
718+ local C_light_old = Palette .get (" light" )
719+
720+ local C_dark = Palette .get (
721+ " dark" ,
722+ false ,
723+ function (C )
724+ return {
725+ dark = {
726+ dark_test_color_dark = C .color0 ,
727+ },
728+ light = {
729+ dark_test_color_light = C .color7 ,
730+ },
731+ all = {
732+ dark_test_color_all = C .color1 ,
733+ },
734+ }
735+ end
736+ )
737+
738+ local C_light = Palette .get (
739+ " light" ,
740+ false ,
741+ function (C )
742+ return {
743+ dark = {
744+ light_test_color_dark = C .color3 ,
745+ },
746+ light = {
747+ light_test_color_light = C .color2 ,
748+ },
749+ all = {
750+ light_test_color_all = C .color4 ,
751+ },
752+ }
753+ end
754+ )
755+
756+ assert .same (C_dark .dark_test_color_dark , C_dark_old .color0 )
757+ assert .same (C_dark .dark_test_color_all , C_dark_old .color1 )
758+ assert .are_not .same (C_dark .dark_test_color_light , C_dark_old .color7 )
759+
760+ assert .same (C_light .light_test_color_light , C_light_old .color2 )
761+ assert .same (C_light .light_test_color_all , C_light_old .color4 )
762+ assert .are_not .same (C_light .light_test_color_dark , C_light_old .color3 )
622763 end )
623764 -- : }}}
624765end )
0 commit comments