|
1 | 1 | import { constructScopes, getIsTabValue, mergeConfigs, generateConfigs } from '../helper'; |
2 | 2 | import packageJson from '../../package.json'; |
3 | 3 | import { AuthAction, AuthnMethod, ConfigsOptions } from '../typings'; |
4 | | -import { stringify } from 'qs'; |
5 | 4 |
|
6 | 5 | describe('helper', () => { |
7 | 6 | test('constuctScopes', () => { |
@@ -133,45 +132,27 @@ describe('helper', () => { |
133 | 132 | ); |
134 | 133 | }); |
135 | 134 |
|
136 | | - test('with authnMethod parameter as an array', () => { |
137 | | - const configPayload: ConfigsOptions = { |
138 | | - authnMethod: ['sso', 'passwordless'] |
139 | | - }; |
140 | | - |
141 | | - expect(generateConfigs(configPayload)).toBe( |
142 | | - `sdk_platform=js&sdk_version=${packageJson.version}&authn_method%5B%5D=sso&authn_method%5B%5D=passwordless` |
143 | | - ); |
144 | | - }); |
145 | | - |
146 | 135 | test('query encoding should make sure config params are also encoded', () => { |
147 | 136 | const configPayload: ConfigsOptions = { |
148 | 137 | email: 'email&!@#(*)-304should be_encoded', |
149 | 138 | backTo: 'backTo #!@with []special= chars', |
150 | 139 | authAction: 'signup', |
151 | 140 | showAuthToggle: true, |
152 | 141 | showRememberMe: true, |
153 | | - authnMethod: ['sso', 'passwordless'] |
| 142 | + authnMethod: 'sso' |
154 | 143 | }; |
155 | 144 |
|
156 | 145 | expect(generateConfigs(configPayload)).toBe( |
157 | | - `sdk_platform=js&sdk_version=${packageJson.version}&email=email%26%21%40%23%28%2A%29-304should%20be_encoded&back_to=backTo%20%23%21%40with%20%5B%5Dspecial%3D%20chars&auth_action=signup&show_auth_toggle=true&show_remember_me=true&authn_method%5B%5D=sso&authn_method%5B%5D=passwordless` |
| 146 | + `sdk_platform=js&sdk_version=${packageJson.version}&email=email%26%21%40%23%28%2A%29-304should%20be_encoded&back_to=backTo%20%23%21%40with%20%5B%5Dspecial%3D%20chars&auth_action=signup&show_auth_toggle=true&show_remember_me=true&authn_method=sso` |
158 | 147 | ); |
159 | 148 | }); |
160 | 149 |
|
161 | | - test('Should filter out invalid authnMethod from array and authAction values', () => { |
| 150 | + test('Should raise an error when passing an array in authnMethod', () => { |
162 | 151 | const configPayload: ConfigsOptions = { |
163 | | - email: 'email', |
164 | | - backTo: 'backTo', |
165 | | - authAction: 'invalid-value' as AuthAction, |
166 | | - showAuthToggle: true, |
167 | | - showRememberMe: true, |
168 | | - authnMethod: ['oh-not-valid', 'sso'] as AuthnMethod[] |
| 152 | + authnMethod: ['oh-not-valid', 'should raise'] as unknown as AuthnMethod |
169 | 153 | }; |
170 | 154 |
|
171 | | - expect(generateConfigs(configPayload)).toBe( |
172 | | - `sdk_platform=js&sdk_version=${packageJson.version}&email=email&back_to=backTo&show_auth_toggle=true` + |
173 | | - `&show_remember_me=true&authn_method=sso` |
174 | | - ); |
| 155 | + expect(() => generateConfigs(configPayload)).toThrow(TypeError); |
175 | 156 | }); |
176 | 157 |
|
177 | 158 | test('Should reject invalid authnMethod from config', () => { |
|
0 commit comments