UNPKG

2.04 kBJavaScriptView Raw
1/*
2Kettle Data Source JSON5 tests
3
4Copyright 2012-2016 Raising the Floor - International
5
6Licensed under the New BSD license. You may not use this file except in
7compliance with this License.
8
9You may obtain a copy of the License at
10https://github.com/fluid-project/kettle/blob/master/LICENSE.txt
11*/
12
13"use strict";
14
15var fluid = require("infusion"),
16 kettle = require("../kettle.js");
17
18require("./shared/DataSourceTestUtils.js");
19
20// JSON5 parsing and diagnostics tests
21
22fluid.defaults("kettle.tests.dataSourceJSON5Tester", {
23 gradeNames: ["fluid.test.testEnvironment", "kettle.tests.dataSource.onErrorLink"],
24 events: {
25 onError: null
26 },
27 components: {
28 faultyJSONDataSource: {
29 type: "kettle.dataSource.file.moduleTerms",
30 options: {
31 path: "%kettle/tests/data/invalid/invalidJSON5File.json5",
32 components: {
33 encoding: {
34 type: "kettle.dataSource.encoding.JSON5"
35 }
36 }
37 }
38 },
39 testCaseHolder: {
40 type: "fluid.test.testCaseHolder",
41 options: {
42 modules: [{
43 name: "Kettle JSON parsing Tests",
44 tests: [{
45 expect: 2,
46 name: "JSON line number diagnostic test",
47 sequence: [{
48 funcName: "kettle.tests.fallibleDataSourceRead",
49 args: ["{faultyJSONDataSource}"]
50 }, {
51 event: "{testEnvironment}.events.onError",
52 listener: "kettle.tests.expectJSON5Diagnostic"
53 }
54 ]
55 }]
56 }]
57 }
58 }
59 }
60});
61
62
63kettle.tests.fallibleDataSourceRead = function (dataSource) {
64 dataSource.get(); // we expect failure - forwarded to root handler
65};
66
67fluid.test.runTests(["kettle.tests.dataSourceJSON5Tester"]);