status-go/api/app_state_test.go

29 lines
849 B
Go
Raw Permalink Normal View History

package api
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseAppType(t *testing.T) {
2018-06-27 08:11:45 +00:00
check := func(input string, expectedState appState, expectError bool) {
actualState, err := parseAppState(input)
assert.Equalf(t, expectedState, actualState, "unexpected result from parseAppState")
if expectError {
assert.NotNil(t, err, "error should not be nil")
}
}
2018-06-27 08:11:45 +00:00
check("active", appStateForeground, false)
check("background", appStateBackground, false)
check("inactive", appStateInactive, false)
check(" acTIVE ", appStateForeground, false)
check(" backGROUND ", appStateBackground, false)
check(" INACTIVE ", appStateInactive, false)
check("", appStateInvalid, true)
check("back ground", appStateInvalid, true)
check(" back ground ", appStateInvalid, true)
check(" ", appStateInvalid, true)
}