fix method type check

This commit is contained in:
Sebastian 2021-11-08 15:42:55 -03:00
parent c898eae296
commit 8481aadfd9
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
2 changed files with 7 additions and 2 deletions

View File

@ -40,7 +40,11 @@ export const NewProvider = createExample(TestedComponent, {
...reducerStatesExample.authEditing,
} as ReducerState);
export const NewSMSProvider = createExample(TestedComponent, {
export const NewVideoProvider = createExample(TestedComponent, {
...reducerStatesExample.authEditing,
} as ReducerState, { providerType: 'video'});
export const NewSmsProvider = createExample(TestedComponent, {
...reducerStatesExample.authEditing,
} as ReducerState, { providerType: 'sms'});

View File

@ -19,12 +19,13 @@ async function testProvider(url: string, expectedMethodType?: string): Promise<v
if (!("methods" in json) || !Array.isArray(json.methods)) {
throw Error("This provider doesn't have authentication method. Check the provider URL")
}
console.log("expected", expectedMethodType)
if (!expectedMethodType) {
return
}
let found = false
for (let i = 0; i < json.methods.length && !found; i++) {
found = json.methods[i].type !== expectedMethodType
found = json.methods[i].type === expectedMethodType
}
if (!found) {
throw Error(`This provider does not support authentication method ${expectedMethodType}`)