UNPKG

1.87 kBJavaScriptView Raw
1/*
2Kettle Data Source JSON tests
3
4Copyright 2012-2015 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// JSON parsing and diagnostics tests
21
22fluid.defaults("kettle.tests.dataSourceJSONTester", {
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/invalidJSONFile.json"
32 }
33 },
34 testCaseHolder: {
35 type: "fluid.test.testCaseHolder",
36 options: {
37 modules: [{
38 name: "Kettle JSON parsing Tests",
39 tests: [{
40 expect: 2,
41 name: "JSON line number diagnostic test",
42 sequence: [{
43 funcName: "kettle.tests.fallibleDataSourceRead",
44 args: ["{faultyJSONDataSource}"]
45 }, {
46 event: "{testEnvironment}.events.onError",
47 listener: "kettle.tests.expectJSONDiagnostic"
48 }
49 ]
50 }]
51 }]
52 }
53 }
54 }
55});
56
57
58kettle.tests.fallibleDataSourceRead = function (dataSource) {
59 dataSource.get(); // we expect failure - forwarded to root handler
60};
61
62fluid.test.runTests(["kettle.tests.dataSourceJSONTester"]);