-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBuildResultsHTMLTemplate_test.go
47 lines (41 loc) · 1.09 KB
/
BuildResultsHTMLTemplate_test.go
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
package main
import (
"io/ioutil"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBuildResultsHTMLTemplate(t *testing.T) {
t.Run("It parses and returns flights results", func(t *testing.T) {
fileContent, _ := ioutil.ReadFile("data-test/test_results_html")
searchInput := SearchInput{"FCO", "RTM", "2020-02-02"}
want := trimWhitespaces(string(fileContent))
got := trimWhitespaces(string(BuildResultsHTMLTemplate(getResultList(), searchInput)))
assert.Equal(t, want, got)
})
}
func trimWhitespaces(initialString string) (strippedString string) {
strippedString = strings.Replace(initialString, " ", "", -1)
strippedString = strings.Replace(strippedString, "\n", "", -1)
return
}
func getResultList() []FlightResult {
return []FlightResult{
{
Departure: "AMS",
Arrival: "FCO",
DepartureTime: "16:30",
ArrivalTime: "18:50",
Price: "69",
Airline: "LEVEL",
},
{
Departure: "AMS",
Arrival: "FCO",
DepartureTime: "7:20",
ArrivalTime: "9:45",
Price: "123",
Airline: "KLM",
},
}
}