<commit_before>import Vue from 'vue';
import '../../utils/polyfills';
import MessagePlugin, { MMessage, MMessageState, MMessageMode } from './message';

const STATE_SUCCESS_CSS: string = 'm--is-success';
const STATE_INFORMATION_CSS: string = 'm--is-information';
const STATE_WARNING_CSS: string = 'm--is-warning';
const STATE_ERROR_CSS: string = 'm--is-error';
const MODE_REGULAR_CSS: string = 'm--is-regular';
const MODE_LIGHT_CSS: string = 'm--is-light';

let message: MMessage;

describe('message', () => {
    beforeEach(() => {
        Vue.use(MessagePlugin);
        message = new MMessage().$mount();
    });

    it('css class for button group are not present', () => {
        expect(message.$el.classList.contains(STATE_INFORMATION_CSS)).toBeFalsy();
        expect(message.$el.classList.contains(STATE_WARNING_CSS)).toBeFalsy();
        expect(message.$el.classList.contains(STATE_ERROR_CSS)).toBeFalsy();
        expect(message.$el.classList.contains(MODE_LIGHT_CSS)).toBeFalsy();
    });

    it('state prop', () => {
        expect(message.$el.classList.contains(STATE_INFORMATION_CSS)).toBeFalsy();
        expect(message.$el.classList.contains(STATE_WARNING_CSS)).toBeFalsy();
        expect(message.$el.classList.contains(STATE_ERROR_CSS)).toBeFalsy();

        message.state = MMessageState.Information;
        Vue.nextTick(() => {
            expect(message.$el.classList.contains(STATE_INFORMATION_CSS)).toBeTruthy();
            expect(message.$el.classList.contains(STATE_SUCCESS_CSS)).toBeFalsy();

            message.state = MMessageState.Warning;
            Vue.nextTick(() => {
                expect(message.$el.classList.contains(STATE_WARNING_CSS)).toBeTruthy();
                expect(message.$el.classList.contains(STATE_INFORMATION_CSS)).toBeFalsy();

                message.state = MMessageState.Error;
                Vue.nextTick(() => {
                    expect(message.$el.classList.contains(STATE_ERROR_CSS)).toBeTruthy();
                    expect(message.$el.classList.contains(STATE_WARNING_CSS)).toBeFalsy();

                    message.state = MMessageState.Success;
                    Vue.nextTick(() => {
                        expect(message.$el.classList.contains(STATE_SUCCESS_CSS)).toBeTruthy();
                        expect(message.$el.classList.contains(STATE_ERROR_CSS)).toBeFalsy();
                    });
                });
            });
        });
    });

    it('mode prop', () => {
        expect(message.$el.classList.contains(MODE_LIGHT_CSS)).toBeFalsy();

        message.mode = MMessageMode.Light;
        Vue.nextTick(() => {
            expect(message.$el.classList.contains(MODE_LIGHT_CSS)).toBeTruthy();
            expect(message.$el.classList.contains(MODE_REGULAR_CSS)).toBeFalsy();

            message.mode = MMessageMode.Regular;
            Vue.nextTick(() => {
                expect(message.$el.classList.contains(MODE_REGULAR_CSS)).toBeTruthy();
                expect(message.$el.classList.contains(MODE_LIGHT_CSS)).toBeFalsy();
            });
        });
    });

});<commit_msg>Message: unit test , click event<commit_after>import Vue from 'vue';
import '../../utils/polyfills';
import MessagePlugin, { MMessage, MMessageState, MMessageMode } from './message';

const STATE_SUCCESS_CSS: string = 'm--is-success';
const STATE_INFORMATION_CSS: string = 'm--is-information';
const STATE_WARNING_CSS: string = 'm--is-warning';
const STATE_ERROR_CSS: string = 'm--is-error';
const MODE_REGULAR_CSS: string = 'm--is-regular';
const MODE_LIGHT_CSS: string = 'm--is-light';

let message: MMessage;

describe('message', () => {
    beforeEach(() => {
        Vue.use(MessagePlugin);
        message = new MMessage().$mount();
    });

    it('css class for button group are not present', () => {
        expect(message.$el.classList.contains(STATE_INFORMATION_CSS)).toBeFalsy();
        expect(message.$el.classList.contains(STATE_WARNING_CSS)).toBeFalsy();
        expect(message.$el.classList.contains(STATE_ERROR_CSS)).toBeFalsy();
        expect(message.$el.classList.contains(MODE_LIGHT_CSS)).toBeFalsy();
    });

    it('state prop', () => {
        expect(message.$el.classList.contains(STATE_INFORMATION_CSS)).toBeFalsy();
        expect(message.$el.classList.contains(STATE_WARNING_CSS)).toBeFalsy();
        expect(message.$el.classList.contains(STATE_ERROR_CSS)).toBeFalsy();

        message.state = MMessageState.Information;
        Vue.nextTick(() => {
            expect(message.$el.classList.contains(STATE_INFORMATION_CSS)).toBeTruthy();
            expect(message.$el.classList.contains(STATE_SUCCESS_CSS)).toBeFalsy();

            message.state = MMessageState.Warning;
            Vue.nextTick(() => {
                expect(message.$el.classList.contains(STATE_WARNING_CSS)).toBeTruthy();
                expect(message.$el.classList.contains(STATE_INFORMATION_CSS)).toBeFalsy();

                message.state = MMessageState.Error;
                Vue.nextTick(() => {
                    expect(message.$el.classList.contains(STATE_ERROR_CSS)).toBeTruthy();
                    expect(message.$el.classList.contains(STATE_WARNING_CSS)).toBeFalsy();

                    message.state = MMessageState.Success;
                    Vue.nextTick(() => {
                        expect(message.$el.classList.contains(STATE_SUCCESS_CSS)).toBeTruthy();
                        expect(message.$el.classList.contains(STATE_ERROR_CSS)).toBeFalsy();
                    });
                });
            });
        });
    });

    it('mode prop', () => {
        expect(message.$el.classList.contains(MODE_LIGHT_CSS)).toBeFalsy();

        message.mode = MMessageMode.Light;
        Vue.nextTick(() => {
            expect(message.$el.classList.contains(MODE_LIGHT_CSS)).toBeTruthy();
            expect(message.$el.classList.contains(MODE_REGULAR_CSS)).toBeFalsy();

            message.mode = MMessageMode.Regular;
            Vue.nextTick(() => {
                expect(message.$el.classList.contains(MODE_REGULAR_CSS)).toBeTruthy();
                expect(message.$el.classList.contains(MODE_LIGHT_CSS)).toBeFalsy();
            });
        });
    });

    it('close button event', () => {
        let clickSpy = jasmine.createSpy('clickSpy');
        let vm = new Vue({
            template: `
                <m-message @close="onClick($event)">Consequat ut proident est ullamco consequat ullamco.</m-message>
            `,
            methods: {
                onClick: clickSpy
            }
        }).$mount();

        let closeButton = vm.$el.querySelector('button');

        if (closeButton) {
            closeButton.click();
        }

        Vue.nextTick(() => {
            expect(clickSpy).toHaveBeenCalled();
        });
    });

});
{'fraction_non_alphanumeric': 0.15151515151515152, 'fraction_numerical': 0.0, 'mean_word_length': 2.564805057955743, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '5435829', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1951, 'n_words': 227}