Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Replace global comment integration test with unit test (refs #81) #85

Merged
merged 1 commit into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions tests/fixtures/long.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,4 @@ console.log("Error!");
!@#$%^&*()
```

```js
foo
```

<!-- global foo -->

```js
foo
```

The end.
5 changes: 1 addition & 4 deletions tests/lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe("plugin", function() {
var report = cli.executeOnFiles([path.resolve(__dirname, "../fixtures/long.md")]);

assert.equal(report.results.length, 1);
assert.equal(report.results[0].messages.length, 6);
assert.equal(report.results[0].messages.length, 5);
assert.equal(report.results[0].messages[0].message, "Unexpected console statement.");
assert.equal(report.results[0].messages[0].line, 10);
assert.equal(report.results[0].messages[0].column, 1);
Expand All @@ -92,9 +92,6 @@ describe("plugin", function() {
assert.equal(report.results[0].messages[4].message, "Parsing error: Unexpected character '@'");
assert.equal(report.results[0].messages[4].line, 46);
assert.equal(report.results[0].messages[4].column, 2);
assert.equal(report.results[0].messages[5].message, "'foo' is not defined.");
assert.equal(report.results[0].messages[5].line, 50);
assert.equal(report.results[0].messages[5].column, 1);
});

describe("configuration comments", function() {
Expand Down
19 changes: 19 additions & 0 deletions tests/lib/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,25 @@ describe("processor", function() {
].join("\n"));
});

it("should insert global comments", function() {
var code = [
"<!-- global foo -->",
"<!-- global bar:false, baz:true -->",
"",
"```js",
"alert(foo, bar, baz);",
"```"
].join("\n");
var blocks = processor.preprocess(code);

assert.equal(blocks.length, 1);
assert.equal(blocks[0], [
"/* global foo */",
"/* global bar:false, baz:true */",
"alert(foo, bar, baz);"
].join("\n"));
});

it("should ignore non-eslint comments", function() {
var code = [
"<!-- eslint-env browser -->",
Expand Down