spec/javascripts/ballonizer_spec.js in ballonizer-0.6.0 vs spec/javascripts/ballonizer_spec.js in ballonizer-0.7.1
- old
+ new
@@ -63,44 +63,44 @@
describe("when exist images to ballonize in the document", function () {
describe("but none in the context", function () {
it("doesn't create a form", function () {
loadFixtures("ballonized-xkcd-without-ballons.html");
- Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#bottom"));
+ Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#bottom"), $);
expect($("form.ballonizer_page_form")).not.toExist();
});
it(".getForm return null", function () {
- instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#bottom"));
+ instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#bottom"), $);
expect(instance.getForm()).toEqual(null);
});
});
describe("and they are in the context", function () {
it("create a hidden form as the last child of the context", function () {
loadFixtures("ballonized-xkcd-without-ballons.html");
- Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
+ Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
expect($("#jasmine-fixtures")).toHaveBallonizerForm(actionFormURL);
expect($("form.ballonizer_page_form")).toBeHidden();
});
it("changes in .getForm result affect the node in the DOM", function () {
loadFixtures("ballonized-xkcd-without-ballons.html");
- instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
+ instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
instance.getForm().attr("method", "get");
expect($("form.ballonizer_page_form")).toHaveAttr("method", "get");
});
});
describe("when the ballonized image is double clicked", function () {
it("a new ballon will be created", function () {
loadFixtures("ballonized-xkcd-without-ballons.html");
- instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
+ instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
var ballonizedImg = $(".ballonizer_image_container img");
ballonizedImg.trigger("dblclick");
expect($(".ballonizer_ballon")).toExist();
});
it("the default action of clicking the image (if any) will not trigger", function () {
loadFixtures("ballonized-xkcd-with-anchor-in-image.html");
- instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
+ instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
var spyAnchor = spyOnEvent("#comic a", "click");
var ballonizedImg = $(".ballonizer_image_container img");
// In a real browser the dblclick event will be generated with one or
// two clicks events before it (http://api.jquery.com/dblclick/)
ballonizedImg.trigger("click");
@@ -110,38 +110,38 @@
});
describe(".getBallonizedImageContainers", function () {
describe("when there's no image to ballonize", function () {
it("return an object without any keys", function () {
- instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
+ instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
var ballonizedImageContainers = instance.getBallonizedImageContainers();
expect(ballonizedImageContainers).toBeAnEmptyObject();
});
});
describe("when there's a image to ballonize", function () {
it("return an object with the img src as key and the object as value", function () {
loadFixtures("ballonized-xkcd-without-ballons.html");
- instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
+ instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
var ballonizedImageContainers = instance.getBallonizedImageContainers();
expect(ballonizedImageContainers.hasOwnProperty("http://imgs.xkcd.com/comics/cells.png")).toBeTruthy();
});
});
});
describe("BallonizedImageContainer", function () {
it("adds a hidden form for the ballon edition in the body", function () {
loadFixtures("ballonized-xkcd-without-ballons.html");
- instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
+ instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
expect($("body")).toContain("form.ballonizer_image_form");
// What the value of action is not important, but the action attribute
// is required (http://www.w3.org/TR/html401/interact/forms.html#h-17.3)
expect($("form.ballonizer_image_form")).toHaveAttr("action");
expect($("form.ballonizer_image_form")).toBeHidden();
});
describe("when there's a image with ballons", function () {
it("getBallons return they", function () {
loadFixtures("ballonized-xkcd-with-ballons.html");
- instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
+ instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
var ballonizedImageContainers = instance.getBallonizedImageContainers();
var ballons = ballonizedImageContainers["http://imgs.xkcd.com/comics/cells.png"].getBallons();
expect(ballons.length).toEqual(2);
expect(ballons[0].getText()).toEqual("When you see a claim that a common drug or vitamin \"kills cancer cells in a petri dish\", keep in mind:");
@@ -166,11 +166,11 @@
};
var containerWidth, containerHeight;
var getBallons = function () {
loadFixtures("ballonized-xkcd-with-ballons.html");
- instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
+ instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
var imageContainer = instance.getBallonizedImageContainers()["http://imgs.xkcd.com/comics/cells.png"],
ballons = imageContainer.getBallons(),
containerNode = imageContainer.getContainerNode();
containerWidth = containerNode.width();
@@ -286,10 +286,10 @@
});
describe("when the container is inside a <a/> element", function () {
it("prevent the default action of changing the page", function () {
// first create a ballon
loadFixtures("ballonized-xkcd-with-anchor-in-image.html");
- instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"));
+ instance = Ballonizer(actionFormURL, imageToBallonizeCSSSelector, $("#jasmine-fixtures"), $);
var ballonizedImg = $(".ballonizer_image_container img");
realWorldEvent("dblclick", ballonizedImg);
var ballon = $(".ballonizer_ballon");
// and then we simulate a dblclick over the ballon