<commit_before>/*global jasmine, module, it, beforeEach, inject, describe, expect */
describe('Unit: stationsController', function () {
    "use strict";
    var ctrl, scope, q;
    
    // Load our controller module
    beforeEach(module('Trafikinfo.controllers'));

    // inject the $controller and $rootScope services in the beforeEach block
    beforeEach(inject(function ($controller, $rootScope, $q) {
        // Create a new scope that's a child of the $rootScope
        scope = $rootScope.$new();
        // Create the controller
        ctrl = $controller;
        q = $q;
    }));
    
    describe('when calling getStations', function () {
        var deferred, spyPromise, TAPIService;
        
        beforeEach(function () {
            // http://jsfiddle.net/onekilo79/LrAhf/
            deferred = q.defer();
            spyPromise = deferred.promise;

            TAPIService = jasmine.createSpyObj('TrafikinfoAPIService', ['getStations']);
            TAPIService.getStations.and.returnValue(spyPromise);

            spyPromise.success = function (fn) {
                spyPromise.then(function (data) {
                    return fn(data);
                });
                return spyPromise;
            };
                
            ctrl('stationsController', {$scope: scope, TrafikinfoAPIService: TAPIService});
        });
        
        it('should set $scope.stations to empty before calling getStations', function () {
            expect(scope.stations.length).toBe(0);
        });
        
        it('should set $scope.stations', function () {
            
            deferred.resolve({
                "RESPONSE": {"RESULT": [{"TrainStation": [
                    {"AdvertisedLocationName": "Västeraspby", "LocationSignature": "Väy", "Prognosticated": true},
                    {"AdvertisedLocationName": "Nässjö C", "LocationSignature": "N", "Prognosticated": true},
                    {"AdvertisedLocationName": "Källene", "LocationSignature": "Käe", "Prognosticated": false},
                    {"AdvertisedLocationName": "Järpås", "LocationSignature": "Jps", "Prognosticated": true}]}]}
            });
    
            scope.$apply();
            expect(scope.stations.length).toBe(4);
        });
    });
});<commit_msg>Added test of stationIdsToNames filter<commit_after>/*global jasmine, module, it, beforeEach, inject, describe, expect */
describe('Unit: stationsController', function () {
    "use strict";
    var ctrl, scope, q;
     var deferred, spyPromise, TAPIService;
    
    // Load our controller module
    beforeEach(module('Trafikinfo.controllers'));

    // inject the $controller and $rootScope services in the beforeEach block
    beforeEach(inject(function ($controller, $rootScope, $q) {
        // Create a new scope that's a child of the $rootScope
        scope = $rootScope.$new();
        // Create the controller
        ctrl = $controller;
        q = $q;
    }));
    
           
        
    beforeEach(function () {
        // http://jsfiddle.net/onekilo79/LrAhf/
        deferred = q.defer();
        spyPromise = deferred.promise;

        TAPIService = jasmine.createSpyObj('TrafikinfoAPIService', ['getStations']);
        TAPIService.getStations.and.returnValue(spyPromise);

        spyPromise.success = function (fn) {
            spyPromise.then(function (data) {
                return fn(data);
            });
            return spyPromise;
        };

        ctrl('stationsController', {$scope: scope, TrafikinfoAPIService: TAPIService});
    });
    
    describe('when calling getStations', function () {

        
        it('should set $scope.stations to empty before calling getStations', function () {
            expect(scope.stations.length).toBe(0);
        });
        
        it('should set $scope.stations', function () {
            
            deferred.resolve({
                "RESPONSE": {"RESULT": [{"TrainStation": [
                    {"AdvertisedLocationName": "Västeraspby", "LocationSignature": "Väy", "Prognosticated": true},
                    {"AdvertisedLocationName": "Nässjö C", "LocationSignature": "N", "Prognosticated": true},
                    {"AdvertisedLocationName": "Källene", "LocationSignature": "Käe", "Prognosticated": false},
                    {"AdvertisedLocationName": "Järpås", "LocationSignature": "Jps", "Prognosticated": true}]}]}
            });
    
            scope.$apply();
            expect(scope.stations.length).toBe(4);
        });
    });
    
    describe('Filter stationIdsToNames', function () {
        
        beforeEach(function () {
            scope.stations = [
                {"AdvertisedLocationName": "Västeraspby", "LocationSignature": "Väy", "Prognosticated": true},
                {"AdvertisedLocationName": "<NAME>", "LocationSignature": "N", "Prognosticated": true},
                {"AdvertisedLocationName": "Källene", "LocationSignature": "Käe", "Prognosticated": false},
                {"AdvertisedLocationName": "Järpås", "LocationSignature": "Jps", "Prognosticated": true}];
        }); 
        
        it('should exist', function ($filter) {
            expect($filter('stationIdsToNames')).not.toBeNull();
        });
        
        it('should translate id to name', inject(function ($filter) {
            expect($filter('stationIdsToNames')(["Väy",  "N", "Käe", "Jps"], scope))
                  .toBe("Västeraspby, Nässjö C, Källene, Järpås");
        }));
        
    });
});
{'fraction_non_alphanumeric': 0.14004016797516888, 'fraction_numerical': 0.001460653642505021, 'mean_word_length': 2.229952830188679, 'pattern_counts': {'":': 42, '<': 4, '<?xml version=': 0, '>': 4, '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': '6266811', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1515, 'n_words': 319}