Commit c22975ff5c372669572525d717f2296ea5c14129
fix isBlog to handle null summary/ thumbail
mix irving committed on 5/28/2018, 4:24:27 AMParent: 0d98a03886c5b5f3da8235f442e83c86a9b7794a
Files changed
schema/blog.js | changed |
tests/sync/isBlog.js | changed |
schema/blog.js | ||
---|---|---|
@@ -7,9 +7,19 @@ | ||
7 | 7 … | properties: { |
8 | 8 … | type: {type: 'string', pattern: 'blog'}, |
9 | 9 … | title: {type: 'string'}, |
10 | 10 … | blog: {type: 'string', pattern: blobIdRegex}, |
11 | - summary: {type: 'string'}, | |
12 | - thumbnail: {type: 'string', pattern: blobIdRegex}, | |
11 … | + summary: { | |
12 … | + oneOf: [ | |
13 … | + {type: 'string'}, | |
14 … | + {type: 'null'} | |
15 … | + ] | |
16 … | + }, | |
17 … | + thumbnail: { | |
18 … | + oneOf: [ | |
19 … | + {type: 'string', pattern: blobIdRegex}, | |
20 … | + {type: 'null'} | |
21 … | + ] | |
22 … | + }, | |
13 | 23 … | channel: {type: 'string'} |
14 | 24 … | } |
15 | 25 … | } |
tests/sync/isBlog.js | |||
---|---|---|---|
@@ -17,8 +17,16 @@ | |||
17 | 17 … | blog: '&sfoIYo0kKKGI+TJYnznVDSs3BM/HjMWdCPXirvj9BfE=.sha256' | |
18 | 18 … | } | |
19 | 19 … | t.ok(isBlog(simpleBlog), 'validates simple blog') | |
20 | 20 … | ||
21 … | + const emptyThumbnail = { | ||
22 … | + type: 'blog', | ||
23 … | + title: 'An important idea', | ||
24 … | + blog: '&sfoIYo0kKKGI+TJYnznVDSs3BM/HjMWdCPXirvj9BfE=.sha256', | ||
25 … | + thumbnail: null | ||
26 … | + } | ||
27 … | + t.ok(isBlog(emptyThumbnail), 'validates simple blog with empty thumbnail') | ||
28 … | + | ||
21 | 29 … | const incompleteBlog = { | |
22 | 30 … | type: 'blog', | |
23 | 31 … | title: 'An important idea' | |
24 | 32 … | } | |
@@ -68,7 +76,8 @@ | |||
68 | 76 … | 'dest': '#cooperative', | |
69 | 77 … | 'rts': 1518568914727 | |
70 | 78 … | } | |
71 | 79 … | t.ok(isBlog(actualBlog), 'validates a blog from ticktack') | |
80 … | + if (!isBlog(actualBlog)) console.log(isBlog.errors) | ||
72 | 81 … | ||
73 | 82 … | t.end() | |
74 | 83 … | }) |
Built with git-ssb-web