Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5eed956

Browse files
committed
setup hint tests
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent811b701 commit5eed956

File tree

2 files changed

+231
-0
lines changed

2 files changed

+231
-0
lines changed

‎src/templates/TUTORIAL.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ Short description of the step's purpose. Should be short and fit in one line
3636
###L1S2 Another step
3737

3838
Step's short description.
39+
40+
####Hints
41+
42+
- If a hint exists, the user can request a hint
43+
- Hints will show up in the order they are written
44+
- When all hints are added, the hint option will become disabled

‎tests/parse.test.ts

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,4 +812,229 @@ Description.
812812
};
813813
expect(result.config).toEqual(expected.config);
814814
});
815+
816+
// hints
817+
it("should parse hints for a step",()=>{
818+
constmd=`# 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+
constskeleton={
837+
levels:[
838+
{
839+
id:"L1",
840+
steps:[
841+
{
842+
id:"L1S1",
843+
},
844+
],
845+
},
846+
],
847+
};
848+
constresult=parse({
849+
text:md,
850+
skeleton,
851+
commits:{
852+
L1S1Q:["abcdef1","123456789"],
853+
},
854+
});
855+
constexpected={
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+
constmd=`# 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+
constskeleton={
906+
levels:[
907+
{
908+
id:"L1",
909+
steps:[
910+
{
911+
id:"L1S1",
912+
},
913+
],
914+
},
915+
],
916+
};
917+
constresult=parse({
918+
text:md,
919+
skeleton,
920+
commits:{
921+
L1S1Q:["abcdef1","123456789"],
922+
},
923+
});
924+
constexpected={
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+
constmd=`# 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+
constskeleton={
982+
levels:[
983+
{
984+
id:"L1",
985+
steps:[
986+
{
987+
id:"L1S1",
988+
},
989+
{
990+
id:"L1S2",
991+
},
992+
],
993+
},
994+
],
995+
};
996+
constresult=parse({
997+
text:md,
998+
skeleton,
999+
commits:{
1000+
L1S1Q:["abcdef1","123456789"],
1001+
L1S2Q:["fedcba1"],
1002+
},
1003+
});
1004+
constexpected={
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+
});
8151040
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp