Created
September 4, 2014 19:07
-
-
Save karlwestin/d6f58c1f777133940a30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Tests for sticky notifications | |
*/ | |
define([ | |
"./stickyNotifications", | |
"lib/RFZ.pubsub", | |
//"widgets/billpay/billpay" | |
], function(Stickies, pubSub, BP) { | |
var models = [{ | |
"channel": "web", | |
"type": "", | |
"active": true, | |
"statuskind": "good", | |
"location": "overview", | |
"text": "Large deposit alert: There was a $2,745.87 deposit to your Wells Fargo Bank Checking (8755) account.", | |
"created": 1357049247130, | |
"id": 1699650 | |
}, { | |
"channel": "web", | |
"type": "", | |
"active": true, | |
"statuskind": "payment_paid", | |
"location": "payments", | |
"text": "Your ReadyForZero PLUS payment of $50.00 to Affiliated Computer Services has been delivered.", | |
"created": 1357249547695, | |
"id": 1706990 | |
}, { | |
"channel": "web", | |
"type": "web", | |
"active": true, | |
"statuskind": "good", | |
"location": "overview", | |
"text": "Large deposit alert: There was a $2,636.20 deposit to your Wells Fargo Bank Checking (8755) account.", | |
"created": 1358254829879, | |
"id": 1774997 | |
}, { | |
"channel": "web", | |
"type": "web", | |
"active": true, | |
"statuskind": "payment_paid", | |
"location": "payments", | |
"text": "Your ReadyForZero PLUS payment of $5.55 to Affiliated Computer Services has been delivered. This saved you $0.24.", | |
"created": 1358286317219, | |
"id": 1779426 | |
}, { | |
"channel": "web", | |
"type": "web", | |
"active": true, | |
"statuskind": "neutral", | |
"location": "overview", | |
"text": "You linked a student loan - check out our <a href=\"http://www.readyforzero.com/resources/student-loan-debt/\" target=\"_blank\">student loan resource center</a> to learn about programs that could save you time and money.", | |
"created": 1358452503605, | |
"id": 1792748 | |
}, { | |
"text": "Reduce debt faster and save money with <a href=\"/readyforzero-plus\"><span class=\"plus_logo\">ReadyForZero <i>PLUS</i></span></a>. <a href=\"#\" class=\"js_enable_link js_make_payment\">» Activate payments</a>", | |
"statuskind": "good", | |
"location": "payments", | |
"created": 1355866624130, | |
"id": 12312321 | |
}]; | |
describe("Sticky Notifications:" , function() { | |
beforeEach(function() { | |
/* | |
spyOn(BP, "Flow"); | |
*/ | |
this.stickies = new Stickies(); | |
this.stickies._reset(); | |
expect(this.stickies.model.length).toEqual(0); | |
}); | |
afterEach(function() { | |
this.stickies.dispose(); | |
this.stickies = null; | |
}); | |
describe("rendering stickies", function() { | |
it("should render added stickies", function() { | |
this.stickies.model.add([ models[0], models[1] ]); | |
expect(this.stickies.$(".item").length).toEqual(2); | |
expect(this.stickies.el.innerHTML).toMatch(/2,745\.87/); | |
}); | |
it("should not double-add stickies", function() { | |
this.stickies.model.add([ models[0], models[1] ]); | |
this.stickies.model.add([ models[0], models[1], models[2], models[3] ]); | |
expect(this.stickies.$(".item").length).toEqual(4); | |
expect(this.stickies.el.innerHTML).toMatch(/5.55/); | |
}); | |
}); | |
/* | |
describe("Showing billpay modal", function() { | |
beforeEach(function() { | |
BP.Flow.reset(); | |
}); | |
it("should call billpay load when clicking '.js_make_payment' #2513", function() { | |
this.stickies.model.add([ models[5] ]); | |
this.stickies.$(".js_make_payment").click(); | |
expect(BP.Flow).toHaveBeenCalledWith("payment:create", undefined); | |
}); | |
}); | |
*/ | |
describe("interacting with accounts via pubSub", function() { | |
it("should set a warning on 'account:planComparison' if paid < min", function() { | |
pubSub.trigger("account:planComparison", { min: 10, paid: 5 }); | |
expect(this.stickies.el.innerHTML).toMatch(/planBroken/i); | |
// should update the notification, not add if coming again | |
pubSub.trigger("account:planComparison", { min: 11, paid: 5 }); | |
expect(this.stickies.el.innerHTML.match(/planBroken/).length).toEqual(1); | |
expect(this.stickies.el.innerHTML).toMatch(/11/i); | |
}); | |
it("should remove warning 'plan broken' if paid >= min", function() { | |
pubSub.trigger("account:planComparison", { min: 5, paid: 6 }); | |
expect(this.stickies.el.innerHTML).not.toMatch(/planBroken/i); | |
// showing warning ( just to test ) | |
pubSub.trigger("account:planComparison", { min: 10, paid: 5 }); | |
expect(this.stickies.el.innerHTML).toMatch(/planBroken/i); | |
// the real test | |
pubSub.trigger("account:planComparison", { min: 5, paid: 5 }); | |
expect(this.stickies.el.innerHTML).not.toMatch(/planBroken/i); | |
}); | |
it("should set a warning on 'account:brokenAccounts' if count, remove if not", function() { | |
pubSub.trigger("account:brokenAccounts", { count: 10 }); | |
expect(this.stickies.el.innerHTML).toMatch(/accountBroken/i); | |
pubSub.trigger("account:brokenAccounts", { count: 0 }); | |
expect(this.stickies.el.innerHTML).not.toMatch(/accountBroken/i); | |
}); | |
}); | |
});// end wrapper describe | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment