From 45df483540c2b4bb347399d1956a0fc6129eda3b Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Tue, 20 May 2008 15:19:59 -0700 Subject: [PATCH] jQuery.print: add specs for NaN, HTMLElements with attributes and Regexps --- spec/print_spec.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/spec/print_spec.js b/spec/print_spec.js index a33827c..dfbd20c 100644 --- a/spec/print_spec.js +++ b/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($('
').get(0))).to(equal, '
'); expect($.print($('
').get(0))).to(equal, '
'); + expect($.print($('
').get(0))).to(equal, '
'); + }); + + describe('when the element is an img', function() { + it('prints out the img src attribute', function() { + expect($.print($(''))).to(match, //); + }) }); }); @@ -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($('
'))).to(equal, '$([
])'); }); }); @@ -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: ... }'); }); }); });