<commit_before>﻿describe('Binding: tooltip', function () {
    this.prepareTestElement('<div data-bind="tooltip: options"></div>');

    it('Should call tooltip method on creation and pass to it options', function() {
        var vm = {
            options: { title: 'test', position: 'left' }
        };

        spyOn($.fn, 'tooltip');
        ko.applyBindings(vm, this.testElement[0]);

        expect($.fn.tooltip).toHaveBeenCalledWith(vm.options);
    });
    
    it('Should extend tooltip data after options update instead of calling tooltip', function () {
        var vm = {
            options: { title: ko.observable('test') }
        };
        
        ko.applyBindings(vm, this.testElement[0]);
        
        spyOn($.fn, 'tooltip');

        vm.options.title('changed text');
        
        expect($.fn.tooltip).not.toHaveBeenCalled();
        expect(this.testElement.data('bs.tooltip').options.title).toEqual(vm.options.title());
    });
});<commit_msg>Rewrote tooltip tests<commit_after>﻿describe('Binding: tooltip', function () {
    this.prepareTestElement('<div data-bind="tooltip: options">Text</div>');

    afterEach(function() {
        $('.tooltip').remove();
    });

    it('Should add tooltip to element', function() {
        var vm = {
            options: { title: 'test' }
        };

        ko.applyBindings(vm, this.testElement[0]);
        this.testElement.mouseover();

        expect($('.tooltip')).toExist();
    });

    it('Should update tooltip according to changes of observables', function() {
        var vm = {
            options: { title: ko.observable('test') }
        };

        ko.applyBindings(vm, this.testElement[0]);
        vm.options.title('new text');
        this.testElement.mouseover();

        expect($('.tooltip')).toContainText('new text');
    });
});
{'fraction_non_alphanumeric': 0.16785518376302797, 'fraction_numerical': 0.0021941854086670325, 'mean_word_length': 2.5348837209302326, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7308627', 'n_tokens_mistral': 528, 'n_tokens_neox': 519, 'n_words': 101}