1
嘿,我从来没有用过Jasmine,但我需要这个小工程,我正在努力。不能完全弄清楚,任何帮助将不胜感激。我看了各种教程并讨论了这个问题,但是对于这个新手并没有什么帮助。
JS源文件
> $(document).ready(function(){
>
>
> $.ajax({ type: 'GET', dataType: "json", url: "db.php/realmadrids",
> success: showResponse, error: showError });
>
>
>
>
>
>
> console.debug("error"); function showResponse(responseData){
>
> //$("#get1").click(function getPlayers(responseData) {
> console.log('Image is clicked'); console.log(responseData);
> $.each(responseData.realmadrid, function(index, realmadrid){
> console.log(' is ');
> $("#playercontentRealMadrid").append("</br><strong> Full Name: </strong>" +realmadrid.PlayerName+ " "+realmadrid.PlayerLastName+"
> </br> <strong>Player Position: </strong>" +realmadrid.PlayerPosition+"
> </br><strong>Player Age: </strong>" +realmadrid.Age+"
> </br><strong>Player Height: </strong>" +realmadrid.Height+"
> </br><strong>Player Weight: </strong>" +realmadrid.Weight+"
> </br><strong>Team Name: </strong>" +realmadrid.TeamName+"</br>");
>
> console.log('Data should output'); // }); });
>
> console.log(responseData);
> }
> console.debug("hello");
>
> function showError(){ alert("Sorry, but something went wrong. Fix
> it!!!!") }
>
> });
这里是我的测试代码:
//Test Suite describe("Spy on my own AJAX call", function(){ it("should make AJAX request with successful setting", function() { spyOn($, "ajax"); expect($.ajax).toHaveBeenCalledWith({ url:'db.php/realmadrids', type:'GET', dataType: "json", sucess: showResponse, error: showError }); }); });
它总是那些小事情,谢谢! –