<commit_before>'use strict';

/* jasmine specs for services go here */
/* global describe, beforeEach, it, expect, inject */
describe('service', function() {
    beforeEach(module('monkeyFace.services'));


    describe('version', function() {
        it('should return current version', inject(function(version) {
            expect(version).toEqual('0.0.1');
        }));
    });


    describe('backend', function() {
        beforeEach(module(function($provide) {
            $provide.value('backendUrl', '');
        }));

        it('should have a isLoggedIn method', inject(function($httpBackend, backend) {
            expect(typeof backend.isLoggedIn).toBe('function');

            // Should not be logged in by default
//            expect(backend.isLoggedIn()).toBe(false);
            // TODO: this doesn't work because it stores the sid in the session storage
            // Need to mock the sessionStorage somehow
        }));

        it('should have a login method', inject(function($httpBackend, backend) {
            // Set up the http backend mock
            $httpBackend.expectPOST('/session', {email: '<EMAIL>', password: '<PASSWORD>'})
                .respond({
                    sessionId: 'test-session-d'
                })
            ;

            expect(typeof backend.login).toBe('function');

            // Use login
            var req = backend.login('<EMAIL>', 'word');
            $httpBackend.flush();

            // Make sure we got a $http object
            expect(typeof req.then).toBe('function');
            expect(typeof req.success).toBe('function');
            expect(typeof req.error).toBe('function');

            // Should be logged in now
            expect(backend.isLoggedIn()).toBe(true);
        }));

        // TODO: test other backend methods
    });
});<commit_msg>New failing backend unit test for addActivityLink method<commit_after>'use strict';

/* jasmine specs for services go here */
/* global describe, beforeEach, it, expect, inject */
describe('service', function() {
    beforeEach(module('monkeyFace.services'));


    describe('version', function() {
        it('should return current version', inject(function(version) {
            expect(version).toEqual('0.0.1');
        }));
    });


    describe('backend', function() {
        beforeEach(module(function($provide) {
            $provide.value('backendUrl', '');
        }));

        it('should have a isLoggedIn method', inject(function($httpBackend, backend) {
            expect(typeof backend.isLoggedIn).toBe('function');

            // Should not be logged in by default
//            expect(backend.isLoggedIn()).toBe(false);
            // TODO: this doesn't work because it stores the sid in the session storage
            // Need to mock the sessionStorage somehow
        }));

        it('should have a login method', inject(function($httpBackend, backend) {
            // Define our expectations
            $httpBackend.expectPOST('/session', {email: '<EMAIL>', password: '<PASSWORD>'})
                .respond({
                    sessionId: 'test-session-d'
                })
            ;

            expect(typeof backend.login).toBe('function');

            // Use login
            var req = backend.login('<EMAIL>', 'word');
            $httpBackend.flush();

            // Make sure we got a $http object
            expect(typeof req.then).toBe('function');
            expect(typeof req.success).toBe('function');
            expect(typeof req.error).toBe('function');

            // Should be logged in now
            expect(backend.isLoggedIn()).toBe(true);
        }));


        it('should have a addActivityLink method', inject(function($httpBackend, backend) {
            // Define our expectations
            var expectedPostData = {
                target: {
                    fullName: 'Tester'
                },
                location: 'Bern',
                startData: '01.02.2014',
                activityId: '1'
            };
            $httpBackend.expectPOST('/activityLink', expectedPostData)
                .respond({
                    referenceCode: 'ref-123'
                })
            ;

            expect(typeof backend.addActivityLink).toBe('function');

            // Use login
            var req = backend.addActivityLink('Tester', 'Bern', '01.02.2014', '1');
            $httpBackend.flush();

            // Make sure we got a $http object
            expect(typeof req.then).toBe('function');
            expect(typeof req.success).toBe('function');
            expect(typeof req.error).toBe('function');
        }));

        // TODO: test other backend methods
    });
});
{'fraction_non_alphanumeric': 0.13668298914200552, 'fraction_numerical': 0.005748350010645093, 'mean_word_length': 1.9234598630989421, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6855838', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1144, 'n_words': 292}