Last active
August 29, 2015 14:08
-
-
Save matiassingers/b15dbc20bcf5f408587e 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('Controller: MeletopCategoryCtrl', function(){ | |
beforeEach(module('companionApp')); | |
var MeletopCategoryCtrl, scope, notificationService; | |
beforeEach(inject(function($rootScope, $controller, _notificationService_){ | |
scope = $rootScope.$new(); | |
notificationService = _notificationService_; | |
spyOn(notificationService, 'load'); | |
MeletopCategoryCtrl = $controller('MeletopCategoryCtrl', { | |
$scope: scope, | |
notificationService: notificationService | |
}); | |
})); | |
it('should have the MeletopCategoryCtrl', function () { | |
expect(MeletopCategoryCtrl).toBeDefined(); | |
expect(notificationService.load).toHaveBeenCalled(); | |
}); | |
}); | |
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('Service: MeletopService', function() { | |
beforeEach(module('companionApp')); | |
var MeletopService, $httpBackend; | |
beforeEach(inject(function(_$httpBackend_, _MeletopService_) { | |
MeletopService = _MeletopService_; | |
$httpBackend = _$httpBackend_; | |
spyOn(MeletopService, 'getCategories').and.callThrough(); | |
})); | |
it('should be defined', function() { | |
expect(MeletopService).toBeDefined(); | |
}); | |
describe('#getCategories() - list of categories', function() { | |
beforeEach(function() { | |
$httpBackend.when('GET', 'http://companionapi.pink.cat/meletop/api/v1/categories') | |
.respond({ | |
data: { | |
categories: [{ | |
photo: 'http://www.astro.com.my/DesktopModules/PackFlashPublish/Resources/handlers/imageResizeAndCrop.ashx?image=/Portals/0/Images/ArticleImages/20141029153244351/CintaIbadah.jpg&width=400&height=200', | |
id: 2, | |
title: 'Bintang Siber Meletop' | |
}, { | |
photo: 'http://www.astro.com.my/DesktopModules/PackFlashPublish/Resources/handlers/imageResizeAndCrop.ashx?image=/Portals/0/Images/ArticleImages/201411415441848/strawbericinta.jpg&width=400&height=200', | |
id: 3, | |
title: 'Anugerah Khas Meletop' | |
}], | |
phase: { | |
time_description: 'Phase 1 voting duration: 11/12/2014 - 11/1/2015', | |
description: 'Who do you think will win at the Meletop? Make your picks with the MY picks official Anugerah Meletop 2015 and find predictions of other Meletop fans.' | |
}, | |
terms: { | |
title: 'terms and conditions', | |
url: 'http://astro.com.my' | |
} | |
} | |
}); | |
}); | |
it('method should be defined', function() { | |
expect(MeletopService.getCategories).toBeDefined(); | |
}); | |
it('should return categories as MeletopCategoriesModel', function(done) { | |
MeletopService.getCategories() | |
.then(function(response) { | |
expect(response).toBeDefined(); | |
expect(response.getCategories()).toBeDefined(); | |
expect(response.getTimeDescription()).toEqual('Phase 1 voting duration: 11/12/2014 - 11/1/2015'); | |
expect(response.getPhaseDescription()).toEqual('Who do you think will win at the Meletop? Make your picks with the MY picks official Anugerah Meletop 2015 and find predictions of other Meletop fans.'); | |
}) | |
.finally(done); | |
$httpBackend.flush(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment