// Unit tests for things related to FTUE

(function(g,$) {

    describe("ftue tests", function() {

        var ftue = null;

        var appFake = {
            clientId: '12345',
            bindScreen: function(){},
            notify: function(){},
            ajaxError: function() { console.debug("ajaxError"); }
        };

        beforeEach(function() {
            g.jamClient = new JK.FakeJamClient();
            ftue = JK.FtueWizard(appFake);
        });

        describe("degreesFromRange", function() {

            describe("20, 0, 40, 360", function() {
                it("should return 0", function() {
                    var deg = ftue._degreesFromRange(20,0,40,360);
                    expect(deg).toEqual(0);
                });
            });

            describe("0, 0, 40, 360", function() {
                it("should return 180", function() {
                    var deg = ftue._degreesFromRange(0,0,40,360);
                    expect(deg).toEqual(180);
                });
            });


            describe("10, 0, 40, 360", function() {
                it("should return 270", function() {
                    var deg = ftue._degreesFromRange(10,0,40,360);
                    expect(deg).toEqual(270);
                });
            });

            describe("30, 0, 40, 360", function() {
                it("should return 90", function() {
                    var deg = ftue._degreesFromRange(30,0,40,360);
                    expect(deg).toEqual(90);
                });
            });

            // Test value outside of range
            describe("100, 0, 40, 360", function() {
                it("should return 180", function() {
                    var deg = ftue._degreesFromRange(100,0,40,360);
                    expect(deg).toEqual(180);
                });
            });
            describe("-120, 0, 40, 360", function() {
                it("should return 180", function() {
                    var deg = ftue._degreesFromRange(-120,0,40,360);
                    expect(deg).toEqual(180);
                });
            });

            // Limit degrees to 300
            describe("20, 0, 40, 300", function() {
                it("should return 0", function() {
                    var deg = ftue._degreesFromRange(20,0,40,300);
                    expect(deg).toEqual(0);
                });
            });

            describe("0, 0, 40, 300", function() {
                it("should return 210", function() {
                    var deg = ftue._degreesFromRange(0,0,40,300);
                    expect(deg).toEqual(210);
                });
            });

            describe("10, 0, 40, 300", function() {
                it("should return 285", function() {
                    var deg = ftue._degreesFromRange(10,0,40,300);
                    expect(deg).toEqual(285);
                });
            });

            describe("30, 0, 40, 300", function() {
                it("should return 75", function() {
                    var deg = ftue._degreesFromRange(30,0,40,300);
                    expect(deg).toEqual(75);
                });
            });

        });

    });

})(window, jQuery);