|
668 | 668 | --- |
669 | 669 | > |
670 | 670 | > afterEach(function () { |
671 | | -578,580c481,484 |
| 671 | +575a479,480 |
| 672 | +> |
| 673 | +> global.kbnHandlebarsEnv = null; |
| 674 | +578,580c483,486 |
672 | 675 | < it('should call logger at default level', function() { |
673 | 676 | < var levelArg, logArg; |
674 | 677 | < handlebarsEnv.log = function(level, arg) { |
|
677 | 680 | > let levelArg; |
678 | 681 | > let logArg; |
679 | 682 | > kbnHandlebarsEnv!.log = function (level, arg) { |
680 | | -585,590c489,491 |
| 683 | +585,590c491,493 |
681 | 684 | < expectTemplate('{{log blah}}') |
682 | 685 | < .withInput({ blah: 'whee' }) |
683 | 686 | < .withMessage('log should not display') |
|
688 | 691 | > expectTemplate('{{log blah}}').withInput({ blah: 'whee' }).toCompileTo(''); |
689 | 692 | > expect(1).toEqual(levelArg); |
690 | 693 | > expect('whee').toEqual(logArg); |
691 | | -593,595c494,497 |
| 694 | +593,595c496,499 |
692 | 695 | < it('should call logger at data level', function() { |
693 | 696 | < var levelArg, logArg; |
694 | 697 | < handlebarsEnv.log = function(level, arg) { |
|
697 | 700 | > let levelArg; |
698 | 701 | > let logArg; |
699 | 702 | > kbnHandlebarsEnv!.log = function (level, arg) { |
700 | | -605,606c507,508 |
| 703 | +605,606c509,510 |
701 | 704 | < equals('03', levelArg); |
702 | 705 | < equals('whee', logArg); |
703 | 706 | --- |
704 | 707 | > expect('03').toEqual(levelArg); |
705 | 708 | > expect('whee').toEqual(logArg); |
706 | | -609,610c511,513 |
| 709 | +609,610c513,515 |
707 | 710 | < it('should output to info', function() { |
708 | 711 | < var called; |
709 | 712 | --- |
710 | 713 | > it('should output to info', function () { |
711 | 714 | > let calls = 0; |
712 | 715 | > const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2; |
713 | | -612,616c515,521 |
| 716 | +612,616c517,523 |
714 | 717 | < console.info = function(info) { |
715 | 718 | < equals('whee', info); |
716 | 719 | < called = true; |
|
724 | 727 | > console.info = $info; |
725 | 728 | > console.log = $log; |
726 | 729 | > } |
727 | | -618,622c523,529 |
| 730 | +618,622c525,531 |
728 | 731 | < console.log = function(log) { |
729 | 732 | < equals('whee', log); |
730 | 733 | < called = true; |
|
738 | 741 | > console.info = $info; |
739 | 742 | > console.log = $log; |
740 | 743 | > } |
741 | | -625,628c532,533 |
| 744 | +625,628c534,535 |
742 | 745 | < expectTemplate('{{log blah}}') |
743 | 746 | < .withInput({ blah: 'whee' }) |
744 | 747 | < .toCompileTo(''); |
745 | 748 | < equals(true, called); |
746 | 749 | --- |
747 | 750 | > expectTemplate('{{log blah}}').withInput({ blah: 'whee' }).toCompileTo(''); |
748 | 751 | > expect(calls).toEqual(callsExpected); |
749 | | -631,632c536,538 |
| 752 | +631,632c538,540 |
750 | 753 | < it('should log at data level', function() { |
751 | 754 | < var called; |
752 | 755 | --- |
753 | 756 | > it('should log at data level', function () { |
754 | 757 | > let calls = 0; |
755 | 758 | > const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2; |
756 | | -634,637c540,543 |
| 759 | +634,637c542,545 |
757 | 760 | < console.error = function(log) { |
758 | 761 | < equals('whee', log); |
759 | 762 | < called = true; |
|
763 | 766 | > expect('whee').toEqual(log); |
764 | 767 | > calls++; |
765 | 768 | > if (calls === callsExpected) console.error = $error; |
766 | | -645c551 |
| 769 | +645c553 |
767 | 770 | < equals(true, called); |
768 | 771 | --- |
769 | 772 | > expect(calls).toEqual(callsExpected); |
770 | | -648,649c554,556 |
| 773 | +648,649c556,558 |
771 | 774 | < it('should handle missing logger', function() { |
772 | 775 | < var called = false; |
773 | 776 | --- |
774 | 777 | > it('should handle missing logger', function () { |
775 | 778 | > let calls = 0; |
776 | 779 | > const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2; |
777 | | -650a558 |
| 780 | +650a560 |
778 | 781 | > // @ts-expect-error |
779 | | -652,655c560,563 |
| 782 | +652,655c562,565 |
780 | 783 | < console.log = function(log) { |
781 | 784 | < equals('whee', log); |
782 | 785 | < called = true; |
|
786 | 789 | > expect('whee').toEqual(log); |
787 | 790 | > calls++; |
788 | 791 | > if (calls === callsExpected) console.log = $log; |
789 | | -663c571 |
| 792 | +663c573 |
790 | 793 | < equals(true, called); |
791 | 794 | --- |
792 | 795 | > expect(calls).toEqual(callsExpected); |
793 | | -666,667c574,576 |
| 796 | +666,667c576,578 |
794 | 797 | < it('should handle string log levels', function() { |
795 | 798 | < var called; |
796 | 799 | --- |
797 | 800 | > it('should handle string log levels', function () { |
798 | 801 | > let calls = 0; |
799 | 802 | > const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2; |
800 | | -669,671c578,580 |
| 803 | +669,671c580,582 |
801 | 804 | < console.error = function(log) { |
802 | 805 | < equals('whee', log); |
803 | 806 | < called = true; |
804 | 807 | --- |
805 | 808 | > console.error = function (log) { |
806 | 809 | > expect('whee').toEqual(log); |
807 | 810 | > calls++; |
808 | | -679c588 |
| 811 | +679c590 |
809 | 812 | < equals(true, called); |
810 | 813 | --- |
811 | 814 | > expect(calls).toEqual(callsExpected); |
812 | | -681c590 |
| 815 | +681c592 |
813 | 816 | < called = false; |
814 | 817 | --- |
815 | 818 | > calls = 0; |
816 | | -688c597 |
| 819 | +688c599 |
817 | 820 | < equals(true, called); |
818 | 821 | --- |
819 | 822 | > expect(calls).toEqual(callsExpected); |
820 | | -691,692c600,602 |
| 823 | +691,692c602,604 |
821 | 824 | < it('should handle hash log levels', function() { |
822 | 825 | < var called; |
823 | 826 | --- |
824 | 827 | > it('should handle hash log levels [1]', function () { |
825 | 828 | > let calls = 0; |
826 | 829 | > const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2; |
827 | | -694,696c604,606 |
| 830 | +694,696c606,608 |
828 | 831 | < console.error = function(log) { |
829 | 832 | < equals('whee', log); |
830 | 833 | < called = true; |
831 | 834 | --- |
832 | 835 | > console.error = function (log) { |
833 | 836 | > expect('whee').toEqual(log); |
834 | 837 | > calls++; |
835 | | -699,702c609,610 |
| 838 | +699,702c611,612 |
836 | 839 | < expectTemplate('{{log blah level="error"}}') |
837 | 840 | < .withInput({ blah: 'whee' }) |
838 | 841 | < .toCompileTo(''); |
839 | 842 | < equals(true, called); |
840 | 843 | --- |
841 | 844 | > expectTemplate('{{log blah level="error"}}').withInput({ blah: 'whee' }).toCompileTo(''); |
842 | 845 | > expect(calls).toEqual(callsExpected); |
843 | | -705,706c613,614 |
| 846 | +705,706c615,616 |
844 | 847 | < it('should handle hash log levels', function() { |
845 | 848 | < var called = false; |
846 | 849 | --- |
847 | 850 | > it('should handle hash log levels [2]', function () { |
848 | 851 | > let called = false; |
849 | | -708,711c616,623 |
| 852 | +708,711c618,625 |
850 | 853 | < console.info = console.log = console.error = console.debug = function() { |
851 | 854 | < called = true; |
852 | 855 | < console.info = console.log = console.error = console.debug = $log; |
|
860 | 863 | > called = true; |
861 | 864 | > console.info = console.log = console.error = console.debug = $log; |
862 | 865 | > }; |
863 | | -713,716c625,626 |
| 866 | +713,716c627,628 |
864 | 867 | < expectTemplate('{{log blah level="debug"}}') |
865 | 868 | < .withInput({ blah: 'whee' }) |
866 | 869 | < .toCompileTo(''); |
867 | 870 | < equals(false, called); |
868 | 871 | --- |
869 | 872 | > expectTemplate('{{log blah level="debug"}}').withInput({ blah: 'whee' }).toCompileTo(''); |
870 | 873 | > expect(false).toEqual(called); |
871 | | -719,720c629,631 |
| 874 | +719,720c631,633 |
872 | 875 | < it('should pass multiple log arguments', function() { |
873 | 876 | < var called; |
874 | 877 | --- |
875 | 878 | > it('should pass multiple log arguments', function () { |
876 | 879 | > let calls = 0; |
877 | 880 | > const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2; |
878 | | -722,727c633,638 |
| 881 | +722,727c635,640 |
879 | 882 | < console.info = console.log = function(log1, log2, log3) { |
880 | 883 | < equals('whee', log1); |
881 | 884 | < equals('foo', log2); |
|
889 | 892 | > expect(1).toEqual(log3); |
890 | 893 | > calls++; |
891 | 894 | > if (calls === callsExpected) console.log = $log; |
892 | | -730,733c641,642 |
| 895 | +730,733c643,644 |
893 | 896 | < expectTemplate('{{log blah "foo" 1}}') |
894 | 897 | < .withInput({ blah: 'whee' }) |
895 | 898 | < .toCompileTo(''); |
896 | 899 | < equals(true, called); |
897 | 900 | --- |
898 | 901 | > expectTemplate('{{log blah "foo" 1}}').withInput({ blah: 'whee' }).toCompileTo(''); |
899 | 902 | > expect(calls).toEqual(callsExpected); |
900 | | -736,737c645,647 |
| 903 | +736,737c647,649 |
901 | 904 | < it('should pass zero log arguments', function() { |
902 | 905 | < var called; |
903 | 906 | --- |
904 | 907 | > it('should pass zero log arguments', function () { |
905 | 908 | > let calls = 0; |
906 | 909 | > const callsExpected = process.env.AST || process.env.EVAL ? 1 : 2; |
907 | | -739,742c649,652 |
| 910 | +739,742c651,654 |
908 | 911 | < console.info = console.log = function() { |
909 | 912 | < expect(arguments.length).to.equal(0); |
910 | 913 | < called = true; |
|
914 | 917 | > expect(arguments.length).toEqual(0); |
915 | 918 | > calls++; |
916 | 919 | > if (calls === callsExpected) console.log = $log; |
917 | | -745,748c655,656 |
| 920 | +745,748c657,658 |
918 | 921 | < expectTemplate('{{log}}') |
919 | 922 | < .withInput({ blah: 'whee' }) |
920 | 923 | < .toCompileTo(''); |
921 | 924 | < expect(called).to.be.true(); |
922 | 925 | --- |
923 | 926 | > expectTemplate('{{log}}').withInput({ blah: 'whee' }).toCompileTo(''); |
924 | 927 | > expect(calls).toEqual(callsExpected); |
925 | | -753,754c661,662 |
| 928 | +753,754c663,664 |
926 | 929 | < describe('#lookup', function() { |
927 | 930 | < it('should lookup arbitrary content', function() { |
928 | 931 | --- |
929 | 932 | > describe('#lookup', () => { |
930 | 933 | > it('should lookup arbitrary content', () => { |
931 | | -760c668 |
| 934 | +760c670 |
932 | 935 | < it('should not fail on undefined value', function() { |
933 | 936 | --- |
934 | 937 | > it('should not fail on undefined value', () => { |
0 commit comments