[Pkg-javascript-commits] [backbone] 74/101: added view tests
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 16:58:30 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.1.0
in repository backbone.
commit d8308f9712084836e91a6e96729c6b4235d01468
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date: Tue Oct 12 16:19:02 2010 -0400
added view tests
---
index.html | 6 +++---
test/view.js | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/index.html b/index.html
index 377ec15..356b32c 100644
--- a/index.html
+++ b/index.html
@@ -251,7 +251,7 @@
<a href="#View">Backbone.View</a>,
it's highly recommended to include <a href="http://jquery.com">jQuery</a>,
and <a href="http://www.json.org/json2.js">json2.js</a>
- (which you probably already have).
+ (both of which you may already have on the page).
</p>
<h2 id="Introduction">Introduction</h2>
@@ -350,7 +350,7 @@ obj.trigger("alert", "an event");
<b>Models</b> are the heart of any JavaScript application, containing
the interactive data as well as a large part of the logic surrounding it:
conversions, validations, computed properties, and access control. You
- extend <tt>Backbone.Model</tt> with your domain-specific methods, and
+ extend <b>Backbone.Model</b> with your domain-specific methods, and
<b>Model</b> provides a basic set of functionality for managing changes.
</p>
@@ -527,7 +527,7 @@ one.set({
<p>
A model with an id of <tt>101</tt>, stored in a
- <tt>Bindable.Collection</tt> with a <tt>url</tt> of <tt>"/notes"</tt>,
+ <b>Backbone.Collection</b> with a <tt>url</tt> of <tt>"/notes"</tt>,
would have this URL: <tt>"/notes/101"</tt>
</p>
diff --git a/test/view.js b/test/view.js
index 85ef36f..2fd1555 100644
--- a/test/view.js
+++ b/test/view.js
@@ -1,3 +1,46 @@
$(document).ready(function() {
+
module("Backbone View");
+
+ var view = new Backbone.View({
+ id : 'test-view',
+ className : 'test-view'
+ });
+
+ test("view: constructor", function() {
+ equals(view.el.id, 'test-view');
+ equals(view.el.className, 'test-view');
+ equals(view.options.id, 'test-view');
+ equals(view.options.className, 'test-view');
+ });
+
+ test("view: jQuery", function() {
+ view.el = document.body;
+ equals(view.$('#qunit-header').text(), 'Backbone Test Suite');
+ });
+
+ test("view: make", function() {
+ var div = view.make('div', {id: 'test-div'}, "one two three");
+ equals(div.tagName.toLowerCase(), 'div');
+ equals(div.id, 'test-div');
+ equals($(div).text(), 'one two three');
+ });
+
+ test("view: handleEvents", function() {
+ var counter = 0;
+ view.el = document.body;
+ view.increment = function() {
+ return ++counter;
+ };
+ var events = {"#qunit-banner.click": "increment"};
+ view.handleEvents(events);
+ $('#qunit-banner').trigger('click');
+ equals(counter, 1);
+ $('#qunit-banner').trigger('click');
+ equals(counter, 2);
+ view.handleEvents(events);
+ $('#qunit-banner').trigger('click');
+ equals(counter, 3);
+ });
+
});
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list