-
-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More usage of the
stx
tagged template literal
- Loading branch information
Showing
36 changed files
with
3,691 additions
and
3,756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/*global mock, converse */ | ||
|
||
const { $msg, u } = converse.env; | ||
const { Strophe, u, stx } = converse.env; | ||
|
||
describe("A Groupchat Message", function () { | ||
|
||
|
@@ -9,16 +9,16 @@ describe("A Groupchat Message", function () { | |
|
||
const muc_jid = '[email protected]'; | ||
const model = await mock.openAndEnterChatRoom(_converse, muc_jid, 'romeo'); | ||
const stanza = $pres({ | ||
to: '[email protected]/_converse.js-29092160', | ||
from: '[email protected]/newguy' | ||
}) | ||
.c('x', {xmlns: Strophe.NS.MUC_USER}) | ||
.c('item', { | ||
'affiliation': 'none', | ||
'jid': '[email protected]/_converse.js-290929789', | ||
'role': 'participant' | ||
}).tree(); | ||
|
||
const stanza = stx` | ||
<presence | ||
to="[email protected]/_converse.js-29092160" | ||
from="[email protected]/newguy" | ||
xmlns="jabber:client"> | ||
<x xmlns="${Strophe.NS.MUC_USER}"> | ||
<item affiliation="none" jid="[email protected]/_converse.js-290929789" role="participant"/> | ||
</x> | ||
</presence>`; | ||
_converse.api.connection.get()._dataRecv(mock.createRequest(stanza)); | ||
|
||
const view = _converse.chatboxviews.get(muc_jid); | ||
|
@@ -28,12 +28,15 @@ describe("A Groupchat Message", function () { | |
|
||
const firstMessageText = 'But soft, what light through yonder airlock breaks?'; | ||
const msg_id = u.getUniqueId(); | ||
await model.handleMessageStanza($msg({ | ||
'from': '[email protected]/newguy', | ||
'to': _converse.api.connection.get().jid, | ||
'type': 'groupchat', | ||
'id': msg_id, | ||
}).c('body').t(firstMessageText).tree()); | ||
await model.handleMessageStanza(stx` | ||
<message | ||
from="[email protected]/newguy" | ||
to="${_converse.api.connection.get().jid}" | ||
type="groupchat" | ||
id="${msg_id}" | ||
xmlns="jabber:client"> | ||
<body>${firstMessageText}</body> | ||
</message>`); | ||
await u.waitUntil(() => view.querySelectorAll('.chat-msg').length === 1); | ||
let firstAction = view.querySelector('.chat-msg__action-copy'); | ||
expect(firstAction).not.toBeNull(); | ||
|
@@ -61,26 +64,28 @@ describe("A Groupchat Message", function () { | |
|
||
const muc_jid = '[email protected]'; | ||
const model = await mock.openAndEnterChatRoom(_converse, muc_jid, 'romeo'); | ||
const stanza = $pres({ | ||
to: '[email protected]/_converse.js-29092160', | ||
from: '[email protected]/newguy' | ||
}) | ||
.c('x', {xmlns: Strophe.NS.MUC_USER}) | ||
.c('item', { | ||
'affiliation': 'none', | ||
'jid': '[email protected]/_converse.js-290929789', | ||
'role': 'participant' | ||
}).tree(); | ||
const stanza = stx` | ||
<presence | ||
to="[email protected]/_converse.js-29092160" | ||
from="[email protected]/newguy" | ||
xmlns="jabber:client"> | ||
<x xmlns="${Strophe.NS.MUC_USER}"> | ||
<item affiliation="none" jid="[email protected]/_converse.js-290929789" role="participant"/> | ||
</x> | ||
</presence>`; | ||
_converse.api.connection.get()._dataRecv(mock.createRequest(stanza)); | ||
|
||
const firstMessageText = 'But soft, what light through yonder airlock breaks?'; | ||
const msg_id = u.getUniqueId(); | ||
await model.handleMessageStanza($msg({ | ||
'from': '[email protected]/newguy', | ||
'to': _converse.api.connection.get().jid, | ||
'type': 'groupchat', | ||
'id': msg_id, | ||
}).c('body').t(firstMessageText).tree()); | ||
await model.handleMessageStanza(stx` | ||
<message | ||
from="[email protected]/newguy" | ||
to="${_converse.api.connection.get().jid}" | ||
type="groupchat" | ||
id="${msg_id}" | ||
xmlns="jabber:client"> | ||
<body>${firstMessageText}</body> | ||
</message>`); | ||
|
||
const view = _converse.chatboxviews.get(muc_jid); | ||
const textarea = await u.waitUntil(() => view.querySelector('textarea.chat-textarea')); | ||
|
@@ -107,37 +112,44 @@ describe("A Groupchat Message", function () { | |
mock.initConverse([], {}, async function (_converse) { | ||
const muc_jid = '[email protected]'; | ||
const model = await mock.openAndEnterChatRoom(_converse, muc_jid, 'romeo', ['muc_moderated']); | ||
const stanza = $pres({ | ||
to: '[email protected]/_converse.js-29092160', | ||
from: '[email protected]/newguy' | ||
}) | ||
.c('x', {xmlns: Strophe.NS.MUC_USER}) | ||
.c('item', { | ||
'affiliation': 'none', | ||
'jid': '[email protected]/_converse.js-290929789', | ||
'role': 'participant' | ||
}).tree(); | ||
const stanza = stx` | ||
<presence | ||
to="[email protected]/_converse.js-29092160" | ||
from="[email protected]/newguy" | ||
xmlns="jabber:client"> | ||
<x xmlns="${Strophe.NS.MUC_USER}"> | ||
<item affiliation="none" jid="[email protected]/_converse.js-290929789" role="participant"/> | ||
</x> | ||
</presence>`; | ||
_converse.api.connection.get()._dataRecv(mock.createRequest(stanza)); | ||
|
||
const view = _converse.chatboxviews.get(muc_jid); | ||
|
||
const msg_id = u.getUniqueId(); | ||
await model.handleMessageStanza($msg({ | ||
'from': '[email protected]/newguy', | ||
'to': _converse.api.connection.get().jid, | ||
'type': 'groupchat', | ||
'id': msg_id, | ||
}).c('body').t('But soft, what light through yonder airlock breaks?').tree()); | ||
await model.handleMessageStanza(stx` | ||
<message | ||
from="[email protected]/newguy" | ||
to="${_converse.api.connection.get().jid}" | ||
type="groupchat" | ||
id="${msg_id}" | ||
xmlns="jabber:client"> | ||
<body>But soft, what light through yonder airlock breaks?</body> | ||
</message>`); | ||
|
||
await u.waitUntil(() => view.querySelectorAll('.chat-msg').length === 1); | ||
// Quoting should be available before losing permission to speak | ||
expect(view.querySelector('.chat-msg__action-quote')).not.toBeNull(); | ||
|
||
const presence = $pres({ | ||
to: '[email protected]/orchard', | ||
from: `${muc_jid}/romeo` | ||
}).c('x', {xmlns: Strophe.NS.MUC_USER}) | ||
.c('item', {'affiliation': 'none', 'role': 'visitor'}).up() | ||
.c('status', {code: '110'}); | ||
const presence = stx` | ||
<presence | ||
to="[email protected]/orchard" | ||
from="${muc_jid}/romeo" | ||
xmlns="jabber:client"> | ||
<x xmlns="${Strophe.NS.MUC_USER}"> | ||
<item affiliation="none" role="visitor"/> | ||
</x> | ||
<status code="110"/> | ||
</presence>`; | ||
_converse.api.connection.get()._dataRecv(mock.createRequest(presence)); | ||
const occupant = view.model.occupants.findWhere({'jid': _converse.bare_jid}); | ||
await u.waitUntil(() => occupant.get('role') === 'visitor'); | ||
|
Oops, something went wrong.