Tests for linting

This commit is contained in:
Slava Kim
2015-07-10 20:37:07 -07:00
parent 1dccd48d03
commit d6ae4b8a1f
15 changed files with 239 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
{
"undef": true
}

View File

@@ -0,0 +1 @@
local

View File

@@ -0,0 +1 @@
1da9lx3m24vwv1kt1w0a

View File

@@ -0,0 +1,8 @@
# Meteor packages used by this project, one per line.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
meteor-platform
my-package
jshint

View File

@@ -0,0 +1,2 @@
browser
server

View File

@@ -0,0 +1 @@
none

View File

@@ -0,0 +1,56 @@
autoupdate@1.2.2
base64@1.0.3
binary-heap@1.0.3
blaze@2.1.2
blaze-tools@1.0.3
boilerplate-generator@1.0.3
callback-hook@1.0.3
check@1.0.5
compiler-plugin@1.0.0
ddp@1.2.0
ddp-client@1.2.0
ddp-common@1.2.0
ddp-server@1.2.0
deps@1.0.7
diff-sequence@1.0.0
ejson@1.0.6
fastclick@1.0.6
geojson-utils@1.0.3
html-tools@1.0.4
htmljs@1.0.4
http@1.1.0
id-map@1.0.3
jquery@1.11.3_2
jshint@0.0.1
json@1.0.3
launch-screen@1.0.3
linter-plugin@1.0.0
livedata@1.0.13
logging@1.0.8
meteor@1.1.6
meteor-platform@1.2.2
minifiers@1.1.5
minimongo@1.0.8
mobile-status-bar@1.0.4
mongo@1.1.0
mongo-id@1.0.0
my-package@0.0.0
npm-mongo@1.4.32_1
observe-sequence@1.0.6
ordered-dict@1.0.3
random@1.0.3
reactive-dict@1.1.0
reactive-var@1.0.5
reload@1.1.3
retry@1.0.3
routepolicy@1.0.5
session@1.1.0
spacebars@1.0.6
spacebars-compiler@1.0.6
templating@1.1.1
tracker@1.0.7
ui@1.0.6
underscore@1.0.3
url@1.0.4
webapp@1.2.1
webapp-hashing@1.0.3

View File

@@ -0,0 +1,3 @@
<body>
no content
</body>

View File

@@ -0,0 +1 @@
GlobalVar = {};

View File

@@ -0,0 +1,3 @@
{
"undef": true
}

View File

@@ -0,0 +1 @@
PackageGlobalVar = {};

View File

@@ -0,0 +1,3 @@
PackageGlobalVar = {};
PermittedGlobal = {};
Package.minimongo.accessPackageVarInMeteor = "is OK";

View File

@@ -0,0 +1,11 @@
Package.describe({
summary: "test local package for using linting"
});
Package.onUse(function (api) {
api.addFiles('package-client.js', 'client');
api.addFiles('package-server.js', 'server');
api.addFiles('.jshintrc');
api.use('jshint');
});

View File

@@ -0,0 +1 @@
GlobalVar = {};

View File

@@ -0,0 +1,144 @@
var selftest = require('../selftest.js');
var files = require('../files.js');
var Sandbox = selftest.Sandbox;
var MONGO_LISTENING =
{ stdout: " [initandlisten] waiting for connections on port" };
function startRun(sandbox, args) {
var run = sandbox.run(args);
run.match('myapp');
run.match('proxy');
run.tellMongo(MONGO_LISTENING);
run.match("MongoDB");
return run;
};
function matchLintingMessages(run, messages, initial) {
run.match('Linting your app.');
messages.forEach(message => run.match(message));
if (initial) {
run.match('Started your app.');
run.match('App running at');
} else {
run.match('Meteor server restarted');
}
}
selftest.define('linter plugins - linting app with local packages', () => {
const s = new Sandbox({ fakeMongo: true });
// Create an app that uses coffeescript and less.
s.createApp('myapp', 'linting-app');
s.cd('myapp');
const run = startRun(s);
matchLintingMessages(run, [
/While linting files .* app .*Server/,
/server\.js:1:1: 'GlobalVar'/,
/While linting files .* app .*Client/,
/client\.js:1:1: 'GlobalVar'/,
/While linting files .* my-package .*Server/,
/package-server\.js:1:1: 'PackageGlobalVar'/,
/package-server\.js:2:1: 'PermittedGlobal'/,
/While linting files .* my-package .*Client/,
/package-client\.js:1:1: 'PackageGlobalVar'/
], true);
s.write('.jshintrc', JSON.stringify({
undef: false
}));
matchLintingMessages(run, [
/While linting files .* my-package .*Server/,
/package-server\.js:1:1: 'PackageGlobalVar'/,
/package-server\.js:2:1: 'PermittedGlobal'/,
/While linting files .* my-package .*Client/,
/package-client\.js:1:1: 'PackageGlobalVar'/
]);
s.write('packages/my-package/.jshintrc', JSON.stringify({
undef: true,
predef: ['PermittedGlobal']
}));
// no warnings should be printed
matchLintingMessages(run, [
/While linting files .* my-package .*Server/,
/package-server\.js:1:1: 'PackageGlobalVar'/,
/While linting files .* my-package .*Client/,
/package-client\.js:1:1: 'PackageGlobalVar'/
]);
run.stop();
});
selftest.define('linter plugins - linting app with local packages with `meteor lint`', () => {
const s = new Sandbox({ fakeMongo: true });
// Create an app that uses coffeescript and less.
s.createApp('myapp', 'linting-app');
s.cd('myapp');
const run = s.run('lint');
const messages = [
/While linting files .* app .*Server/,
/server\.js:1:1: 'GlobalVar'/,
/While linting files .* app .*Client/,
/client\.js:1:1: 'GlobalVar'/,
/While linting files .* my-package .*Server/,
/package-server\.js:1:1: 'PackageGlobalVar'/,
/package-server\.js:2:1: 'PermittedGlobal'/,
/While linting files .* my-package .*Client/,
/package-client\.js:1:1: 'PackageGlobalVar'/
];
messages.forEach(message => run.matchErr(message));
run.expectExit(1);
});
selftest.define('linter plugins - linting package with `meteor lint`', () => {
const s = new Sandbox({ fakeMongo: true });
// Create an app that uses coffeescript and less.
s.createApp('myapp', 'linting-app');
s.cd('myapp/packages/my-package');
const run = s.run('lint');
const messages = [
/While linting files .* my-package .*Server/,
/package-server\.js:1:1: 'PackageGlobalVar'/,
/package-server\.js:2:1: 'PermittedGlobal'/,
/While linting files .* my-package .*Client/,
/package-client\.js:1:1: 'PackageGlobalVar'/
];
messages.forEach(message => run.matchErr(message));
run.forbid('app');
run.expectExit(1);
});
selftest.define('linter plugins - running with --no-lint', () => {
const s = new Sandbox({ fakeMongo: true });
// Create an app that uses coffeescript and less.
s.createApp('myapp', 'linting-app');
s.cd('myapp');
const run = startRun(s, '--no-lint');
run.forbid('Linting');
run.forbid('linting');
run.forbid('is not defined');
run.match('Started your app');
run.stop();
});