2018-03-14 15:46:21 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseAppType(t *testing.T) {
|
2024-11-19 09:31:29 +00:00
|
|
|
check := func(input string, expectedState AppState, expectError bool) {
|
|
|
|
actualState, err := ParseAppState(input)
|
2018-06-27 08:11:45 +00:00
|
|
|
assert.Equalf(t, expectedState, actualState, "unexpected result from parseAppState")
|
2018-03-14 15:46:21 +00:00
|
|
|
if expectError {
|
|
|
|
assert.NotNil(t, err, "error should not be nil")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-19 09:31:29 +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)
|
2018-03-14 15:46:21 +00:00
|
|
|
}
|