Skip to content

Commit

Permalink
Add simple test to ensure linter doesn't blow up on .tsx files
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya committed Aug 5, 2015
1 parent 021aaa2 commit 60935a1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/files/tsx/react.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as React from 'react'; // quotemark failure

export class MyComponent extends React.Component<{}, {}> {
//
}
2 changes: 2 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"./helper.ts",
"./ruleDisableEnableTests.ts",
"./ruleLoaderTests.ts",
"./tsxTests.ts",
"./formatters/*.ts",
"./rules/*.ts"
],
Expand All @@ -29,6 +30,7 @@
"./helper.ts",
"./ruleDisableEnableTests.ts",
"./ruleLoaderTests.ts",
"./tsxTests.ts",
"./formatters/externalFormatterTest.ts",
"./formatters/jsonFormatterTests.ts",
"./formatters/pmdFormatterTests.ts",
Expand Down
40 changes: 40 additions & 0 deletions test/tsxTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

describe("Linter applied to TSX syntax", () => {
const fs = require("fs");
const path = require("path");
const fileName = "react.test.tsx";

it("doesn't blow up", () => {
const validConfiguration = {};
const relativePath = path.join("test", "files", "tsx", fileName);
const source = fs.readFileSync(relativePath, "utf8");

const options: Lint.ILinterOptions = {
configuration: validConfiguration,
formatter: "json",
formattersDirectory: null,
rulesDirectory: null
};

const ll = new Lint.Linter(relativePath, source, options);
const result = ll.lint();
const parsedResult = JSON.parse(result.output);

assert.lengthOf(parsedResult, 0);
});
});

0 comments on commit 60935a1

Please sign in to comment.