@@ -2,6 +2,48 @@ import * as T from "../typings/tutorial";
22import tutorialSchema from "../src/schema/tutorial" ;
33import { validateSchema } from "../src/utils/validateSchema" ;
44
5+ const validJson : Partial < T . Tutorial > = {
6+ version : "0.1.0" ,
7+ summary : { title : "Title" , description : "Description" } ,
8+ config : {
9+ testRunner : {
10+ command : "aCommand" ,
11+ args : {
12+ filter : "filter" ,
13+ tap : "tap" ,
14+ } ,
15+ directory : "coderoad" ,
16+ setup : {
17+ commits : [ "abcdef1" ] ,
18+ commands : [ "npm install" ] ,
19+ } ,
20+ } ,
21+ repo : {
22+ uri : "https://github.com/some-repo.git" ,
23+ branch : "someBranch" ,
24+ } ,
25+ dependencies : [ { name : "name" , version : ">=1" } ] ,
26+ appVersions : {
27+ vscode : ">=0.7.0" ,
28+ } ,
29+ } ,
30+ levels : [
31+ {
32+ id : "1" ,
33+ title : "Level 1" ,
34+ summary : "The first level" ,
35+ content : "The first level" ,
36+ steps : [
37+ {
38+ id : "1.1" ,
39+ content : "The first step" ,
40+ setup : { commits : [ ] } ,
41+ } ,
42+ ] ,
43+ } ,
44+ ] ,
45+ } ;
46+
547const validateTutorial = ( json : any ) => validateSchema ( tutorialSchema , json ) ;
648
749describe ( "validate tutorial" , ( ) => {
@@ -12,37 +54,18 @@ describe("validate tutorial", () => {
1254 expect ( valid ) . toBe ( false ) ;
1355 } ) ;
1456 it ( "should return true for a valid tutorial" , ( ) => {
15- const json : Partial < T . Tutorial > = {
16- version : "0.1.0" ,
17- summary : { title : "Title" , description : "Description" } ,
18- config : {
19- testRunner : {
20- command : "aCommand" ,
21- args : {
22- filter : "filter" ,
23- tap : "tap" ,
24- } ,
25- directory : "coderoad" ,
26- setup : {
27- commits : [ "abcdef1" ] ,
28- commands : [ "npm install" ] ,
29- } ,
30- } ,
31- repo : {
32- uri : "https://github.com/some-repo.git" ,
33- branch : "someBranch" ,
34- } ,
35- dependencies : [ { name : "name" , version : ">=1" } ] ,
36- appVersions : {
37- vscode : ">=0.7.0" ,
38- } ,
39- } ,
57+ const valid = validateTutorial ( { ...validJson } ) ;
58+ expect ( valid ) . toBe ( true ) ;
59+ } ) ;
60+ it ( "should return true for a tutorial with no level content" , ( ) => {
61+ const json = {
62+ ...validJson ,
4063 levels : [
4164 {
4265 id : "1" ,
4366 title : "Level 1" ,
44- summary : "The first level " ,
45- content : "The first level " ,
67+ summary : "" ,
68+ content : "" ,
4669 steps : [ ] ,
4770 } ,
4871 ] ,
0 commit comments