@@ -2,6 +2,48 @@ import * as T from "../typings/tutorial";
2
2
import tutorialSchema from "../src/schema/tutorial" ;
3
3
import { validateSchema } from "../src/utils/validateSchema" ;
4
4
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
+
5
47
const validateTutorial = ( json : any ) => validateSchema ( tutorialSchema , json ) ;
6
48
7
49
describe ( "validate tutorial" , ( ) => {
@@ -12,37 +54,18 @@ describe("validate tutorial", () => {
12
54
expect ( valid ) . toBe ( false ) ;
13
55
} ) ;
14
56
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 ,
40
63
levels : [
41
64
{
42
65
id : "1" ,
43
66
title : "Level 1" ,
44
- summary : "The first level " ,
45
- content : "The first level " ,
67
+ summary : "" ,
68
+ content : "" ,
46
69
steps : [ ] ,
47
70
} ,
48
71
] ,
0 commit comments