Skip to content

Commit 72c7dde

Browse files
updating tests
1 parent f10b99f commit 72c7dde

File tree

7 files changed

+19
-13
lines changed

7 files changed

+19
-13
lines changed

cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func TestRunCLI(t *testing.T) {
173173
{
174174
name: "Latest Flag",
175175
args: []string{"-l"},
176-
expectedOutput: "Latest Docker image version: v0.12.0\nLatest release tag: v0.12.0\n",
176+
expectedOutput: "Latest Docker image version: v0.12.1\nLatest release tag: v0.12.1\n",
177177
expectedCode: 0,
178178
},
179179
}

cmd/ability_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"bytes"
55
"fmt"
6+
"github.com/digitalghost-dev/poke-cli/styling"
67
"log"
78
"os"
89
"strings"
@@ -61,7 +62,7 @@ func TestAbilityCommand(t *testing.T) {
6162
{
6263
name: "Valid Execution",
6364
args: []string{"ability", "stench"},
64-
expectedOutput: stripANSI("Stench\nEffect: Has a 10% chance of making target Pokémon flinch with each hit."),
65+
expectedOutput: styling.StripANSI("Stench\nEffect: Has a 10% chance of making target Pokémon flinch with each hit."),
6566
expectError: false,
6667
},
6768
}

cmd/types_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"github.com/digitalghost-dev/poke-cli/styling"
45
"github.com/stretchr/testify/assert"
56
"testing"
67
)
@@ -50,9 +51,9 @@ func TestModelView_DisplayTable(t *testing.T) {
5051

5152
// Construct the expected output exactly as `View()` should render it
5253
expectedOutput := "Select a type!\n" +
53-
typesTableBorder.Render(m.table.View()) +
54+
styling.TypesTableBorder.Render(m.table.View()) +
5455
"\n" +
55-
keyMenu.Render("↑ (move up) • ↓ (move down)\nctrl+c | esc (quit) • enter (select)")
56+
styling.KeyMenu.Render("↑ (move up) • ↓ (move down)\nctrl+c | esc (quit) • enter (select)")
5657

5758
output := m.View()
5859

cmd/validateargs_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cmd
22

33
import (
4+
"github.com/digitalghost-dev/poke-cli/styling"
45
"strings"
56
"testing"
67
)
@@ -21,7 +22,7 @@ func TestValidatePokemonArgs(t *testing.T) {
2122
}
2223

2324
// Strip ANSI codes for comparison
24-
actualError := stripANSI(err.Error())
25+
actualError := styling.StripANSI(err.Error())
2526
expectedError = strings.TrimSpace(expectedError)
2627

2728
if actualError != expectedError {

connections/connection_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package connections
22

33
import (
44
"encoding/json"
5+
"github.com/digitalghost-dev/poke-cli/structs"
56
"github.com/stretchr/testify/assert"
67
"net/http"
78
"net/http/httptest"
@@ -30,7 +31,7 @@ func TestApiCallSetup(t *testing.T) {
3031
}
3132

3233
func TestAbilityApiCall(t *testing.T) {
33-
expectedAbility := AbilityJSONStruct{
34+
expectedAbility := structs.AbilityJSONStruct{
3435
Name: "Unaware",
3536
}
3637

@@ -47,7 +48,7 @@ func TestAbilityApiCall(t *testing.T) {
4748
}
4849

4950
func TestPokemonApiCall(t *testing.T) {
50-
expectedPokemon := PokemonJSONStruct{
51+
expectedPokemon := structs.PokemonJSONStruct{
5152
Name: "pikachu",
5253
ID: 25,
5354
Weight: 60,
@@ -84,7 +85,7 @@ func TestPokemonApiCall(t *testing.T) {
8485

8586
// TestTypesApiCall - Test for the TypesApiCall function
8687
func TestTypesApiCall(t *testing.T) {
87-
expectedTypes := TypesJSONStruct{
88+
expectedTypes := structs.TypesJSONStruct{
8889
Name: "electric",
8990
ID: 13,
9091
Pokemon: []struct {

flags/abilityflagset_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package flags
22

33
import (
44
"bytes"
5+
"github.com/digitalghost-dev/poke-cli/styling"
56
"github.com/stretchr/testify/assert"
67
"os"
78
"reflect"
@@ -58,7 +59,7 @@ Pokemon with Stench
5859
7. Skuntank 8. Trubbish 9. Garbodor
5960
10. Garbodor-Gmax
6061
`
61-
actualOutput := stripANSI(output.String())
62+
actualOutput := styling.StripANSI(output.String())
6263

6364
assert.True(t, strings.Contains(actualOutput, expectedOutput), "Output should contain Pokémon with the ability")
6465
}

flags/pokemonflagset_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package flags
33
import (
44
"bytes"
55
"fmt"
6+
"github.com/digitalghost-dev/poke-cli/styling"
67
"github.com/stretchr/testify/assert"
78
"os"
89
"reflect"
@@ -73,7 +74,7 @@ Hidden Ability: Chlorophyll
7374
`
7475

7576
// Assert the actual output matches the expected output
76-
actualOutput := stripANSI(output.String())
77+
actualOutput := styling.StripANSI(output.String())
7778

7879
assert.Equal(t, expectedOutput, actualOutput, "Output should contain data for the abilities flag")
7980
}
@@ -103,7 +104,7 @@ func TestImageFlag(t *testing.T) {
103104
assert.NoError(t, err)
104105

105106
// Validate that the output contains some expected patterns
106-
actualOutput := stripANSI(output.String())
107+
actualOutput := styling.StripANSI(output.String())
107108

108109
// Since the output is an ASCII image, we can't hardcode the expected output,
109110
// but we can check that it contains some general expected structure
@@ -177,7 +178,7 @@ Total 318
177178
`
178179

179180
// Assert output contains the expected header and typing information
180-
actualOutput := stripANSI(output.String())
181+
actualOutput := styling.StripANSI(output.String())
181182

182183
assert.Equal(t, expectedOutput, actualOutput, "Output should contain data for the stats flag")
183184

@@ -215,7 +216,7 @@ Type 2: Poison
215216
`
216217

217218
// Assert output contains the expected header and typing information
218-
actualOutput := stripANSI(output.String())
219+
actualOutput := styling.StripANSI(output.String())
219220

220221
assert.Equal(t, expectedOutput, actualOutput, "Output should contain data for the types flag")
221222
}

0 commit comments

Comments
 (0)