﻿'use strict';

describe('The translate events test suite', function() {
    var $translateEvents;

    beforeEach(function() {
        module('mutant-ng-translate');

        inject(function (_$translateEvents_) {
            $translateEvents = _$translateEvents_;
        });
    });

    describe('Common tests', function () {
        it('should be defined', function () {
            expect($translateEvents).toBeDefined();
        });

        it('should be an object', function () {
            expect(typeof $translateEvents).toBe('object');
        });
    });

    describe('Subscribe exceptions tests', function() {
        it('should throw an exception if called without params', function () {
            expect($translateEvents.partLoaded.subscribe)
                .toThrowError(/callback must be defined to subscribe for an event/);
        });

        it('should throw an exception if callback is not a function', function () {
            expect(function () { $translateEvents.partLoaded.subscribe('callback'); })
                .toThrowError(/callback must be a function to subscribe for an event/);
        });
    });
});
@@ -90,18 +90,28 @@
 teEvents
+, callback
 ;%0A
-
 %0A    bef
@@ -272,32 +272,83 @@
 ts_;%0A        %7D);
+%0A%0A        callback = jasmine.createSpy('callback');
 %0A    %7D);%0A%0A    de
@@ -1086,16 +1086,16 @@
 k'); %7D)%0A
-
         
@@ -1193,12 +1193,1236 @@
 %0A    %7D);
+%0A%0A    describe('Subscribe tests', function() %7B%0A        it('should call registered callback', function () %7B%0A            $translateEvents.partLoaded.subscribe(callback);%0A            $translateEvents.partLoaded.publish();%0A%0A            expect(callback.calls.count()).toBe(1);%0A        %7D);%0A%0A        it('should call all registered callbacks', function () %7B%0A            $translateEvents.partLoaded.subscribe(callback);%0A            $translateEvents.partLoaded.subscribe(callback);%0A            $translateEvents.partLoaded.publish();%0A%0A            expect(callback.calls.count()).toBe(2);%0A        %7D);%0A%0A        it('should not call callback if unsibscribed', function () %7B%0A            $translateEvents.partLoaded.subscribe(callback);%0A            $translateEvents.partLoaded.subscribe(callback).unsubscribe();%0A            $translateEvents.partLoaded.publish();%0A%0A            expect(callback.calls.count()).toBe(1);%0A        %7D);%0A%0A        it('should call callback one time if disposable', function () %7B%0A            $translateEvents.partLoaded.subscribe(callback, true);%0A            $translateEvents.partLoaded.publish();%0A            $translateEvents.partLoaded.publish();%0A%0A            expect(callback.calls.count()).toBe(1);%0A        %7D);%0A    %7D);
 %0A%7D);

implement subscribe tests in translate events suite