Skip to content

Commit

Permalink
Merge pull request Azure#2 from arpanlaha/ts
Browse files Browse the repository at this point in the history
Initial processor testing
  • Loading branch information
arpanlaha authored Jun 10, 2019
2 parents 5da61a4 + e04aa8c commit 12b4a43
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
"url": "https://github.com/arpanlaha/eslint-plugin-azure"
},
"dependencies": {
"@types/chai": "^4.1.7",
"typescript": "<3.5.1"
},
"devDependencies": {
"@types/eslint": "^4.16.6",
"@types/estree": "0.0.39",
"@types/mocha": "^5.2.7",
"@typescript-eslint/eslint-plugin": "^1.9.0",
"@typescript-eslint/experimental-utils": "^1.9.0",
"@typescript-eslint/parser": "^1.9.0",
"@typescript-eslint/typescript-estree": "^1.9.0",
"chai": "^4.2.0",
"eslint": "^5.16.0",
"mocha": "^6.1.4",
"ts-mocha": "^6.0.0"
Expand Down
55 changes: 55 additions & 0 deletions tests/processors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @fileoverview Testing processors
* @author Arpan Laha
*/

import * as plugin from "../src";
import { assert } from "chai";

/**
* Test structure taken from https://github.com/azeemba/eslint-plugin-json/blob/master/test/test.js
*/
describe("plugin", function() {
describe("structure", function() {
it("processors should a member of the plugin", function() {
assert.property(
plugin,
"processors",
"processors is not a member of the plugin"
);
});
it(".json should be a member of processors", function() {
assert.property(
plugin.processors,
".json",
".json is not a member of processors"
);
});
it("preprocess should be a member of .json", function() {
assert.property(
plugin.processors[".json"],
"preprocess",
"preprocess is not a member of .json"
);
});
it("postprocess should be a member of .json", function() {
assert.property(
plugin.processors[".json"],
"postprocess",
"postprocess is not a member of .json"
);
});
});
describe("preprocess", function() {
const preprocess = plugin.processors[".json"].preprocess;
it("preprocess should prepend 'const json = ' to the input and return its singleton array", function() {
const input = "input";
const output = preprocess(input);
assert.isArray(output, "preprocess should always return an array");
assert.strictEqual(output[0], "const json = input");
});
});
/**
* TODO: Implement postprocess tests after functionality complete
*/
});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"pretty": true,
"strict": true,
"target": "es6",
"types": ["eslint", "estree"]
"types": ["chai", "eslint", "estree", "mocha"]
},
"exclude": ["node_modules"]
}

0 comments on commit 12b4a43

Please sign in to comment.