package de.espend.idea.shopware.tests.index;

import de.espend.idea.shopware.index.SnippetIndex;
import de.espend.idea.shopware.tests.ShopwareLightCodeInsightFixtureTestCase;

/**
 * @author Daniel Espendiller <daniel@espendiller.net>
 */
public class SnippetIndexTest extends ShopwareLightCodeInsightFixtureTestCase {
    public void setUp() throws Exception {
        super.setUp();
        myFixture.copyFileToProject("snippets.tpl");
        myFixture.copyFileToProject("widgets.ini", "snippets/frontend/listing/foobar_ini/widgets.ini");
        myFixture.copyFileToProject("javascript.js");
    }

    public String getTestDataPath() {
        return "src/test/java/de/espend/idea/shopware/tests/index/fixtures";
    }

    public void testTemplateUsageSnippetsAreInIndex() {
        assertIndexContains(SnippetIndex.KEY, "frontend/foobar", "frontend/detail/actions");

        assertIndexContainsKeyWithValue(SnippetIndex.KEY, "frontend/foobar", value ->
            value.contains("FO-O/BAR")
        );
    }

    public void testIniSnippetsAreInIndex() {
        assertIndexContains(SnippetIndex.KEY, "frontend/listing/foobar_ini/widgets");

        assertIndexContainsKeyWithValue(SnippetIndex.KEY, "frontend/listing/foobar_ini/widgets", value ->
            value.contains("swag-last-registrations/customer")
        );
    }

    public void testJavascriptCommentNamespaceSnippetsAreInIndex() {
        assertIndexContains(SnippetIndex.KEY, "backend/namespace");
    }
}

@@ -995,32 +995,186 @@
 BAR%22)%0A        );
+%0A%0A        assertIndexContainsKeyWithValue(SnippetIndex.KEY, %22frontend/detail/actions%22, value -%3E%0A            value.contains(%22DetailLinkNotepad%22)%0A        );
 %0A    %7D%0A%0A    publ

add test for normal snippet index