Skip to content

Commit

Permalink
Update Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khadijahazward committed Apr 17, 2024
1 parent b2c6457 commit ec4d012
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package io.ballerina.cli.cmd;

import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

Expand All @@ -29,6 +30,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.stream.Stream;

import static io.ballerina.cli.cmd.CommandOutputUtils.getOutput;

Expand Down Expand Up @@ -58,14 +60,29 @@ public void setup() throws IOException {
public void testDocCommand() throws IOException {
Path projectPath = this.testResources.resolve("doc_project");
System.setProperty("user.dir", projectPath.toString());
Path destinationPath = projectPath.resolve("target")
.resolve("apidocs").resolve("foo").resolve("winery").resolve("0.1.0");
DocCommand docCommand = new DocCommand(this.printStream, this.printStream, false);
docCommand.execute();

Assert.assertTrue(Files.exists(this.testResources.resolve("doc_project").resolve("target")
.resolve("apidocs").resolve("foo").resolve("winery").resolve("0.1.0").resolve("index.html")));
Assert.assertTrue(Files.exists(destinationPath.resolve("api-docs.js")));
Assert.assertTrue(Files.exists(destinationPath.resolve("api-docs.json")));
}

Files.delete(this.testResources.resolve("doc_project").resolve("target")
.resolve("apidocs").resolve("foo").resolve("winery").resolve("0.1.0").resolve("index.html"));
@Test(description = "Test doc command on a ballerina project to check if all the UI components are present.")
public void testDocCommandUiComponents() throws IOException {
Path projectPath = this.testResources.resolve("doc_project");
System.setProperty("user.dir", projectPath.toString());
Path destinationPath = projectPath.resolve("doc_project").resolve("target")
.resolve("apidocs").resolve("foo").resolve("winery").resolve("0.1.0");
DocCommand docCommand = new DocCommand(this.printStream, this.printStream, false);
docCommand.execute();

Assert.assertTrue(Files.exists(destinationPath.resolve("bundle.js")));
Assert.assertTrue(Files.exists(destinationPath.resolve("favicon.ico")));
Assert.assertTrue(Files.exists(destinationPath.resolve("globals.css")));
Assert.assertTrue(Files.exists(destinationPath.resolve("index.html")));
Assert.assertTrue(Files.exists(destinationPath.resolve("vercel.svg")));
}

@Test(description = "Test doc command on a ballerina project with custom target dir.")
Expand Down

0 comments on commit ec4d012

Please sign in to comment.