Add json reader and its tests

This commit is contained in:
Vit Brunner
2013-06-10 23:55:55 +01:00
parent a5ce7c9f15
commit 9a4fce961b
4 changed files with 51 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
test("jsonReader", () ->
injector = angular.injector(["ng", "sideBySide"])
jsonReader = injector.get("jsonReader")
testCases = [{
tested: """
{
meta: {
Title: "Test leading text"
},
content: [
"<p><strong>This</strong> is leading text.</p>",
{ section: "I", text: "<p>First section.</p>" },
{ section: "II", text: "<p>Second section.</p>" },
{ text: "<p>Another section.</p>" },
],
}"""
expected: {
meta: {
Title: "Test leading text"
}
content: [
{ section: "", text: "<p><strong>This</strong> is leading text.</p>" }
{ section: "I", text: "<p>First section.</p>" }
{ section: "II", text: "<p>Second section.</p>" }
{ section: "", text: "<p>Another section.</p>" }
]
}
}]
for testCase in testCases
deepEqual(jsonReader(testCase.tested), testCase.expected)
)