私が解決しようとしている問題は、ジャスミンを使用して工場をテストする機能です。
以下は私のアプリと工場のコピーです:
var app = angular.module('app', []);
app.factory('service', function ($http) {
return {
getCustomers: function (callback) {
$http.get('/Home/Customers').success(callback);
},
getProfile: function (callback, viewModel) {
$http.post('/Home/Profiles', JSON.stringify(viewModel), {
headers: {
'Content-Type': 'application/json'
}
}).success(callback);
}
};
});
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::
ジャスミンもセットアップしましたが、上記の「getCustomers」と「getProfile」のテストに問題があります。
以下は私の現在の試みです:
describe("getCustomers", function (service) {
beforeEach(module('service'));
describe('getCustomers', function () {
it("should return a list of customers", inject(function(getCustomers){
expect(getCustomers.results).toEqual(["david", "James", "Sam"]);
}))
})
});
これは、「getCustomers」と「getProfile」の両方を 2 つの別々のテストでテストする方法の例を誰かが提供できれば、非常に役立ちます。
敬具。