Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-hooks-for-single-case: false positive in nested functions #177

Closed
rugk opened this issue Aug 8, 2018 · 0 comments · Fixed by #238
Closed

no-hooks-for-single-case: false positive in nested functions #177

rugk opened this issue Aug 8, 2018 · 0 comments · Fixed by #238
Labels

Comments

@rugk
Copy link

rugk commented Aug 8, 2018

describe("common module: Localiser", function () {
    describe("init()", function () {
        it("replaces html lang attribute", function () {
            const stubGetUiLang = sinon.stub().returns("EXA-01");
            browser.i18n.getUILanguage = stubGetUiLang;

            Localiser.init();

            chai.assert.strictEqual(document.querySelector("html").getAttribute("lang"), "EXA-01", "did not set language code correctly");
            chai.assert(stubGetUiLang.calledOnceWithExactly(), "i18n.getUILanguage was not called correctly");
        });

        it("replaces '__MSG_extensionNameShort__' as text content", function () {
            setTestHtml('<span id="testExtensionName" class="message-text" data-i18n="__MSG_extensionNameShort__">What is my name?</span>');
            const stubGetMessage = sinon.stub().withArgs("extensionNameShort").returns("My fake extension name 101");
            browser.i18n.getMessage = stubGetMessage;

            Localiser.init();

            chai.assert(stubGetMessage.calledOnceWithExactly("extensionNameShort"), "i18n.getMessage was not called correctly");
            chai.assert.strictEqual(document.getElementById("testExtensionName").innerHTML, "My fake extension name 101", "did not replace span with correct content");
        });
    });

    afterEach(function() {
        console.log("sdds");

      // restore the default sandbox
      sinon.restore();
    });

});

The afterEach triggers the eslint rule, but actually, it is run after each of the inner tests, too (verifiable with the console.log), as such it is not about a single test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants