Skip to content

Commit 3e11dbc

Browse files
committed
fix: tests
1 parent 748357c commit 3e11dbc

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package thirdpartyemailpassword
2+
3+
import (
4+
"encoding/json"
5+
"io/ioutil"
6+
"net/http"
7+
"net/http/httptest"
8+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
"github.com/supertokens/supertokens-golang/supertokens"
12+
"github.com/supertokens/supertokens-golang/test/unittesting"
13+
)
14+
15+
func TestLoginMethodsReturnEmptyProviderArray(t *testing.T) {
16+
configValue := supertokens.TypeInput{
17+
Supertokens: &supertokens.ConnectionInfo{
18+
ConnectionURI: "http://localhost:8080",
19+
},
20+
AppInfo: supertokens.AppInfo{
21+
APIDomain: "api.supertokens.io",
22+
AppName: "SuperTokens",
23+
WebsiteDomain: "supertokens.io",
24+
},
25+
RecipeList: []supertokens.Recipe{
26+
Init(nil),
27+
},
28+
}
29+
30+
BeforeEach()
31+
unittesting.StartUpST("localhost", "8080")
32+
defer AfterEach()
33+
err := supertokens.Init(configValue)
34+
if err != nil {
35+
t.Error(err.Error())
36+
}
37+
mux := http.NewServeMux()
38+
testServer := httptest.NewServer(supertokens.Middleware(mux))
39+
defer testServer.Close()
40+
41+
resp, err := http.Get(testServer.URL + "/auth/loginmethods")
42+
if err != nil {
43+
t.Error(err.Error())
44+
}
45+
assert.Equal(t, http.StatusOK, resp.StatusCode)
46+
47+
respObj := map[string]interface{}{}
48+
respBytes, err := ioutil.ReadAll(resp.Body)
49+
assert.Nil(t, err)
50+
err = json.Unmarshal(respBytes, &respObj)
51+
assert.Nil(t, err)
52+
providersArr, ok := respObj["thirdParty"].(map[string]interface{})["providers"]
53+
assert.True(t, ok)
54+
assert.NotNil(t, providersArr)
55+
}

recipe/thirdpartypasswordless/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func TestMinimumConfigForThirdPartyPasswordlessWithEmailOrPhoneContactMethod(t *
8383
thirdPartyPasswordlessRecipe, err := GetRecipeInstanceOrThrowError()
8484
assert.NoError(t, err)
8585
assert.Equal(t, "USER_INPUT_CODE_AND_MAGIC_LINK", thirdPartyPasswordlessRecipe.Config.FlowType)
86+
assert.NotNil(t, thirdPartyPasswordlessRecipe.thirdPartyRecipe) // thirdPartyRecipe must be created always
8687
}
8788

8889
func TestForThirdPartyPasswordLessCreateAndSendCustomTextMessageWithFlowTypeMagicLinkAndPhoneContactMethod(t *testing.T) {

0 commit comments

Comments
 (0)