@@ -812,4 +812,229 @@ Description.
812
812
} ;
813
813
expect ( result . config ) . toEqual ( expected . config ) ;
814
814
} ) ;
815
+
816
+ // hints
817
+ it ( "should parse hints for a step" , ( ) => {
818
+ const md = `# Title
819
+
820
+ Description.
821
+
822
+ ## L1 Title 1
823
+
824
+ First level content.
825
+
826
+ ### L1S1
827
+
828
+ The first step
829
+
830
+ #### Hints
831
+
832
+ * First Hint
833
+ * Second Hint
834
+
835
+ ` ;
836
+ const skeleton = {
837
+ levels : [
838
+ {
839
+ id : "L1" ,
840
+ steps : [
841
+ {
842
+ id : "L1S1" ,
843
+ } ,
844
+ ] ,
845
+ } ,
846
+ ] ,
847
+ } ;
848
+ const result = parse ( {
849
+ text : md ,
850
+ skeleton,
851
+ commits : {
852
+ L1S1Q : [ "abcdef1" , "123456789" ] ,
853
+ } ,
854
+ } ) ;
855
+ const expected = {
856
+ summary : {
857
+ description : "Description." ,
858
+ } ,
859
+ levels : [
860
+ {
861
+ id : "L1" ,
862
+ title : "Title 1" ,
863
+ summary : "First level content." ,
864
+ content : "First level content." ,
865
+ steps : [
866
+ {
867
+ id : "L1S1" ,
868
+ content : "The first step" ,
869
+ setup : {
870
+ commits : [ "abcdef1" , "123456789" ] ,
871
+ } ,
872
+ hints : [ "First Hint" , "Second Hint" ] ,
873
+ } ,
874
+ ] ,
875
+ } ,
876
+ ] ,
877
+ } ;
878
+ expect ( result . levels ) . toEqual ( expected . levels ) ;
879
+ } ) ;
880
+
881
+ it ( "should parse hints for a step" , ( ) => {
882
+ const md = `# Title
883
+
884
+ Description.
885
+
886
+ ## L1 Title 1
887
+
888
+ First level content.
889
+
890
+ ### L1S1
891
+
892
+ The first step
893
+
894
+ #### Hints
895
+
896
+ * First Hint with \`markdown\`. See **bold**
897
+ * Second Hint has a codeblock
898
+
899
+ \`\`\`js
900
+ var a = 1;
901
+ \`\`\`
902
+
903
+ And spans multiple lines.
904
+ ` ;
905
+ const skeleton = {
906
+ levels : [
907
+ {
908
+ id : "L1" ,
909
+ steps : [
910
+ {
911
+ id : "L1S1" ,
912
+ } ,
913
+ ] ,
914
+ } ,
915
+ ] ,
916
+ } ;
917
+ const result = parse ( {
918
+ text : md ,
919
+ skeleton,
920
+ commits : {
921
+ L1S1Q : [ "abcdef1" , "123456789" ] ,
922
+ } ,
923
+ } ) ;
924
+ const expected = {
925
+ summary : {
926
+ description : "Description." ,
927
+ } ,
928
+ levels : [
929
+ {
930
+ id : "L1" ,
931
+ title : "Title 1" ,
932
+ summary : "First level content." ,
933
+ content : "First level content." ,
934
+ steps : [
935
+ {
936
+ id : "L1S1" ,
937
+ content : "The first step" ,
938
+ setup : {
939
+ commits : [ "abcdef1" , "123456789" ] ,
940
+ } ,
941
+ hints : [
942
+ "First Hint with `markdown`. See **bold**" ,
943
+ "Second Hint has a codeblock\n\n```js\nvar a = 1;\n```\n\nAnd spans multiple lines." ,
944
+ ] ,
945
+ } ,
946
+ ] ,
947
+ } ,
948
+ ] ,
949
+ } ;
950
+ expect ( result . levels ) . toEqual ( expected . levels ) ;
951
+ } ) ;
952
+
953
+ it ( "should parse hints and not interrupt next step" , ( ) => {
954
+ const md = `# Title
955
+
956
+ Description.
957
+
958
+ ## L1 Title 1
959
+
960
+ First level content.
961
+
962
+ ### L1S1
963
+
964
+ The first step
965
+
966
+ #### Hints
967
+
968
+ * First Hint with \`markdown\`. See **bold**
969
+ * Second Hint has a codeblock
970
+
971
+ \`\`\`js
972
+ var a = 1;
973
+ \`\`\`
974
+
975
+ And spans multiple lines.
976
+
977
+ ### L1S2A
978
+
979
+ The second uninterrupted step
980
+ ` ;
981
+ const skeleton = {
982
+ levels : [
983
+ {
984
+ id : "L1" ,
985
+ steps : [
986
+ {
987
+ id : "L1S1" ,
988
+ } ,
989
+ {
990
+ id : "L1S2" ,
991
+ } ,
992
+ ] ,
993
+ } ,
994
+ ] ,
995
+ } ;
996
+ const result = parse ( {
997
+ text : md ,
998
+ skeleton,
999
+ commits : {
1000
+ L1S1Q : [ "abcdef1" , "123456789" ] ,
1001
+ L1S2Q : [ "fedcba1" ] ,
1002
+ } ,
1003
+ } ) ;
1004
+ const expected = {
1005
+ summary : {
1006
+ description : "Description." ,
1007
+ } ,
1008
+ levels : [
1009
+ {
1010
+ id : "L1" ,
1011
+ title : "Title 1" ,
1012
+ summary : "First level content." ,
1013
+ content : "First level content." ,
1014
+ steps : [
1015
+ {
1016
+ id : "L1S1" ,
1017
+ content : "The first step" ,
1018
+ setup : {
1019
+ commits : [ "abcdef1" , "123456789" ] ,
1020
+ } ,
1021
+ hints : [
1022
+ "First Hint with `markdown`. See **bold**" ,
1023
+ "Second Hint has a codeblock\n\n```js\nvar a = 1;\n```\n\nAnd spans multiple lines." ,
1024
+ ] ,
1025
+ } ,
1026
+ {
1027
+ id : "L1S2" ,
1028
+ content : "The second uninterrupted step" ,
1029
+ setup : {
1030
+ commits : [ "fedcba1" ] ,
1031
+ } ,
1032
+ } ,
1033
+ ] ,
1034
+ } ,
1035
+ { } ,
1036
+ ] ,
1037
+ } ;
1038
+ expect ( result . levels ) . toEqual ( expected . levels ) ;
1039
+ } ) ;
815
1040
} ) ;
0 commit comments