Skip to content

Commit 6960aae

Browse files
Alexander JayarajAlexander Jayaraj
authored andcommitted
Added test cases for issue #375
1 parent 52fea2a commit 6960aae

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
+ I love animals
2+
- ^topicRedirect("animals", "__favorite__")
3+
4+
+ I love pets
5+
- ^topicRedirect("pets", "__favorite__")
6+
7+
8+
> topic animals {keep}
9+
+ __favorite__
10+
- I don't like pets, what is your favorite?
11+
12+
+ Mine is cat
13+
- Cats are scary, what is your favorite?
14+
+ whatever
15+
% * what is your favorite *
16+
-Cats are scary
17+
18+
+ i do love animals
19+
- Yes, I do as well
20+
< topic
21+
22+
> topic pets {keep}
23+
+ __favorite__
24+
- Me too, what is your favorite?
25+
26+
+ Mine is cat
27+
- I love it too, what is your favorite ?
28+
+ whatever
29+
% * what is your favorite *
30+
-Cats are fun
31+
32+
+ i do love animals
33+
- No, I like only cats
34+
< topic

test/topicconversation.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/* global describe, it, before, after */
2+
3+
import mocha from 'mocha';
4+
import should from 'should/as-function';
5+
import helpers from './helpers';
6+
import { doesMatch, doesMatchTopic } from '../src/bot/getReply/helpers';
7+
8+
9+
// Testing topics that include and mixin other topics.
10+
describe('SuperScript TopicsConversation', () => {
11+
before(helpers.before('topicconversation'));
12+
13+
describe('TopicConversationPets', () => {
14+
it('Conversation begin', (done) => {
15+
helpers.getBot().reply('tc_user', 'i love pets', (err, reply) => {
16+
should('Me too, what is your favorite?').eql(reply.string);
17+
done();
18+
});
19+
});
20+
21+
it('Inside the pets topic', (done) => {
22+
helpers.getBot().reply('tc_user', 'mine is cat', (err, reply) => {
23+
should(reply.string).eql('I love it too, what is your favorite ?');
24+
done();
25+
});
26+
});
27+
28+
it('Should remain in the pets topic', (done) => {
29+
helpers.getBot().reply('tc_user', 'whatever', (err, reply) => {
30+
should(reply.string).eql('Cats are fun');
31+
done();
32+
});
33+
});
34+
35+
});
36+
37+
describe('TopicConversationAnimals', () => {
38+
it('Conversation begin', (done) => {
39+
helpers.getBot().reply('tc_user', 'i love animals', (err, reply) => {
40+
should('I don\'t like pets, what is your favorite?').eql(reply.string);
41+
done();
42+
});
43+
});
44+
45+
it('Inside the pets topic', (done) => {
46+
helpers.getBot().reply('tc_user', 'mine is cat', (err, reply) => {
47+
should(reply.string).eql('Cats are scary, what is your favorite?');
48+
done();
49+
});
50+
});
51+
52+
it('Should remain in the pets topic', (done) => {
53+
helpers.getBot().reply('tc_user', 'whatever', (err, reply) => {
54+
should(reply.string).eql('Cats are scary');
55+
done();
56+
});
57+
});
58+
59+
});
60+
61+
after(helpers.after);
62+
});

0 commit comments

Comments
 (0)