-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
97 lines (87 loc) · 2.93 KB
/
index.test.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const {readChat} = require('./index');
const Node = ({text, left, right}) => ({
text,
left,
right,
})
const conversationTree = {
messages: [
{text: 'Hello, John! It looks like you booked a Basic Economy flight.'},
{text: 'Are you aware that this flight doesn\'t have any storage for carry-on luggage?'}
],
left: {
messages: [
{text: "Some other limitations you may want to consider is that you will not be able to pick a seat."},
{text: "We're happy to let you know that we can upgrade you today for just $25!", label: 1},
{text: "Would you like to do that now?"}
],
left: {
messages: [{text: 'Okay, please let our customer service team know if you change your mind.'}]
},
right: {
messages: [
{text: "Okay, you've been upgraded!"}
]
}
},
right: {
goto: 1
}
};
test('node tree two, no, and not right now', () => {
// Arrange
const userAnswers = ['No', 'Not right now'];
// Act
const result = readChat(conversationTree, userAnswers);
console.log(result);
// Assert
expect(result).toEqual(
`Hello, John! It looks like you booked a Basic Economy flight.
Are you aware that this flight doesn't have any storage for carry-on luggage?
-No
Some other limitations you may want to consider is that you will not be able to pick a seat.
1:We're happy to let you know that we can upgrade you today for just $25!
Would you like to do that now?
-Not right now
=Okay, please let our customer service team know if you change your mind.
`
);
});
test('I did not, Yes, please upgrade', () => {
// Arrange
const userAnswers = ['No', 'Yes, please upgrade'];
// Act
const result = readChat(conversationTree, userAnswers);
// Assert
console.log(result);
expect(result).toEqual(
`Hello, John! It looks like you booked a Basic Economy flight.
Are you aware that this flight doesn't have any storage for carry-on luggage?
-No
Some other limitations you may want to consider is that you will not be able to pick a seat.
1:We're happy to let you know that we can upgrade you today for just $25!
Would you like to do that now?
-Yes, please upgrade
=Okay, you've been upgraded!
`
);
})
test('I did not, Yes', () => {
// Arrange
const userAnswers = ['No', 'Yes >1'];
// Act
const result = readChat(conversationTree, userAnswers);
// Assert
console.log(result);
expect(result).toEqual(
`Hello, John! It looks like you booked a Basic Economy flight.
Are you aware that this flight doesn't have any storage for carry-on luggage?
-No
Some other limitations you may want to consider is that you will not be able to pick a seat.
1:We're happy to let you know that we can upgrade you today for just $25!
Would you like to do that now?
-Yes, please upgrade
=Okay, you've been upgraded!
`
);
})