@@ -5,52 +5,83 @@ import getLastCommitHash from './lastHash'
55describe ( 'lastHash' , ( ) => {
66 it ( 'should grab the last passing hash from a step' , ( ) => {
77 const position : T . Position = { levelId : '1' , stepId : '1.2' }
8- const levels : TT . Level [ ] = [
9- {
10- id : '1' ,
11- title : '' ,
12- summary : '' ,
13- content : '' ,
14- steps : [
15- {
16- id : '1.1' ,
17- content : '' ,
18- setup : { commits : [ 'abcdef1' ] } ,
19- } ,
20- {
21- id : '1.2' ,
22- content : '' ,
23- setup : { commits : [ 'abcdef2' ] } ,
24- } ,
25- ] ,
26- } ,
27- ]
28- const result = getLastCommitHash ( position , levels )
8+ // @ts -ignore
9+ const tutorial : TT . Tutorial = {
10+ levels : [
11+ {
12+ id : '1' ,
13+ title : '' ,
14+ summary : '' ,
15+ content : '' ,
16+ steps : [
17+ {
18+ id : '1.1' ,
19+ content : '' ,
20+ setup : { commits : [ 'abcdef1' ] } ,
21+ } ,
22+ {
23+ id : '1.2' ,
24+ content : '' ,
25+ setup : { commits : [ 'abcdef2' ] } ,
26+ } ,
27+ ] ,
28+ } ,
29+ ] ,
30+ }
31+ const result = getLastCommitHash ( position , tutorial )
2932 expect ( result ) . toBe ( 'abcdef2' )
3033 } )
3134 it ( 'should grab the last passing hash from a step with several commits' , ( ) => {
3235 const position : T . Position = { levelId : '1' , stepId : '1.2' }
33- const levels : TT . Level [ ] = [
34- {
35- id : '1' ,
36- title : '' ,
37- summary : '' ,
38- content : '' ,
39- steps : [
40- {
41- id : '1.1' ,
42- content : '' ,
43- setup : { commits : [ 'abcdef1' ] } ,
44- } ,
45- {
46- id : '1.2' ,
47- content : '' ,
48- setup : { commits : [ 'abcdef2' , 'abcdef3' ] } ,
36+ // @ts -ignore
37+ const tutorial : TT . Tutorial = {
38+ levels : [
39+ {
40+ id : '1' ,
41+ title : '' ,
42+ summary : '' ,
43+ content : '' ,
44+ steps : [
45+ {
46+ id : '1.1' ,
47+ content : '' ,
48+ setup : { commits : [ 'abcdef1' ] } ,
49+ } ,
50+ {
51+ id : '1.2' ,
52+ content : '' ,
53+ setup : { commits : [ 'abcdef2' , 'abcdef3' ] } ,
54+ } ,
55+ ] ,
56+ } ,
57+ ] ,
58+ }
59+ const result = getLastCommitHash ( position , tutorial )
60+ expect ( result ) . toBe ( 'abcdef3' )
61+ } )
62+ it ( 'should grab the last passing hash when level has no steps' , ( ) => {
63+ const position : T . Position = { levelId : '1' , stepId : null }
64+ // @ts -ignore
65+ const tutorial : TT . Tutorial = {
66+ config : {
67+ // @ts -ignore
68+ testRunner : {
69+ setup : {
70+ commits : [ 'abcdef2' , 'abcdef3' ] ,
4971 } ,
50- ] ,
72+ } ,
5173 } ,
52- ]
53- const result = getLastCommitHash ( position , levels )
74+ levels : [
75+ {
76+ id : '1' ,
77+ title : '' ,
78+ summary : '' ,
79+ content : '' ,
80+ steps : [ ] ,
81+ } ,
82+ ] ,
83+ }
84+ const result = getLastCommitHash ( position , tutorial )
5485 expect ( result ) . toBe ( 'abcdef3' )
5586 } )
5687} )
0 commit comments