'use strict';
describe('getmodules', function () {
window.__env.platform = 'jasmine'; // web || mobile || desktop
beforeEach(function () { module('myApp', 'ngMockE2E', 'ngCookies'); });
var service, $httpBackend, defaultAlertFactory, $cookies, $http;
var $controller;
var $rootScope;
beforeEach(inject(function ($injector) {
service = $injector.get('dashboardService');
$httpBackend = $injector.get('$httpBackend');
$rootScope = $injector.get('$rootScope');
$http = $injector.get('$http');
}));
it("should return a list of getmodules", function () {
debugger;
var result1 = null;
$httpBackend.when('GET', '/home/modulesInfo').respond(true, ['david', 'James', 'Sam']);
/* Code Under Test */
$http({
method: 'GET',
url: '/home/modulesInfo'
}).then(function (success,response) {
result1 =response;
}, function (error) {
});
$httpBackend.flush();
expect(result1).toEqual(["david", "James", "Sam"]);
});
});
=============================================== ========= 不知道为什么?有$ http.get(),并使用flush()来调用fack httpBackend调用,应该不错。仍然没有工作