Skip to content

Commit

Permalink
feat(jQuery): jQueryプラグインのサンプルとテストを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Aug 29, 2015
1 parent f4d7687 commit 86a15df
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 25 deletions.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@
"devDependencies": {
"eslint": "^1.3.0",
"eslint-plugin-markdown": "git://github.com/eslint/eslint-plugin-markdown.git",
"espower-babel": "^3.3.0",
"gitbook-cli": "^0.3.4",
"gitbook-summary-to-path": "^1.0.1",
"jsdom": "^3.0.0",
"mocha": "^2.2.5",
"power-assert": "^1.0.0",
"textlint": "^3.2.0",
"textlint-rule-spellcheck-tech-word": "^4.0.1"
},
"dependencies": {
"jquery": "^2.1.4"
}
}
7 changes: 7 additions & 0 deletions src/jQuery/greenify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";
(function ($) {
$.fn.greenify = function () {
this.css("color", "green");
return this;
};
})(jQuery);
3 changes: 0 additions & 3 deletions src/jQuery/jquery.js

This file was deleted.

22 changes: 0 additions & 22 deletions src/jQuery/package.json

This file was deleted.

10 changes: 10 additions & 0 deletions test/jQuery/fixtures/testbed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>

</body>
</html>
28 changes: 28 additions & 0 deletions test/jQuery/greenify-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// LICENSE : MIT
"use strict";
import jsdom from "jsdom";
import assert from "power-assert"
import fs from "fs";
const testbed = fs.readFileSync(__dirname + "/fixtures/testbed.html", "utf-8");
const jquery = fs.readFileSync(__dirname + "/../../node_modules/jquery/dist/jquery.js", "utf-8");
const greenify = fs.readFileSync(__dirname + "/../../src/jQuery/greenify.js", "utf-8");
describe("greenify", function () {
var $, document;
before(done => {
jsdom.env({
html: testbed,
src: [jquery, greenify],
done: function (err, window) {
document = window.document;
$ = window.$;
done();
}
});
});
it("should extend $.prototype with greenify", function () {
assert(typeof $ !== "undefined");
assert($.fn.greenify != null);
assert($(document.body).greenify != null);
assert($(document.body).greenify() instanceof $);
});
});
1 change: 1 addition & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--compilers js:espower-babel/guess

0 comments on commit 86a15df

Please sign in to comment.