frontend: add tests against XSS

This commit is contained in:
Lan Tian
2021-01-17 02:21:23 +08:00
parent 1baf325149
commit a984095282
4 changed files with 182 additions and 5 deletions

30
frontend/dn42_test.go Normal file
View File

@@ -0,0 +1,30 @@
package main
import (
"testing"
)
func TestDN42WhoisFilter(t *testing.T) {
input := "name: Testing\ndescr: Description"
result := dn42WhoisFilter(input)
expectedResult := `name: Testing
1 line(s) skipped.
`
if result != expectedResult {
t.Errorf("Output doesn't match expected: %s", result)
}
}
func TestDN42WhoisFilterUnneeded(t *testing.T) {
input := "name: Testing\nwhatever: Description"
result := dn42WhoisFilter(input)
if result != input+"\n" {
t.Errorf("Output doesn't match expected: %s", result)
}
}