Refactor folder structure
This commit is contained in:
parent
7e9a205d53
commit
c7cca02ca7
30 changed files with 610 additions and 933 deletions
53
html_test.go
53
html_test.go
|
|
@ -1,53 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// returns a minified version of the input HTML string
|
||||
func TestMinifyHTML(t *testing.T) {
|
||||
input := "<html><head><title>Test</title></head><body><h1>Hello, World!</h1></body></html>"
|
||||
expected := "<title>Test</title><h1>Hello, World!</h1>"
|
||||
|
||||
result := minifyHTML(input)
|
||||
|
||||
if result != expected {
|
||||
t.Errorf("Expected minified HTML: %s, but got: %s", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMinifyCSS(t *testing.T) {
|
||||
cssString := `
|
||||
body {
|
||||
background-color: red;
|
||||
color: blue;
|
||||
}
|
||||
`
|
||||
expected := "body{background-color:red;color:blue}"
|
||||
result := minifyCSS(cssString)
|
||||
if result != expected {
|
||||
t.Errorf("Expected minified CSS string to be %s, but got %s", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
// Displays error messages if there are any parse errors
|
||||
func TestErrorMessages(t *testing.T) {
|
||||
// Initialize test data
|
||||
parseResult := []ParseResult{
|
||||
{IsError: true, Msg: "Error 1"},
|
||||
{IsError: true, Msg: "Error 2"},
|
||||
}
|
||||
|
||||
h := HTMLData{
|
||||
ParseResult: parseResult,
|
||||
}
|
||||
|
||||
// Invoke function under test
|
||||
result := fullHTML(h)
|
||||
|
||||
// Assert that the result contains the error messages
|
||||
if !strings.Contains(result, "Error 1") || !strings.Contains(result, "Error 2") {
|
||||
t.Errorf("Expected error messages, but got: %s", result)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue