Permalink
Browse files

Merge pull request #29 from pivotal/master

When loading Jasmine fixtures with an inline <script> tag, the javascript should execute AFTER the fixture is inserted into the body
  • Loading branch information...
2 parents 7ded03c + 9f623e0 commit 7fcfa635a8a7281cc3b16513084a02f1020c0c43 @velesin velesin committed Aug 11, 2011
Showing with 18 additions and 2 deletions.
  1. +7 −2 lib/jasmine-jquery.js
  2. +11 −0 spec/suites/jasmine-jquery-spec.js
@@ -71,8 +71,13 @@ jasmine.Fixtures.prototype.sandbox = function(attributes) {
};
jasmine.Fixtures.prototype.createContainer_ = function(html) {
- var container = jQuery('<div id="' + this.containerId + '" />');
- container.html(html);
+ var container;
+ if(html instanceof jQuery) {
+ container = jQuery('<div id="' + this.containerId + '" />');
+ container.html(html);
+ } else {
+ container = '<div id="' + this.containerId + '">' + html + '</div>'
+ }
jQuery('body').append(container);
};
@@ -119,6 +119,17 @@ describe("jasmine.Fixtures", function() {
expect(fixturesContainer().html()).toEqual(ajaxData);
});
});
+
+ describe("when fixture contains an inline <script> tag", function(){
+ beforeEach(function(){
+ ajaxData = "<div><a id=\"anchor_01\"></a><script>$(function(){ $('#anchor_01').addClass('foo')});</script></div>"
+ });
+
+ it("should execute the inline javascript after the fixture has been inserted into the body", function(){
+ jasmine.getFixtures().load(fixtureUrl);
+ expect($("#anchor_01")).toHaveClass('foo');
+ })
+ });
});
describe("preload", function() {

0 comments on commit 7fcfa63

Please sign in to comment.