Created
September 27, 2012 21:00
-
-
Save FND/3796438 to your computer and use it in GitHub Desktop.
template for JavaScript components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Sample Test Suite</title> | |
<link rel="stylesheet" href="../lib/qunit.css"> | |
</head> | |
<body> | |
<div id="qunit"></div> | |
<div id="qunit-fixture"></div> | |
<script src="../lib/qunit.js"></script> | |
<script src="../lib/blanket.js"></script> | |
<script src="../src/sample.js" data-cover></script> | |
<script src="tests.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: release test lint dependencies | |
jquery_version = 1.8 | |
qunit_version = 1.10.0 | |
download = \ | |
curl --output $(1) --time-cond $(1) --remote-time $(2) | |
# TODO: optional checksum verification | |
release: lint test | |
scp # TODO | |
test: | |
phantomjs lib/phantomjs-qunit-runner.js test/index.html | |
lint: | |
jslint-reporter `find {src,test} -type f -name "*.js"` | |
dependencies: | |
mkdir -p lib | |
$(call download, "lib/jquery.js", \ | |
"http://ajax.googleapis.com/ajax/libs/jquery/$(jquery_version)/jquery.min.js") | |
$(call download, "lib/qunit.js", \ | |
"http://code.jquery.com/qunit/qunit-$(qunit_version).js") | |
$(call download, "lib/qunit.css", \ | |
"http://code.jquery.com/qunit/qunit-$(qunit_version).css") | |
$(call download, "lib/blanket.js", \ | |
"https://raw.github.com/alex-seville/blanket/master/dist/qunit/blanket.min.js") | |
$(call download, "lib/phantomjs-qunit-runner.js", \ | |
"https://raw.github.com/jquery/qunit/master/addons/phantomjs/runner.js") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint vars: true, white: true */ | |
var SAMPLE = (function() { | |
"use strict"; | |
var foo = "lorem"; | |
var bar = "ipsum"; | |
return { | |
foo: foo, | |
bar: bar | |
}; | |
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint vars: true, white: true */ | |
/*global module, test, strictEqual */ | |
/*global SAMPLE */ | |
(function() { | |
"use strict"; | |
module("Hello World"); | |
test("lipsum", function() { | |
strictEqual(SAMPLE.foo, "lorem"); | |
strictEqual(SAMPLE.bar, "ipsum"); | |
strictEqual(SAMPLE.baz, "..."); | |
}); | |
}()); |
since I cannot push due to gists no longer supporting directories:
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,10 @@ download = \
curl --output $(1) --time-cond $(1) --remote-time $(2)
test:
- phantomjs lib/phantomjs-qunit-runner.js test/index.html
+ @set -o pipefail && \
+ phantomjs lib/phantomjs-qunit-runner.js test/index.html | \
+ sed -e "s/[^0 ][^0 ]* failed/\x1b[31m&\x1b[0m/" \
+ -e "s/Failed assertion: expected: \(.*\), but was: \(.*\)/\n assertion failed\n \x1b[31;1mexpected: \1\x1b[0m\n \x1b[32;1mactual : \2\x1b[0m/"
lint:
jslint-reporter `find {scripts,test} -type f -name "*.js"`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
caveats:
jslint-reporter
[1][2] - there might be better packaged alternatives ("there are many like it, but this one is mine")phantomjs
is presentcurl
only works for simple libraries - perhaps NPM/Bower/Jam/... should be used to retrieve depenencies (and store them in./lib
)./dist/{rails,flask,...}
iqroca {lint,upload}
)[1] https://github.com/FND/jslint-reporter
[2] https://github.com/FND/homedir/blob/master/bin/jslint-reporter