<commit_before>import $ from "jquery";
import dom from "@patternslib/patternslib/src/core/dom";
import Pattern from "./cookietrigger";

describe("Cookie Trigger", () => {
    afterEach(() => {
        document.body.innerHTML = "";
    });

    it("The .pat-cookietrigger DOM element is shown if cookies are disabled", (done) => {
        document.body.innerHTML = `
          <div class="portalMessage error pat-cookietrigger">
          Cookies are not enabled. You must enable cookies before you can log in.
          </div>
        `;

        const el = document.querySelector(".pat-cookietrigger");
        dom.hide(el);

        const pattern = new Pattern(el);
        spyOn(pattern, "isCookiesEnabled").and.callFake(() => 0);
        pattern.init(el); // need to spy on already initialized pattern. re-init

        expect(el.style.display).not.toEqual("none");

        done();
    });

    it("The .pat-cookietrigger DOM element is hidden if cookies are enabled", (done) => {
        document.body.innerHTML = `
          <div class="portalMessage error pat-cookietrigger">
          Cookies are not enabled. You must enable cookies before you can log in.
          </div>
        `;

        const el = document.querySelector(".pat-cookietrigger");
        dom.hide(el);

        const pattern = new Pattern(el);
        spyOn(pattern, "isCookiesEnabled").and.callFake(() => 1);
        pattern.init(el); // need to spy on already initialized pattern. re-init

        expect(el.style.display).toEqual("none");

        done();
    });
});<commit_msg>pat cookietrigger - fix tests.<commit_after>import dom from "@patternslib/patternslib/src/core/dom";
import Pattern from "./cookietrigger";
import { jest } from "@jest/globals";

describe("Cookie Trigger", () => {
    afterEach(() => {
        document.body.innerHTML = "";
    });

    it("The .pat-cookietrigger DOM element is shown if cookies are disabled", (done) => {
        document.body.innerHTML = `
          <div class="portalMessage error pat-cookietrigger">
          Cookies are not enabled. You must enable cookies before you can log in.
          </div>
        `;

        const el = document.querySelector(".pat-cookietrigger");
        dom.hide(el);

        const pattern = new Pattern(el);
        jest.spyOn(pattern, "isCookiesEnabled").mockImplementation(() => 0);
        pattern.init(el); // need to spy on already initialized pattern. re-init

        expect(el.style.display).not.toEqual("none");

        done();
    });

    it("The .pat-cookietrigger DOM element is hidden if cookies are enabled", (done) => {
        document.body.innerHTML = `
          <div class="portalMessage error pat-cookietrigger">
          Cookies are not enabled. You must enable cookies before you can log in.
          </div>
        `;

        const el = document.querySelector(".pat-cookietrigger");
        dom.hide(el);

        const pattern = new Pattern(el);
        jest.spyOn(pattern, "isCookiesEnabled").mockImplementation(() => 1);
        pattern.init(el); // need to spy on already initialized pattern. re-init

        expect(el.style.display).toEqual("none");

        done();
    });
});
{'fraction_non_alphanumeric': 0.136292099464904, 'fraction_numerical': 0.0012590494176896443, 'mean_word_length': 2.507726269315673, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '5001661', 'n_tokens_mistral': 898, 'n_tokens_neox': 880, 'n_words': 242}