-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathhappy.userIdOnStartConversation.js
More file actions
69 lines (51 loc) · 2.16 KB
/
happy.userIdOnStartConversation.js
File metadata and controls
69 lines (51 loc) · 2.16 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
63
64
65
66
67
68
69
import 'dotenv/config';
import onErrorResumeNext from 'on-error-resume-next';
import { timeouts } from './constants.json';
import * as createDirectLine from './setup/createDirectLine';
import postActivity from './setup/postActivity';
import waitForBotToRespond from './setup/waitForBotToRespond';
import waitForConnected from './setup/waitForConnected';
describe('Happy path', () => {
let unsubscribes;
beforeEach(() => unsubscribes = []);
afterEach(() => unsubscribes.forEach(fn => onErrorResumeNext(fn)));
describe('should receive the welcome message from bot', () => {
let directLine;
describe('using REST', () => {
beforeEach(() => jest.setTimeout(timeouts.rest));
test('with secret', async () => {
directLine = await createDirectLine.forREST({ token: false });
});
});
describe('using Web Socket', () => {
beforeEach(() => jest.setTimeout(timeouts.webSocket));
test('with secret', async () => {
directLine = await createDirectLine.forWebSocket({ token: false });
});
});
afterEach(async () => {
// If directLine object is undefined, that means the test is failing.
if (!directLine) { return; }
unsubscribes.push(directLine.end.bind(directLine));
directLine.setUserId('u_test');
await waitForBotToRespond(directLine, ({ text }) => text === 'Welcome');
});
});
describe('should use conversationStartProperties when starting conversation', () => {
let directLine;
test('using Streaming Extensions', async () => {
jest.setTimeout(timeouts.streamingExtensions);
directLine = await createDirectLine.forStreamingExtensions({ conversationStartProperties: { user: { id: 'u_test' } }});
});
afterEach(async () => {
// If directLine object is undefined, that means the test is failing.
if (!directLine) { return; }
unsubscribes.push(directLine.end.bind(directLine));
unsubscribes.push(await waitForConnected(directLine));
await Promise.all([
postActivity(directLine, { text: 'Hello, World!', type: 'message' }),
waitForBotToRespond(directLine, ({ from }) => from.id === 'u_test')
]);
});
});
});