-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathkba-create-callback.test.ts
More file actions
62 lines (55 loc) · 1.71 KB
/
kba-create-callback.test.ts
File metadata and controls
62 lines (55 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
import { callbackType } from '@forgerock/sdk-types';
import { describe, it, expect } from 'vitest';
import type { Callback } from '@forgerock/sdk-types';
import { KbaCreateCallback } from './kba-create-callback.js';
describe('KbaCreateCallback', () => {
const payload: Callback = {
type: callbackType.KbaCreateCallback,
output: [
{
name: 'prompt',
value: 'What is your favorite color?',
},
{
name: 'predefinedQuestions',
value: ['Question 1', 'Question 2'],
},
{
name: 'allowUserDefinedQuestions',
value: true,
},
],
input: [
{
name: 'IDToken1question',
value: '',
},
{
name: 'IDToken1answer',
value: '',
},
],
};
it('should allow getting the prompt and questions', () => {
const cb = new KbaCreateCallback(payload);
expect(cb.getPrompt()).toBe('What is your favorite color?');
expect(cb.getPredefinedQuestions()).toEqual(['Question 1', 'Question 2']);
});
it('should allow setting the question and answer', () => {
const cb = new KbaCreateCallback(payload);
cb.setQuestion('My custom question');
cb.setAnswer('Blue');
expect(cb.getInputValue('IDToken1question')).toBe('My custom question');
expect(cb.getInputValue('IDToken1answer')).toBe('Blue');
});
it('should indicate if user-defined questions are allowed', () => {
const cb = new KbaCreateCallback(payload);
expect(cb.isAllowedUserDefinedQuestions()).toBe(true);
});
});