Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('End to end', done => {
expect.assertions(2);
const client1 = stanza.createClient({
jid: 'anon@anon.stanzajs.org'
});
const client2 = stanza.createClient({
jid: 'anon@anon.stanzajs.org'
});
client1.on('session:started', async () => {
const roster = await client1.getRoster();
expect(roster.items).toStrictEqual([]);
client1.sendPresence();
client2.on('session:started', async () => {
await client2.getRoster();
client2.sendPresence();
test('Connect using BOSH', done => {
expect.assertions(1);
const client = stanza.createClient({
jid: 'anon@anon.stanzajs.org',
transports: {
bosh: 'https://anon.stanzajs.org/http-bind'
}
});
client.on('session:started', () => {
client.disconnect();
expect(true).toBe(true);
done();
});
client.connect();
});
test('Test session-initiate with no contents fails', done => {
expect.assertions(1);
const jingle = new SessionManager({
selfID
});
jingle.on('send', data => {
expect(data).toEqual({
error: {
condition: 'bad-request',
type: 'cancel'
},
id: '123',
to: peerID,
type: 'error'
});
done();
test('Return error for unknown transport-info action', done => {
expect.assertions(1);
const jingle = new SessionManager({
selfID
});
const sess = new GenericSession({
parent: jingle,
peerID,
sid: 'sid123'
});
jingle.addSession(sess);
sess.state = 'active';
jingle.on('send', data => {
expect(data).toEqual({
error: {
test('[Streams] Wrapped streams', done => {
expect.assertions(4);
const registry = setupRegistry();
const parser = new StreamParser({
registry,
rootKey: 'stream',
wrappedStream: true
});
parser.on('data', (data: ParsedData) => {
if (data.event === 'stream-start') {
expect(data.kind).toBe('stream');
}
if (data.event === 'stream-end') {
expect(data.kind).toBe('stream');
}
if (!data.event) {
test('Test ending sessions for peer', done => {
expect.assertions(2);
const jingle = new SessionManager({
selfID
});
const sess = new GenericSession({
parent: jingle,
peerID,
sid: 'sid123'
});
jingle.addSession(sess);
const sess2 = new GenericSession({
parent: jingle,
peerID,
sid: 'sid124'
test('Prepare session', () => {
expect.assertions(1);
const jingle = new SessionManager({
prepareSession: meta => {
expect(meta).toBeTruthy();
return new GenericSession(meta);
},
selfID
});
jingle.process({
from: peerID,
id: '123',
jingle: {
action: 'session-initiate',
contents: [
{
test('Test cancelling a pending session', done => {
expect.assertions(2);
const jingle = new SessionManager({
selfID
});
const sess = new StubSession({
initiator: true,
peerID
});
let started = false;
jingle.on('send', data => {
delete data.id;
if (!started) {
expect(data).toEqual({
jingle: {
it('should take only last change in case of a burst of changes (case of inputs being currently edited)', () => {
expect.assertions(2);
const props = {
...defaultProps,
children: fakeComponent,
};
const { getByLabelText, dispatch, reduxStore } = renderWithRedux(
,
{
admin: {
resources: { posts: { list: { params: {} } } },
},
}
);
const searchInput = getByLabelText('search');
it('supports declarative onSuccess side effects', async () => {
expect.assertions(4);
let dispatchSpy;
const dataProvider = jest.fn();
dataProvider.mockImplementationOnce(() =>
Promise.resolve({ data: [{ id: 1, foo: 'bar' }], total: 42 })
);
let getByTestId;
act(() => {
const res = render(
{({ store }) => {
dispatchSpy = jest.spyOn(store, 'dispatch');
return (