describe('BriefingPackage Manager Service Jasmine Test', function(){
it('4a. setBriefingPackageAlreadyDownloaded function test when available', function(done){ spyOn($log,"debug").and.callThrough();
//mocking the existing context
ebriefingBriefingPackageManagerService.context = briefingPackage;
//initializing a new database in PouchDB
var dbJasmine = new PouchDB("jasmine_flightRoute");
//storing data in the database
dbJasmine.put(briefingPackage, function() {
//getting the eff metadata of the flight date eff
console.log("toto");
dataService.getEffMetadataByFlightDateFrom(dbJasmine,briefingPackage.flightId,briefingPackage.departureDate, briefingPackage.departureAirport).then(function(succ){
//destruction of the database object after use
console.log("test");
dbJasmine.destroy().then(function() {
//checking the retrieved data are consistent with our mocked data
expect(succ._id).toEqual(briefingPackage._id);
//getting the eff metadata from the database
console.log("tak tak");
done();
});
//error callback
}, function(err) {
//destruction of the database
dbJasmine.destroy().then(function() {
//exception thrown because the datas are certainly null
expect(err).toBeNull();
});
});
});
var isAvailable = true;
ebriefingBriefingPackageManagerService.setBriefingPackageAlreadyDownloaded(briefingPackage,isAvailable);
expect($log.debug).toHaveBeenCalledWith("briefingPackageManagerService.setBriefingPackageAlreadyDownloaded START");
expect(ebriefingBriefingPackageManagerService.briefingPackagesDownloadedStatus.availableBriefingPackage).toBeTruthy();
});
});
Aucun commentaire:
Enregistrer un commentaire