|
1 | 1 | (function (root, factory) {
|
2 | 2 | define([
|
3 | 3 | "jquery",
|
| 4 | + "jasmine", |
4 | 5 | "converse-core",
|
5 | 6 | "mock",
|
6 |
| - "test_utils", |
| 7 | + "test-utils", |
7 | 8 | "utils",
|
8 | 9 | "transcripts"
|
9 | 10 | ], factory
|
10 | 11 | );
|
11 |
| -} (this, function ($, converse, mock, test_utils, utils, transcripts) { |
| 12 | +} (this, function ($, jasmine, converse, mock, test_utils, utils, transcripts) { |
12 | 13 | var Strophe = converse.env.Strophe;
|
13 | 14 | var _ = converse.env._;
|
14 | 15 | var IGNORED_TAGS = [
|
|
48 | 49 |
|
49 | 50 | return describe("Transcripts of chat logs", function () {
|
50 | 51 |
|
51 |
| - it("can be used to replay conversations", mock.initConverse(function (_converse) { |
52 |
| - /* |
53 |
| - test_utils.openAndEnterChatRoom(_converse, "dummy", 'rooms.localhost', 'jc'); |
54 |
| - test_utils.openAndEnterChatRoom(_converse, "prosody", 'conference.prosody.im', 'jc'); |
55 |
| - */ |
56 |
| - test_utils.openAndEnterChatRoom(_converse, "discuss", 'conference.conversejs.org', 'jc'); |
57 |
| - spyOn(_converse, 'areDesktopNotificationsEnabled').andReturn(true); |
58 |
| - _.each(transcripts, function (transcript) { |
59 |
| - var text = transcript(); |
60 |
| - var xml = Strophe.xmlHtmlNode(text); |
61 |
| - $(xml).children('log').children('body').each(function (i, el) { |
62 |
| - $(el).children().each(function (i, el) { |
63 |
| - if (el.nodeType === 3) { |
64 |
| - return; // Ignore text |
65 |
| - } |
66 |
| - if (_.includes(IGNORED_TAGS, el.nodeName.toLowerCase())) { |
67 |
| - return; |
68 |
| - } |
69 |
| - var _stanza = traverseElement(el); |
70 |
| - _converse.connection._dataRecv(test_utils.createRequest(_stanza)); |
| 52 | + it("can be used to replay conversations", |
| 53 | + mock.initConverseWithPromises( |
| 54 | + null, ['rosterGroupsFetched'], {}, |
| 55 | + function (done, _converse) { |
| 56 | + |
| 57 | + _converse.allow_non_roster_messaging = true; |
| 58 | + |
| 59 | + test_utils.openAndEnterChatRoom(_converse, 'discuss', 'conference.conversejs.org', 'dummy').then(function () { |
| 60 | + spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true); |
| 61 | + _.each(transcripts, function (transcript) { |
| 62 | + var text = transcript(); |
| 63 | + var xml = Strophe.xmlHtmlNode(text); |
| 64 | + _.each(xml.firstElementChild.children, function (el) { |
| 65 | + _.each(el.children, function (el) { |
| 66 | + if (el.nodeType === 3) { |
| 67 | + return; // Ignore text |
| 68 | + } |
| 69 | + if (_.includes(IGNORED_TAGS, el.nodeName.toLowerCase())) { |
| 70 | + return; |
| 71 | + } |
| 72 | + var _stanza = traverseElement(el); |
| 73 | + _converse.connection._dataRecv(test_utils.createRequest(_stanza)); |
| 74 | + }); |
71 | 75 | });
|
72 | 76 | });
|
| 77 | + done(); |
73 | 78 | });
|
74 | 79 | }));
|
75 | 80 | });
|
|
0 commit comments