/**
 * Karma tests
 *
 * @author ryan
 */

/**
 * app.js Tests
 */
describe('Unit: Routing', function () {
    it('Should Map Routes to Controllers', function() {
        module('democracy-lab-app');

        inject(function($route) {

            expect($route.routes['/'].controller).toBe('main-controller');
            expect($route.routes['/'].templateUrl).
                toEqual('./pages/login.html');

            expect($route.routes['/home'].controller).toBe('main-controller');
            expect($route.routes['/home'].templateUrl).
                toEqual('./pages/login.html');

            expect($route.routes['/issue'].controller).toBe('issue-controller');
            expect($route.routes['/issue'].templateUrl).
                toEqual('./pages/issue.html');
        });
    });
});

/**
 * appController.js Tests
 */
describe('Unit: main-controller', function() {
    // Load the module with MainController
    beforeEach(module('democracy-lab-app'));

    var ctrl;
    var fact;
    // inject the $controller and $rootScope services
    // in the beforeEach block
    beforeEach(inject(function($controller, $injector) {
        // Create the controller
        ctrl = $controller('main-controller');
        fact = $injector.get('dataFac');
    }));

    it('Verify title', function() {
        expect(ctrl.title).toEqual("Login or Create Account");
    });

    it('Verify Create Form pops', function() {
        ctrl.createAccount();
        expect(ctrl.showCreateForm).toEqual(true);
    });

    // TODO fix later
    it('Verify User already in DB', function() {
        ctrl.new_user = "rta";
        fact.postUser(ctrl.new_user);
        expect(false);
    });
});

describe('Unit: issue-controller', function() {
    // Load the module with MainController
    beforeEach(module('democracy-lab-app'));

    var ctrl;
    // inject the $controller and $rootScope services
    // in the beforeEach block
    beforeEach(inject(function($controller) {
        // Create the controller
        ctrl = $controller('issue-controller');
    }));

    it('Verify Title',
        function() {
            expect(ctrl.title).toEqual("Weigh in on an issue");
    });

    it('Verify Form Clears on Press', function() {
        ctrl.submitIssue();
        expect(ctrl.new_title = "");
        expect(ctrl.new_description = "");
    });

    it('Verify vote changes voting to true', function() {
        ctrl.vote();
        expect(ctrl.voting).toEqual(true);
    });

});

describe('Unit: explore-controller', function() {
    // Load the module with MainController
    beforeEach(module('democracy-lab-app'));

    var ctrl;
    // inject the $controller and $rootScope services
    // in the beforeEach block
    beforeEach(inject(function($controller) {
        // Create the controller
        ctrl = $controller('explore-controller');
    }));
    it('Verify Title',
        function() {
            expect(ctrl.title).toEqual("Explore the issues");
        });
});
@@ -1272,116 +1272,8 @@
 );%0A%0A
-    it('Verify title', function() %7B%0A        expect(ctrl.title).toEqual(%22Login or Create Account%22);%0A    %7D);%0A%0A
     
@@ -1307,32 +1307,32 @@
 ', function() %7B%0A
+
         ctrl.cre
@@ -1958,125 +1958,8 @@
 );%0A%0A
-    it('Verify Title',%0A        function() %7B%0A            expect(ctrl.title).toEqual(%22Weigh in on an issue%22);%0A    %7D);%0A%0A
     
@@ -2617,32 +2617,32 @@
 e-controller');%0A
+
     %7D));%0A    it(
@@ -2638,125 +2638,7 @@
 ));%0A
-    it('Verify Title',%0A        function() %7B%0A            expect(ctrl.title).toEqual(%22Explore the issues%22);%0A        %7D);%0A
 %7D);

test fix