Created
October 23, 2014 17:17
-
-
Save victormejia/df95014dbe41dfffdb8d to your computer and use it in GitHub Desktop.
This file contains 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('Portfolio Module', function () { | |
var DesignerContextSvc, $httpBackend, authRequestHandler, path, adTypeId = 1; | |
var metadata = { | |
collection: [{ | |
name: "leaderboard", | |
label: "Leaderboard", | |
units: [{ | |
name: "desktop", | |
w: 728, | |
h: 90 | |
}], | |
canUploadCustom: true, | |
style: "default" | |
}], | |
assets: [{ | |
name: "profile", | |
label: "Upload your photo", | |
help: "Upload your photo", | |
button: "Add Photo" | |
}] | |
}; | |
beforeEach(module('adBrokerApp', function ($provide) { | |
$provide.value('context', context); | |
})); | |
// load the service module | |
beforeEach(module('adBrokerApp.providers')); | |
beforeEach(inject(function ($injector) { | |
DesignerContextSvc = $injector.get('DesignerContextService'); | |
path = $injector.get('path'); | |
// Set up the mock http service responses | |
$httpBackend = $injector.get('$httpBackend'); | |
authRequestHandler = $httpBackend.when('GET', path.getMarketplaceApiUrl('metadata', 'adType', adTypeId)) | |
.respond(metadata); | |
})); | |
afterEach(function() { | |
$httpBackend.verifyNoOutstandingExpectation(); | |
$httpBackend.verifyNoOutstandingRequest(); | |
}); | |
describe('DesignerContextService: getAdTypeMetadata', function () { | |
it('should be defined', function () { | |
expect(DesignerContextSvc.getAdTypeMetadata).toBeDefined(); | |
}); | |
it('should invoke GET method', function () { | |
$httpBackend.expectGET(path.getMarketplaceApiUrl('metadata', 'adType', adTypeId)); | |
// call service method | |
DesignerContextSvc.getAdTypeMetadata(1); | |
// flush | |
$httpBackend.flush(); | |
}); | |
it('returns http request successfully and resolves the promise', function () { | |
var promise = DesignerContextSvc.getAdTypeMetadata(1); | |
var returnData = {}; | |
promise.then(function (data) { | |
returnData = data; | |
}); | |
$httpBackend.flush(); | |
expect(returnData.collection).toBeDefined(); | |
expect(returnData.assets).toBeDefined(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment