Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.jetbrains.lang.dart.util;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright?


import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.lang.dart.DartCodeInsightFixtureTestCase;

public class PubspecYamlUtilTest extends DartCodeInsightFixtureTestCase {

public void testGetDartProjectName() {
myFixture.addFileToProject("pubspec.yaml", "name: my_project\n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing newline?

final VirtualFile pubspec = myFixture.findFileInTempDir("pubspec.yaml");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using the PUBSPEC_YAML constant here and below?

assertEquals("my_project", PubspecYamlUtil.getDartProjectName(pubspec));
}

public void testIsPubspecFile() {
myFixture.addFileToProject("pubspec.yaml", "");
final VirtualFile pubspec = myFixture.findFileInTempDir("pubspec.yaml");
assertTrue(PubspecYamlUtil.isPubspecFile(pubspec));

myFixture.addFileToProject("other.yaml", "");
final VirtualFile other = myFixture.findFileInTempDir("other.yaml");
assertFalse(PubspecYamlUtil.isPubspecFile(other));
}

public void testFindPubspecYamlFile() {
myFixture.addFileToProject("pubspec.yaml", "name: my_project\n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That pesky newline again! :D

myFixture.addFileToProject("lib/main.dart", "");

final VirtualFile mainDart = myFixture.findFileInTempDir("lib/main.dart");
final VirtualFile pubspec = PubspecYamlUtil.findPubspecYamlFile(getProject(), mainDart);
assertNotNull(pubspec);
assertEquals("pubspec.yaml", pubspec.getName());
}
}
Loading