﻿(function () {
    'use strict';

    var worker = null;

    describe("WebWorker", function () {

        it("should be defined", function () {
            expect(WebWorker).toBeDefined();
            return;
        });

        describe("instance", function () {
            
            afterEach(function () {
                worker = null;
                return;
            });

            describe("constructor", function () {

                it("should accept string selector if first argument is string and if the element exists", function () {
                    
                    worker = new WebWorker("#test-worker-script-elem");
                    
                    expect(worker).not.toBe(null);

                    return;
                });

                it("should accept string URL if first argument is string and an element of same selector does not exist", function () {
                    
                    worker = new WebWorker("/js/example-worker.js");
                    
                    expect(worker).not.toBe(null);

                    return;
                });

                return;
            });

            return;
        });

        describe("static", function () {
        });

        return;
    });

    return;
})();
@@ -301,32 +301,120 @@
 h(function () %7B%0A
+                if (worker) %7B%0A                    worker.terminate();%0A                %7D%0A
                 
@@ -640,37 +640,16 @@
 on () %7B%0A
-                    %0A
         
@@ -712,37 +712,16 @@
 elem%22);%0A
-                    %0A
         
@@ -755,33 +755,32 @@
 not.toBe(null);%0A
-%0A
                 
@@ -972,147 +972,1129 @@
     
-%0A                    worker = new WebWorker(%22/js/example-worker.js%22);%0A                    %0A                    expect(worker).not.toBe(null
+worker = new WebWorker(%22/js/example-worker.js%22);%0A                    expect(worker).not.toBe(null);%0A                    return;%0A                %7D);%0A%0A                it(%22should support terminating the worker%22, function () %7B%0A                    worker = new WebWorker(%22/js/example-worker.js%22);%0A                    spyOn(worker, 'terminate');%0A                    worker.terminate();%0A                    expect(worker.terminate).toHaveBeenCalled();%0A                    return;%0A                %7D);%0A%0A                it(%22should trigger the WORKER_LOADED event once the worker has loaded%22, function (done) %7B%0A%0A                    var Listeners = %7B%0A                        WORKER_LOADED: function () %7B%0A                            expect(Listeners.WORKER_LOADED).toHaveBeenCalled();%0A                            done();%0A                            return;%0A                        %7D%0A                    %7D;%0A%0A                    spyOn(Listeners, 'WORKER_LOADED').and.callThrough();%0A%0A                    worker = new WebWorker(%22/js/example-worker.js%22);%0A                    worker.on(WebWorker.Event.WORKER_LOADED, Listeners.WORKER_LOADED
 );%0A%0A

Update specs