forked from breck7/ScrollHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScrollHub.test.js
executable file
·97 lines (88 loc) · 2.44 KB
/
ScrollHub.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /usr/bin/env node
const tap = require("tap")
const fs = require("fs")
const path = require("path")
const { TestRacer } = require("scrollsdk/products/TestRacer.js")
const { ScrollHub } = require("./ScrollHub.js")
const testParticles = {}
testParticles.basics = areEqual => {
// Arrange
const hub = new ScrollHub()
// Act/Assert
areEqual(!!hub, true)
}
testParticles.create = areEqual => {
// Arrange
const hub = new ScrollHub()
const testCases = {
"http://pldb.io pldb7": {
errorMessage: undefined,
folderName: "pldb7",
template: "http://pldb.io"
},
foobar: {
errorMessage: undefined,
folderName: "foobar",
template: "blank_template"
},
"http://pldb.io": {
errorMessage: undefined,
folderName: "pldb.io",
template: "http://pldb.io"
},
"gallery_template my copy": {
errorMessage: undefined,
folderName: "mycopy",
template: "gallery_template",
folderCache: { gallery_template: true }
},
"missing my copy": {
errorMessage: undefined,
folderName: "missingmycopy",
template: "blank_template"
}
}
// Act/ Assert
Object.keys(testCases).forEach(key => {
const theCase = testCases[key]
const result = hub.makeFolderNameAndTemplateFromInput(key, theCase.folderCache || {})
const keys = "folderName template errorMessage".split(" ")
keys.forEach(testKey => areEqual(result[testKey], theCase[testKey], `${testKey} did not match`))
})
}
testParticles.writeFlow = async areEqual => {
// Arrange
const testCases = {
"foo.scroll": {
error: undefined,
content: ``,
expected: ``
},
"foo2.scroll": {
error: undefined,
content: `\r\r`,
expected: ``
},
"foo.css": {
error: undefined,
content: ` body { color: red; }`,
expected: `body {\n color: red;\n}\n`
},
"foo.docx": {
error: true,
content: ``,
expected: ``
}
}
const hub = new ScrollHub()
// todo:
// // Act/ Assert
// Object.keys(testCases).forEach(filename => {
// const theCase = testCases[key]
// const result = hub.writeAndCommitTextFile(filename, theCase.content)
// const keys = "content error".split(" ")
// keys.forEach(testKey => areEqual(result[testKey], theCase[testKey], `${testKey} did not match`))
// })
}
if (module && !module.parent) TestRacer.testSingleFile(__filename, testParticles)
module.exports = { testParticles }