Skip to content

Commit

Permalink
Add testing bendc#4
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Jun 8, 2015
1 parent c807d20 commit 3b716df
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.swp
.DS_Store
node_modules/
50 changes: 50 additions & 0 deletions __tests__/sprint-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
jest.dontMock("../sprint");

describe("$('.foo').add('.bar')", function() {
it('should contain .foo', function() {
var $ = require("../sprint.js");
document.body.innerHTML =
'<div>' +
' <div class="foo"></div>' +
' <div class="bar"></div>' +
'</div>';
var foo = $('.foo').add('.bar').dom[0];
var foo_node = $('.foo').dom[0];
expect(foo).toBe(foo_node);
});
it('should contain .bar', function() {
var $ = require("../sprint.js");
document.body.innerHTML =
'<div>' +
' <div class="foo"></div>' +
' <div class="bar"></div>' +
'</div>';
var bar = $('.foo').add('.bar').dom[1];
var bar_node = $('.bar').dom[0];
expect(bar).toBe(bar_node);
});
});

describe("$('#checkbox').attr('type')", function() {
it('should return the value of the type attribute', function() {
var $ = require("../sprint.js");
document.body.innerHTML =
'<div>' +
' <input id="checkbox" type="checkbox" />' +
'</div>';
var input_type = $('#checkbox').attr('type');
expect(input_type).toEqual('checkbox');
});
});

describe("$('#checkbox').attr('type', 'text')", function() {
it('should change the value of the type attribute to "text"', function() {
var $ = require("../sprint.js");
document.body.innerHTML =
'<div>' +
' <input id="checkbox" type="checkbox" />' +
'</div>';
var input_type = $('#checkbox').attr('type', 'text').attr('type');
expect(input_type).toEqual('text');
});
});
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "0.1.0",
"description": "A tiny, lightning fast jQuery-like library for modern browsers.",
"main": "sprint.js",
"scripts": {
"test": "jest"
},
"repository": {
"type": "git",
"url": "[email protected]:philplckthun/sprint.git"
Expand All @@ -12,5 +15,8 @@
"bugs": {
"url": "https://github.com/philplckthun/sprint/issues"
},
"homepage": "https://github.com/philplckthun/sprint"
"homepage": "https://github.com/philplckthun/sprint",
"devDependencies": {
"jest-cli": "^0.4.8"
}
}

0 comments on commit 3b716df

Please sign in to comment.