Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

jQuery.print: add specs for NaN, HTMLElements with attributes and Reg…

…exps
  • Loading branch information...
commit 45df483540c2b4bb347399d1956a0fc6129eda3b 1 parent 3d0c2fc
@tmm1 tmm1 authored
Showing with 21 additions and 2 deletions.
  1. +21 −2 spec/print_spec.js
View
23 spec/print_spec.js
@@ -54,10 +54,29 @@ Screw.Unit(function() {
});
});
+ describe('when given a RegExp', function() {
+ it('should print the regexp', function() {
+ expect($.print(/abc/i)).to(equal, '/abc/i');
+ });
+ });
+
+ describe('when given NaN', function() {
+ it('should print the string "NaN"', function() {
+ expect($.print(NaN)).to(equal, 'NaN');
+ });
+ });
+
describe('when given an element', function() {
it("returns the string representation of the element", function() {
expect($.print($('<div>').get(0))).to(equal, '<div>');
expect($.print($('<div foo="bar">').get(0))).to(equal, '<div>');
+ expect($.print($('<div class="foo" id="bar">').get(0))).to(equal, '<div class="foo" id="bar">');
+ });
+
+ describe('when the element is an img', function() {
+ it('prints out the img src attribute', function() {
+ expect($.print($('<img src="test.png">'))).to(match, /<img src=".+?test.png">/);
+ })
});
});
@@ -90,7 +109,7 @@ Screw.Unit(function() {
});
describe('when given a jQuery', function() {
- it("returns the printed array of elements engirthed in '$()' ", function() {
+ it("returns the printed array of elements engirthed in '$()'", function() {
expect($.print($('<div>'))).to(equal, '$([ <div> ])');
});
});
@@ -110,7 +129,7 @@ Screw.Unit(function() {
it("returns elipses for circularities", function() {
var circular = {};
circular[0] = circular;
- expect($.print(circular)).to(equal, '{ 0: { 0: ... } }');
+ expect($.print(circular)).to(equal, '{ 0: ... }');
});
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.