Skip to content

Commit

Permalink
Add unit tests for material remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
geertw committed Jul 17, 2022
1 parent ef17460 commit 0b28d95
Showing 1 changed file with 121 additions and 1 deletion.
122 changes: 121 additions & 1 deletion models/departure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func TestDepartureRemarksTips(t *testing.T) {
}
}

func TestDepartureMaterialRemarks(t *testing.T) {
func TestDepartureMaterialRemarksRemainsBehind(t *testing.T) {
var departure Departure = Departure{
Station: Station{
Code: "RTD",
Expand Down Expand Up @@ -235,3 +235,123 @@ func TestDepartureMaterialRemarks(t *testing.T) {
t.Errorf("Remarks: expected %s, got %s", "Treinstellen 1234, 2345 blijven in Rotterdam C.", remarks[0])
}
}

func TestDepartureMaterialTipsAdded(t *testing.T) {
var departure Departure = Departure{
Station: Station{
Code: "RTD",
NameMedium: "Rotterdam C.",
},
TrainWings: []TrainWing{
{
Material: []Material{
{
NaterialType: "ICM",
Number: "1234",
Added: true,
},
},
},
},
}

_, tips := departure.GetRemarksTips("nl")

if tips[0] != "Trein wordt op dit station verlengd. Treinstel 1234 wordt op dit station bijgeplaatst" {
t.Errorf("Tips: expected %s, got %s", "Trein wordt op dit station verlengd. Treinstel 1234 wordt op dit station bijgeplaatst", tips[0])
}

departure = Departure{
Station: Station{
Code: "RTD",
NameMedium: "Rotterdam C.",
},
TrainWings: []TrainWing{
{
Material: []Material{
{
NaterialType: "ICM",
Number: "1234",
Added: true,
},
{
NaterialType: "ICM",
Number: "4321",
Added: false,
},
{
NaterialType: "ICM",
Number: "2345",
Added: true,
},
},
},
},
}

_, tips = departure.GetRemarksTips("nl")

if tips[0] != "Trein wordt op dit station verlengd. Treinstellen 1234, 2345 worden op dit station bijgeplaatst" {
t.Errorf("Tips: expected %s, got %s", "Trein wordt op dit station verlengd. Treinstellen 1234, 2345 worden op dit station bijgeplaatst", tips[0])
}
}

func TestDepartureMaterialRemarksClosed(t *testing.T) {
var departure Departure = Departure{
Station: Station{
Code: "RTD",
NameMedium: "Rotterdam C.",
},
TrainWings: []TrainWing{
{
Material: []Material{
{
NaterialType: "ICM",
Number: "1234",
Closed: true,
},
},
},
},
}

remarks, _ := departure.GetRemarksTips("nl")

if remarks[0] != "Treinstel 1234: niet instappen" {
t.Errorf("Remarks: expected %s, got %s", "Treinstel 1234: niet instappen", remarks[0])
}

departure = Departure{
Station: Station{
Code: "RTD",
NameMedium: "Rotterdam C.",
},
TrainWings: []TrainWing{
{
Material: []Material{
{
NaterialType: "ICM",
Number: "1234",
Closed: true,
},
{
NaterialType: "ICM",
Number: "4321",
Closed: false,
},
{
NaterialType: "ICM",
Number: "2345",
Closed: true,
},
},
},
},
}

remarks, _ = departure.GetRemarksTips("nl")

if remarks[0] != "Treinstellen 1234, 2345: niet instappen" {
t.Errorf("Remarks: expected %s, got %s", "Treinstellen 1234, 2345: niet instappen", remarks[0])
}
}

0 comments on commit 0b28d95

Please sign in to comment.