Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #852 from palantir/cleanup-test
Browse files Browse the repository at this point in the history
Cleanup test/
  • Loading branch information
adidahiya committed Dec 7, 2015
2 parents a828771 + 9f45172 commit 9d2d66b
Show file tree
Hide file tree
Showing 76 changed files with 983 additions and 902 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.DS_Store
.tscache/
build/
bin/tslint-cli.js
lib/
/build/
/lib/
node_modules/
tscommand*.txt
# created by grunt-ts for faster compiling
Expand Down
10 changes: 7 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
.DS_Store
.gitmodules
.jscsrc
.project
.settings
.travis.yml
.tslintrc
.vscode
appveyor.yml
Gruntfile.js
tslint.json
build/tslint-tests.js
src/
test/
/build/
/src/
/test/
tscommand*.txt
Empty file removed lib/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion src/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
Expand Down
5 changes: 3 additions & 2 deletions src/rules/noNullKeywordRule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
/**
* @license
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,8 +17,8 @@

// with due reference to https://github.com/Microsoft/TypeScript/blob/7813121c4d77e50aad0eed3152ef1f1156c7b574/scripts/tslint/noNullRule.ts

import * as Lint from "../lint";
import * as ts from "typescript";
import * as Lint from "../lint";

export class Rule extends Lint.Rules.AbstractRule {
public static FAILURE_STRING = "Use 'undefined' instead of 'null'";
Expand Down
12 changes: 9 additions & 3 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@
"rewriteTsconfig": false
},
"filesGlob": [
"../typings/tsd.d.ts",
"../typings/**/*.d.ts",
"./*.ts",
"./formatters/**/*.ts",
"./language/**/*.ts",
"./rules/**/*.ts"
],
"files": [
"../typings/tsd.d.ts",
"../typings/findup-sync/findup-sync.d.ts",
"../typings/glob/glob.d.ts",
"../typings/minimatch/minimatch.d.ts",
"../typings/node/node.d.ts",
"../typings/optimist/optimist.d.ts",
"../typings/underscore.string/underscore.string.d.ts",
"../typings/underscore/underscore.d.ts",
"configuration.ts",
"enableDisableRules.ts",
"formatterLoader.ts",
Expand Down Expand Up @@ -102,4 +108,4 @@
"rules/variableNameRule.ts",
"rules/whitespaceRule.ts"
]
}
}
6 changes: 6 additions & 0 deletions test/references.ts → test/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
* limitations under the License.
*/

declare namespace NodeJS {
interface Global {
assert: Chai.Assert;
}
}

/* tslint:disable:no-var-keyword */
var assert: Chai.Assert = require("chai").assert;
global.assert = assert;
Expand Down
11 changes: 0 additions & 11 deletions test/chaiAssert.d.ts

This file was deleted.

123 changes: 61 additions & 62 deletions test/formatters/externalFormatterTest.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,61 @@
/*
* 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.
*/
import * as Lint from "../lint";
import * as ts from "typescript";

describe("External Formatter", () => {
const TEST_FILE = "formatters/externalFormatter.test.ts";
const TEST_MODULE = "../../test/files/formatters/simple";
let sourceFile: ts.SourceFile;
let formatter: Lint.IFormatter;

before(() => {
const Formatter = Lint.Test.getFormatter(TEST_MODULE);
sourceFile = Lint.Test.getSourceFile(TEST_FILE);
formatter = new Formatter();
});

it("formats failures", () => {
const maxPosition = sourceFile.getFullWidth();

const failures = [
new Lint.RuleFailure(sourceFile, 0, 1, "first failure", "first-name"),
new Lint.RuleFailure(sourceFile, 32, 36, "mid failure", "mid-name"),
new Lint.RuleFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name")
];

const expectedResult =
getPositionString(1, 1) + TEST_FILE + "\n" +
getPositionString(2, 11) + TEST_FILE + "\n" +
getPositionString(9, 2) + TEST_FILE + "\n";

const actualResult = formatter.format(failures);

assert.equal(actualResult, expectedResult);
});

it("returns undefined for unresolvable module", () => {
assert.isUndefined(Lint.Test.getFormatter(TEST_FILE + "/__non-existent__"));
});

it("handles no failures", () => {
const result = formatter.format([]);
assert.equal(result, "");
});

function getPositionString(line: number, character: number) {
return "[" + line + ", " + character + "]";
}
});
/*
* 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.
*/

import * as ts from "typescript";
import {IFormatter, RuleFailure, TestUtils} from "../lint";

describe("External Formatter", () => {
const TEST_FILE = "formatters/externalFormatter.test.ts";
const TEST_MODULE = "../../test/files/formatters/simple";
let sourceFile: ts.SourceFile;
let formatter: IFormatter;

before(() => {
const Formatter = TestUtils.getFormatter(TEST_MODULE);
sourceFile = TestUtils.getSourceFile(TEST_FILE);
formatter = new Formatter();
});

it("formats failures", () => {
const maxPosition = sourceFile.getFullWidth();
const failures = [
new RuleFailure(sourceFile, 0, 1, "first failure", "first-name"),
new RuleFailure(sourceFile, 32, 36, "mid failure", "mid-name"),
new RuleFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name")
];

const expectedResult =
getPositionString(1, 1) + TEST_FILE + "\n" +
getPositionString(2, 11) + TEST_FILE + "\n" +
getPositionString(9, 2) + TEST_FILE + "\n";

const actualResult = formatter.format(failures);
assert.equal(actualResult, expectedResult);
});

it("returns undefined for unresolvable module", () => {
assert.isUndefined(TestUtils.getFormatter(TEST_FILE + "/__non-existent__"));
});

it("handles no failures", () => {
const result = formatter.format([]);
assert.equal(result, "");
});

function getPositionString(line: number, character: number) {
return "[" + line + ", " + character + "]";
}
});
15 changes: 8 additions & 7 deletions test/formatters/jsonFormatterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as Lint from "../lint";

import * as ts from "typescript";
import {IFormatter, RuleFailure, TestUtils} from "../lint";

describe("JSON Formatter", () => {
const TEST_FILE = "formatters/jsonFormatter.test.ts";
let sourceFile: ts.SourceFile;
let formatter: Lint.IFormatter;
let formatter: IFormatter;

before(() => {
const Formatter = Lint.Test.getFormatter("json");
sourceFile = Lint.Test.getSourceFile(TEST_FILE);
const Formatter = TestUtils.getFormatter("json");
sourceFile = TestUtils.getSourceFile(TEST_FILE);
formatter = new Formatter();
});

it("formats failures", () => {
const maxPosition = sourceFile.getFullWidth();

const failures = [
new Lint.RuleFailure(sourceFile, 0, 1, "first failure", "first-name"),
new Lint.RuleFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name"),
new Lint.RuleFailure(sourceFile, 0, maxPosition, "full failure", "full-name")
new RuleFailure(sourceFile, 0, 1, "first failure", "first-name"),
new RuleFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name"),
new RuleFailure(sourceFile, 0, maxPosition, "full failure", "full-name")
];

/* tslint:disable:object-literal-sort-keys */
Expand Down
17 changes: 9 additions & 8 deletions test/formatters/pmdFormatterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as Lint from "../lint";

import * as ts from "typescript";
import {IFormatter, RuleFailure, TestUtils} from "../lint";

describe("PMD Formatter", () => {
const TEST_FILE = "formatters/pmdFormatter.test.ts";
let sourceFile: ts.SourceFile;
let formatter: Lint.IFormatter;
let formatter: IFormatter;

before(() => {
const Formatter = Lint.Test.getFormatter("pmd");
sourceFile = Lint.Test.getSourceFile(TEST_FILE);
const Formatter = TestUtils.getFormatter("pmd");
sourceFile = TestUtils.getSourceFile(TEST_FILE);
formatter = new Formatter();
});

it("formats failures", () => {
const maxPosition = sourceFile.getFullWidth();

const failures = [
new Lint.RuleFailure(sourceFile, 0, 1, "first failure", "first-name"),
new Lint.RuleFailure(sourceFile, 2, 3, "&<>'\" should be escaped", "escape"),
new Lint.RuleFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name"),
new Lint.RuleFailure(sourceFile, 0, maxPosition, "full failure", "full-name")
new RuleFailure(sourceFile, 0, 1, "first failure", "first-name"),
new RuleFailure(sourceFile, 2, 3, "&<>'\" should be escaped", "escape"),
new RuleFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name"),
new RuleFailure(sourceFile, 0, maxPosition, "full failure", "full-name")
];
const expectedResult =
"<pmd version=\"tslint\">" +
Expand Down
15 changes: 8 additions & 7 deletions test/formatters/proseFormatterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as Lint from "../lint";

import * as ts from "typescript";
import {IFormatter, RuleFailure, TestUtils} from "../lint";

describe("Prose Formatter", () => {
const TEST_FILE = "formatters/proseFormatter.test.ts";
let sourceFile: ts.SourceFile;
let formatter: Lint.IFormatter;
let formatter: IFormatter;

before(() => {
const Formatter = Lint.Test.getFormatter("prose");
sourceFile = Lint.Test.getSourceFile(TEST_FILE);
const Formatter = TestUtils.getFormatter("prose");
sourceFile = TestUtils.getSourceFile(TEST_FILE);
formatter = new Formatter();
});

it("formats failures", () => {
const maxPosition = sourceFile.getFullWidth();

const failures = [
new Lint.RuleFailure(sourceFile, 0, 1, "first failure", "first-name"),
new Lint.RuleFailure(sourceFile, 32, 36, "mid failure", "mid-name"),
new Lint.RuleFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name")
new RuleFailure(sourceFile, 0, 1, "first failure", "first-name"),
new RuleFailure(sourceFile, 32, 36, "mid failure", "mid-name"),
new RuleFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name")
];

const expectedResult =
Expand Down
15 changes: 8 additions & 7 deletions test/formatters/verboseFormatterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as Lint from "../lint";

import * as ts from "typescript";
import {IFormatter, RuleFailure, TestUtils} from "../lint";

describe("Verbose Formatter", () => {
const TEST_FILE = "formatters/proseFormatter.test.ts";
let sourceFile: ts.SourceFile;
let formatter: Lint.IFormatter;
let formatter: IFormatter;

before(() => {
const Formatter = Lint.Test.getFormatter("verbose");
sourceFile = Lint.Test.getSourceFile(TEST_FILE);
const Formatter = TestUtils.getFormatter("verbose");
sourceFile = TestUtils.getSourceFile(TEST_FILE);
formatter = new Formatter();
});

it("formats failures", () => {
const maxPosition = sourceFile.getFullWidth();

const failures = [
new Lint.RuleFailure(sourceFile, 0, 1, "first failure", "first-name"),
new Lint.RuleFailure(sourceFile, 32, 36, "mid failure", "mid-name"),
new Lint.RuleFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name")
new RuleFailure(sourceFile, 0, 1, "first failure", "first-name"),
new RuleFailure(sourceFile, 32, 36, "mid failure", "mid-name"),
new RuleFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name")
];

const expectedResult =
Expand Down
Loading

0 comments on commit 9d2d66b

Please sign in to comment.