package mobi.hsz.idea.gitignore.completion;

import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
import mobi.hsz.idea.gitignore.file.GitignoreFileType;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;

public class CompletionTest extends LightPlatformCodeInsightFixtureTestCase {
    public void testSimple() {
        myFixture.getTempDirFixture().createFile("fileName.txt");
        doTest("fileN<caret>", "fileName.txt<caret>");
    }

    public void testCurrentDirectoryAlias() throws IOException {
        myFixture.getTempDirFixture().createFile("fileName.txt");
        doTest("./fileN<caret>", "./fileName.txt<caret>");
    }

    public void testNestedDirectory() throws IOException {
        myFixture.getTempDirFixture().findOrCreateDir("dir").createChildData(this, "fileName.txt");
        doTest("dir/fileN<caret>", "dir/fileName.txt<caret>");
    }

    public void testInHiddenDirectory() throws IOException {
        myFixture.getTempDirFixture().findOrCreateDir(".hidden").createChildData(this, "fileName.txt");
        doTest(".hidden/fileN<caret>", ".hidden/fileName.txt<caret>");
    }

    private void doTest(@NotNull String beforeText, @NotNull String afterText) {
        myFixture.configureByText(GitignoreFileType.INSTANCE, beforeText);
        myFixture.completeBasic();
        myFixture.checkResult(afterText);
    }
}

@@ -1158,239 +1158,877 @@
   %7D%0A
-%0A    private void doTest(@NotNull String beforeText, @NotNull String afterText) %7B%0A        myFixture.configureByText(GitignoreFileType.INSTANCE, beforeText);%0A        myFixture.completeBasic();%0A        myFixture.checkResult(afterText
+        %0A    public void testInGlobDirectory() throws IOException %7B%0A        myFixture.getTempDirFixture().findOrCreateDir(%22glob1%22).createChildData(this, %22fileName1.txt%22);%0A        myFixture.getTempDirFixture().findOrCreateDir(%22glob2%22).createChildData(this, %22fileName2.txt%22);%0A        doTestVariants(%22*/fileN%3Ccaret%3E%22, %22fileName1.txt%22, %22fileName2.txt%22);%0A    %7D%0A%0A    private void doTest(@NotNull String beforeText, @NotNull String afterText) %7B%0A        myFixture.configureByText(GitignoreFileType.INSTANCE, beforeText);%0A        myFixture.completeBasic();%0A        myFixture.checkResult(afterText);%0A    %7D%0A    %0A    private void doTestVariants(@NotNull String beforeText, String... variants) %7B%0A        myFixture.configureByText(GitignoreFileType.INSTANCE, beforeText);%0A        myFixture.completeBasic();%0A        assertContainsElements(myFixture.getLookupElementStrings(), variants
 );%0A 

Test completion with glob