add other Tests

main
ByrmGkcn 2023-12-06 15:26:13 +01:00
parent 5fefabc6a0
commit 466a917698
3 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sample Test</title>
</head>
<body>
<h1>Hello, World!</h1>
<script>
function greet() {
return "Hello from JavaScript!";
}
console.log(greet());
</script>
</body>
</html>

View File

@ -0,0 +1,5 @@
function greet() {
return "Hello from JavaScript!";
}
console.log(greet());

View File

@ -12,4 +12,18 @@ class ParserTest {
assertEquals("This is a string.", output) assertEquals("This is a string.", output)
} }
@Test
fun testTakeOnlyJs() {
val fileToTest = "src/test/kotlin/HTMLFileWithScript.html"
val expectedJsCode = """
function greet() {
return "Hello from JavaScript!";
}
console.log(greet());""".trimIndent().replace("\\s+".toRegex(), " ")
val output = takeOnlyJs(fileToTest).trimIndent().replace("\\s+".toRegex(), " ")
assertEquals(expectedJsCode, output)
}
} }