Skip to content

Instantly share code, notes, and snippets.

@matiassingers
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save matiassingers/b15dbc20bcf5f408587e to your computer and use it in GitHub Desktop.

Select an option

Save matiassingers/b15dbc20bcf5f408587e to your computer and use it in GitHub Desktop.

Revisions

  1. matiassingers revised this gist Nov 6, 2014. 1 changed file with 60 additions and 0 deletions.
    60 changes: 60 additions & 0 deletions meletop.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    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();
    });
    });
    });
  2. matiassingers revised this gist Nov 6, 2014. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions category.js
    Original file line number Diff line number Diff line change
    @@ -13,8 +13,6 @@ describe('Controller: MeletopCategoryCtrl', function(){
    notificationService: notificationService
    });
    }));



    it('should have the MeletopCategoryCtrl', function () {
    expect(MeletopCategoryCtrl).toBeDefined();
  3. matiassingers revised this gist Nov 6, 2014. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions category.js
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,13 @@ describe('Controller: MeletopCategoryCtrl', function(){
    notificationService: notificationService
    });
    }));



    it('should have the MeletopCategoryCtrl', function () {
    expect(MeletopCategoryCtrl).toBeDefined();

    expect(notificationService.load).toHaveBeenCalled();
    });
    });

  4. matiassingers created this gist Nov 6, 2014.
    16 changes: 16 additions & 0 deletions category.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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
    });
    }));