package com.chrisfolger.needsmoredojo.testutil;

import com.intellij.lang.javascript.JavaScriptFileType;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.impl.source.PsiFileImpl;
import org.jetbrains.annotations.NotNull;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class MockPsiFile extends PsiFileImpl
{
    private String name;
    private String path;
    private MockPsiDirectory directory;

    public MockPsiFile(String fileName, String path) {
        super(mock(FileViewProvider.class));

        this.name = fileName;
        this.path = path;

        directory = new MockPsiDirectory(path);
    }

    @NotNull
    @Override
    public FileType getFileType() {
        return new JavaScriptFileType();
    }

    @Override
    public PsiDirectory getContainingDirectory()
    {
        return this.directory;
    }

    @Override
    public void accept(@NotNull PsiElementVisitor psiElementVisitor) {
        return;
    }

    @Override
    public String getName()
    {
        return this.name;
    }
}

@@ -1243,11 +1243,212 @@
 e;%0A    %7D
+%0A%0A    @Override%0A    public VirtualFile getVirtualFile()%0A    %7B%0A        VirtualFile file = mock(VirtualFile.class);%0A        when(file.getCanonicalPath()).thenReturn(this.path);%0A        return file;%0A    %7D
 %0A%7D%0A

update mocks