-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathpagetypeclassifier_test.go
More file actions
54 lines (48 loc) · 1.1 KB
/
pagetypeclassifier_test.go
File metadata and controls
54 lines (48 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package pagetypeclassifier
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPageTypeClassifier(t *testing.T) {
t.Run("test creation of new PageTypeClassifier", func(t *testing.T) {
epc := New()
assert.NotNil(t, epc)
})
t.Run("test classification non error page text", func(t *testing.T) {
epc := New()
assert.Equal(t, "nonerror", epc.Classify(`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Terms of Service</title>
</head>
<body>
<h1>Welcome to our Terms of Service page.</h1>
<p>Understand our conditions for providing services.</p>
</body>
</html>
`))
})
t.Run("test classification on error page text", func(t *testing.T) {
epc := New()
assert.Equal(t, "error", epc.Classify(`<!DOCTYPE html>
<html>
<head>
<title>Error 403: Forbidden</title>
<style>
.error-message {
text-align: center;
color: #333;
}
</style>
</head>
<body>
<div class="error-message">
<h1>Error 403: Forbidden</h1>
<p>Sorry you don't have access rights to this page.</p>
</div>
</body>
</html>
`))
})
}