Created
December 8, 2013 15:41
-
-
Save Madhuka/7859220 to your computer and use it in GitHub Desktop.
Jasmine with AJAX and spyon (Sample bank Version 2)
This file contains hidden or 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
| function Bank() {}; | |
| Bank.send = function (information){ | |
| $.ajax({ | |
| method: "POST", | |
| url: "/data", | |
| data: information | |
| }); | |
| }; | |
| Bank.moneyTransfer = function (transferData){ | |
| $.ajax({ | |
| method: "POST", | |
| url: "/data", | |
| data: transferData | |
| }); | |
| }; | |
This file contains hidden or 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
| describe("Bank Information passing", function() { | |
| it("Bank should send user name", function(){ | |
| spyOn($,"ajax"); | |
| var bankUserInformation = {"Bank User Name":"mahuka"}; | |
| Bank.send(bankUserInformation); | |
| expect($.ajax).toHaveBeenCalledWith ({ | |
| method:"POST", | |
| url:"/data", | |
| data:{"Bank User Name":"mahuka"} | |
| }); | |
| }); | |
| it("Bank money transfer", function(){ | |
| spyOn($,"ajax"); | |
| var moneyTransferInformation = {"from":"2345-1232-1232","to":"1212-5656-7898","amount":Math.random()}; | |
| Bank.moneyTransfer(moneyTransferInformation); | |
| expect($.ajax).toHaveBeenCalledWith ({ | |
| method:"POST", | |
| url:"/data", | |
| data: moneyTransferInformation | |
| }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment