Skip to content

Commit

Permalink
jQuery.print: add specs for NaN, HTMLElements with attributes and Reg…
Browse files Browse the repository at this point in the history
…exps
  • Loading branch information
tmm1 committed May 20, 2008
1 parent 3d0c2fc commit 45df483
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions spec/print_spec.js
Expand Up @@ -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">/);
})
});
});

Expand Down Expand Up @@ -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> ])');
});
});
Expand All @@ -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: ... }');
});
});
});
Expand Down

0 comments on commit 45df483

Please sign in to comment.