add other Tests
parent
5fefabc6a0
commit
466a917698
|
@ -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>
|
|
@ -0,0 +1,5 @@
|
||||||
|
function greet() {
|
||||||
|
return "Hello from JavaScript!";
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(greet());
|
|
@ -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)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue