Created
December 8, 2013 15:32
-
-
Save Madhuka/7859106 to your computer and use it in GitHub Desktop.
Jasmine with AJAX, spyon (Bank Sample versions One - Static Data )
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 | |
| }); | |
| }; | |
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.data).toHaveBeenCalledWith ({ | |
| method:"POST", | |
| url:"/data", | |
| data:{"Bank User Name":"mahuka"} | |
| }); | |
| }); | |
| }); |
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
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
| "http://www.w3.org/TR/html4/loose.dtd"> | |
| <html> | |
| <head> | |
| <title>Jasmine Spec Runner</title> | |
| <link rel="shortcut icon" type="image/png" href="lib/jasmine-1.3.1/jasmine_favicon.png"> | |
| <link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css"> | |
| <script type="text/javascript" src="lib/jasmine-1.3.1/jquery.min.js"></script> | |
| <script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script> | |
| <script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script> | |
| <script type="text/javascript" src="src/Data.js"></script> | |
| <script type="text/javascript" src="spec/DataSpec.js"></script> | |
| <script type="text/javascript"> | |
| (function() { | |
| var jasmineEnv = jasmine.getEnv(); | |
| jasmineEnv.updateInterval = 1000; | |
| var htmlReporter = new jasmine.HtmlReporter(); | |
| jasmineEnv.addReporter(htmlReporter); | |
| jasmineEnv.specFilter = function(spec) { | |
| return htmlReporter.specFilter(spec); | |
| }; | |
| var currentWindowOnload = window.onload; | |
| window.onload = function() { | |
| if (currentWindowOnload) { | |
| currentWindowOnload(); | |
| } | |
| execJasmine(); | |
| }; | |
| function execJasmine() { | |
| jasmineEnv.execute(); | |
| } | |
| })(); | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment