<commit_before>import angular = require('angular');
import ngMock = require('angular-mocks');

import IRootScopeService = angular.IRootScopeService;

import './index.ts';
import IComponentController = angular.IComponentController;
import {StarRatingController, IStarRatingCompBindings, starRatingColors} from "./star-rating.controller";
import {StarRatingComponent} from "./star-rating.component";

describe('Star rating controller', () => {

    let $componentController;
    let starRatingCtrl;
    let rootScope;
    let scope;

    let negativeValue: number = -1;
    let defaultValue: number = 0;

    let defaultColor: starRatingColors = "default";
    let negativeColor: starRatingColors = "negative";
    let okColor: starRatingColors = "middle";
    let positiveColor: starRatingColors = "positive";

    let lowRating = 1;
    let okRating = 3;
    let highRating = 5;

    beforeEach(angular.mock.module('star-rating'));

    beforeEach(inject(($rootScope, _$componentController_) => {
        scope = $rootScope.$new();
        $componentController = _$componentController_;
    }));

    it('should expose a `starRatingComp` object', () => {
        starRatingCtrl = getStarRatingCtrl();

        expect(starRatingCtrl).toBeDefined();
        expect(typeof starRatingCtrl.onStarClicked).toBe('function');
    });

    it('should contain proper default values if no bindings are set', () => {
        starRatingCtrl = getStarRatingCtrl();
        //bindings
        //<
        expect(starRatingCtrl.id).toBe(undefined);
        expect(starRatingCtrl.text).toBe(undefined);
        expect(starRatingCtrl.staticColor).toBe(undefined);
        expect(starRatingCtrl.labelPosition).toBe(undefined);
        expect(starRatingCtrl.speed).toBe(undefined);
        expect(starRatingCtrl.size).toBe(undefined);
        expect(starRatingCtrl.starType).toBe(undefined);
        expect(starRatingCtrl.spread).toBe(undefined);
        expect(starRatingCtrl.readOnly).toBe(undefined);
        expect(starRatingCtrl.disabled).toBe(undefined);
        expect(starRatingCtrl.rating).toBe(0);
        expect(starRatingCtrl.numOfStars).toBe(StarRatingController.DefaultNumOfStars);
        //expect(typeof starRatingCtrl.getColor).toBe("function");
        //expect(typeof starRatingCtrl.getHalfStarVisible).toBe("function");
        //&
        expect(typeof starRatingCtrl.onUpdate).toBe("function");
        expect(typeof starRatingCtrl.onClick).toBe("function");

        //ctrl only
        expect(starRatingCtrl.classEmpty).toBe(StarRatingController.DefaultClassEmpty);
        expect(starRatingCtrl.classFilled).toBe(StarRatingController.DefaultClassFilled);
        expect(starRatingCtrl.pathEmpty).toBe(StarRatingController.DefaultSvgPathEmpty);
        expect(starRatingCtrl.pathFilled).toBe(StarRatingController.DefaultSvgPathFilled);
        starRatingCtrl.numOfStars = 5;
        expect(typeof starRatingCtrl.stars).toBe("object");
        expect(starRatingCtrl.stars.length).toBe(StarRatingController.DefaultNumOfStars);
        expect(starRatingCtrl.stars[0]).toBe(1);
        expect(starRatingCtrl.color).toBe('default');
    });

    fit('should set custom bindings properly', () => {
        let bindings = <IStarRatingCompBindings>{
            //<
            id: 'custom-id'
            , text: 'custom-text'
            , staticColor: 'positive'
            , labelPosition: 'right'
            , speed: 'immediately'
            , size: 'small'
            , starType: 'icon'
            , spread: true
            , readOnly: true
            , disabled: true
            , rating: 3
            , numOfStars: 8
            , getColor: function (rating, numOfStars, staticColor) {
                return "default";
            }
            , getHalfStarVisible: function (rating) {
                return true;
            }
            //&
            , onClick: function ($event) {
                return 'onClick'
            }
            , onUpdate: function ($event) {
                return 'onUpdate'
            }
        };

        starRatingCtrl = getStarRatingCtrl(bindings);

        //expect(starRatingCtrl.id).toBe(bindings.id);
        //expect(starRatingCtrl.text).toBe(bindings.text);
        //expect(starRatingCtrl.staticColor).toBe(bindings.staticColor);
        //expect(starRatingCtrl.labelPosition).toBe(bindings.labelPosition);
        //expect(starRatingCtrl.speed).toBe(bindings.speed);
        //expect(starRatingCtrl.size).toBe(bindings.size);
        //expect(starRatingCtrl.starType).toBe(bindings.starType);
        //expect(starRatingCtrl.spread).toBe(bindings.spread);
        //expect(starRatingCtrl.readOnly).toBe(bindings.readOnly);
        //expect(starRatingCtrl.disabled).toBe(bindings.disabled);
        //expect(starRatingCtrl.rating).toBe(bindings.rating);
        //expect(starRatingCtrl.getColor(1, 5, 'default')).toBe(bindings.getColor(1, 5, 'default'));
        //expect(starRatingCtrl.getHalfStarVisible(1)).toBe(bindings.getHalfStarVisible(1));
        //expect(starRatingCtrl.onClick({$event: {rating: 1}})).toBe(bindings.onClick({$event: {rating: 1}}));
        //expect(starRatingCtrl.onUpdate({$event: {rating: 1}})).toBe(bindings.onUpdate({$event: {rating: 1}}));
    });

    it("should return proper values when firing _getColor function", () => {

        let testValues = {};
        testValues[negativeValue] = defaultColor;<commit_msg>test(jasmine): fix tests on travis<commit_after>import angular = require('angular');
import ngMock = require('angular-mocks');

import IRootScopeService = angular.IRootScopeService;

import './index.ts';
import IComponentController = angular.IComponentController;
import {StarRatingController, IStarRatingCompBindings, starRatingColors} from "./star-rating.controller";
import {StarRatingComponent} from "./star-rating.component";

describe('Star rating controller', () => {

    let $componentController;
    let starRatingCtrl;
    let rootScope;
    let scope;

    let negativeValue: number = -1;
    let defaultValue: number = 0;

    let defaultColor: starRatingColors = "default";
    let negativeColor: starRatingColors = "negative";
    let okColor: starRatingColors = "middle";
    let positiveColor: starRatingColors = "positive";

    let lowRating = 1;
    let okRating = 3;
    let highRating = 5;

    beforeEach(angular.mock.module('star-rating'));

    beforeEach(inject(($rootScope, _$componentController_) => {
        scope = $rootScope.$new();
        $componentController = _$componentController_;
    }));

    it('should expose a `starRatingComp` object', () => {
        starRatingCtrl = getStarRatingCtrl();

        expect(starRatingCtrl).toBeDefined();
        expect(typeof starRatingCtrl.onStarClicked).toBe('function');
    });

    it('should contain proper default values if no bindings are set', () => {
        starRatingCtrl = getStarRatingCtrl();
        //bindings
        //<
        expect(starRatingCtrl.id).toBe(undefined);
        expect(starRatingCtrl.text).toBe(undefined);
        expect(starRatingCtrl.staticColor).toBe(undefined);
        expect(starRatingCtrl.labelPosition).toBe(undefined);
        expect(starRatingCtrl.speed).toBe(undefined);
        expect(starRatingCtrl.size).toBe(undefined);
        expect(starRatingCtrl.starType).toBe(undefined);
        expect(starRatingCtrl.spread).toBe(undefined);
        expect(starRatingCtrl.readOnly).toBe(undefined);
        expect(starRatingCtrl.disabled).toBe(undefined);
        expect(starRatingCtrl.rating).toBe(0);
        expect(starRatingCtrl.numOfStars).toBe(StarRatingController.DefaultNumOfStars);
        //expect(typeof starRatingCtrl.getColor).toBe("function");
        //expect(typeof starRatingCtrl.getHalfStarVisible).toBe("function");
        //&
        expect(typeof starRatingCtrl.onUpdate).toBe("function");
        expect(typeof starRatingCtrl.onClick).toBe("function");

        //ctrl only
        expect(starRatingCtrl.classEmpty).toBe(StarRatingController.DefaultClassEmpty);
        expect(starRatingCtrl.classFilled).toBe(StarRatingController.DefaultClassFilled);
        expect(starRatingCtrl.pathEmpty).toBe(StarRatingController.DefaultSvgPathEmpty);
        expect(starRatingCtrl.pathFilled).toBe(StarRatingController.DefaultSvgPathFilled);
        starRatingCtrl.numOfStars = 5;
        expect(typeof starRatingCtrl.stars).toBe("object");
        expect(starRatingCtrl.stars.length).toBe(StarRatingController.DefaultNumOfStars);
        expect(starRatingCtrl.stars[0]).toBe(1);
        expect(starRatingCtrl.color).toBe('default');
    });

    fit('should set custom bindings properly', () => {
        let bindings = <IStarRatingCompBindings>{
            //<
            id: 'custom-id'
           /* , text: 'custom-text'
            , staticColor: 'positive'
            , labelPosition: 'right'
            , speed: 'immediately'
            , size: 'small'
            , starType: 'icon'
            , spread: true
            , readOnly: true
            , disabled: true
            , rating: 3
            , numOfStars: 8
            , getColor: function (rating, numOfStars, staticColor) {
                return "default";
            }
            , getHalfStarVisible: function (rating) {
                return true;
            }
            //&
            , onClick: function ($event) {
                return 'onClick'
            }
            , onUpdate: function ($event) {
                return 'onUpdate'
            }*/
        };

        starRatingCtrl = getStarRatingCtrl(bindings);

        //expect(starRatingCtrl.id).toBe(bindings.id);
        //expect(starRatingCtrl.text).toBe(bindings.text);
        //expect(starRatingCtrl.staticColor).toBe(bindings.staticColor);
        //expect(starRatingCtrl.labelPosition).toBe(bindings.labelPosition);
        //expect(starRatingCtrl.speed).toBe(bindings.speed);
        //expect(starRatingCtrl.size).toBe(bindings.size);
        //expect(starRatingCtrl.starType).toBe(bindings.starType);
        //expect(starRatingCtrl.spread).toBe(bindings.spread);
        //expect(starRatingCtrl.readOnly).toBe(bindings.readOnly);
        //expect(starRatingCtrl.disabled).toBe(bindings.disabled);
        //expect(starRatingCtrl.rating).toBe(bindings.rating);
        //expect(starRatingCtrl.getColor(1, 5, 'default')).toBe(bindings.getColor(1, 5, 'default'));
        //expect(starRatingCtrl.getHalfStarVisible(1)).toBe(bindings.getHalfStarVisible(1));
        //expect(starRatingCtrl.onClick({$event: {rating: 1}})).toBe(bindings.onClick({$event: {rating: 1}}));
        //expect(starRatingCtrl.onUpdate({$event: {rating: 1}})).toBe(bindings.onUpdate({$event: {rating: 1}}));
    });

    it("should return proper values when firing _getColor function", () => {

        let testValues = {};
        testValues[negativeValue] = defaultColor;
{'fraction_non_alphanumeric': 0.13090741593735605, 'fraction_numerical': 0.0038691847075080607, 'mean_word_length': 3.0222304557243422, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '5613314', 'n_tokens_mistral': 3149, 'n_tokens_neox': 2928, 'n_words': 455}