Ejemplo n.º 1
0
            it("calls exec to get the timeout", function () {
                var success = jasmine.createSpy(),
                    fail = jasmine.createSpy();

                spyOn(window, "setInterval");
                accelerometer.watchAcceleration(success, fail);

                expect(exec).toHaveBeenCalledWith(jasmine.any(Function), jasmine.any(Function), "Accelerometer", "getTimeout", []);
            });
Ejemplo n.º 2
0
        it("starts the interval with the provided frequency", function () {
            var success = jasmine.createSpy(),
                fail = jasmine.createSpy();

            spyOn(window, "setInterval");
            accelerometer.watchAcceleration(success, fail, {frequency: 11});

            expect(window.setInterval).toHaveBeenCalledWith(jasmine.any(Function), 11);
        });
Ejemplo n.º 3
0
            it("doesn't set it if timeout is less than freq + 10sec", function () {
                var success = jasmine.createSpy(),
                    fail = jasmine.createSpy();

                spyOn(window, "setInterval");
                accelerometer.watchAcceleration(success, fail, {frequency: 1000});

                //execute the success callback ;)
                exec.mostRecentCall.args[0](20000);

                expect(exec).not.toHaveBeenCalledWith(null, null, "Accelerometer", "setTimeout", [11000]);
            });
Ejemplo n.º 4
0
            it("it sets it to 10 seconds greater than the frequency", function () {
                var success = jasmine.createSpy(),
                    fail = jasmine.createSpy();

                spyOn(window, "setInterval");
                accelerometer.watchAcceleration(success, fail, {frequency: 5000});

                //execute the success callback ;)
                exec.mostRecentCall.args[0](5000);

                expect(exec).toHaveBeenCalledWith(null, null, "Accelerometer", "setTimeout", [15000]);
            });
Ejemplo n.º 5
0
        it("gets the acceleration for the provided interval", function () {
            var success = jasmine.createSpy(),
                fail = jasmine.createSpy();

            spyOn(window, "setInterval");
            accelerometer.watchAcceleration(success, fail, {frequency: 11});

            //exec the interval callback!
            window.setInterval.mostRecentCall.args[0]();

            expect(exec).toHaveBeenCalledWith(success, fail, "Accelerometer", "getAcceleration", []);
        });
Ejemplo n.º 6
0
 it("logs the error message the error callback isn't a function", function () {
     spyOn(console, "log");
     accelerometer.watchAcceleration(jasmine.createSpy(), "rainbows");
     expect(console.log).toHaveBeenCalledWith("Accelerometer Error: errorCallback is not a function");
 });
Ejemplo n.º 7
0
 it("logs the error message when the success callback isn't a function", function () {
     spyOn(console, "log");
     accelerometer.watchAcceleration("ponies");
     expect(console.log).toHaveBeenCalledWith("Accelerometer Error: successCallback is not a function");
 });