# Path: sockjs/transports/jsonp.py
# class JSONPolling(StreamingTransport):
#     async def send(self, text):
#     async def process(self):


from unittest import mock
from aiohttp import web
from aiohttp.test_utils import make_mocked_coro
from sockjs.transports import jsonp
import pytest

    return maker


async def test_streaming_send(make_transport):
    trans = make_transport()
    trans.callback = "cb"

    resp = trans.response = mock.Mock()
    resp.write = make_mocked_coro(None)
    stop = await trans.send("text data")
    resp.write.assert_called_with(b'/**/cb("text data");\r\n')
    assert stop


async def test_process(make_transport, make_fut):
    transp = make_transport(query_params={"c": "calback"})
    transp.handle_session = make_fut(1)
    resp = await transp.process()
    assert transp.handle_session.called
    assert resp.status == 200


async def test_process_no_callback(make_transport, make_fut):
    transp = make_transport()
    transp.session = mock.Mock()
    transp.session._remote_closed = make_fut(1)

    resp = await transp.process()
    assert transp.session._remote_closed.called

# Path: sockjs/transports/jsonp.py
# class JSONPolling(StreamingTransport):
#     async def send(self, text):
#     async def process(self):


# Path: tests/test_transport_jsonp.py
from unittest import mock
from aiohttp import web
from aiohttp.test_utils import make_mocked_coro
from sockjs.transports import jsonp
import pytest


    return maker


async def test_streaming_send(make_transport):
    trans = make_transport()
    trans.callback = "cb"

    resp = trans.response = mock.Mock()
    resp.write = make_mocked_coro(None)
    stop = await trans.send("text data")
    resp.write.assert_called_with(b'/**/cb("text data");\r\n')
    assert stop


async def test_process(make_transport, make_fut):
    transp = make_transport(query_params={"c": "calback"})
    transp.handle_session = make_fut(1)
    resp = await transp.process()
    assert transp.handle_session.called
    assert resp.status == 200


async def test_process_no_callback(make_transport, make_fut):
    transp = make_transport()
    transp.session = mock.Mock()
    transp.session._remote_closed = make_fut(1)

    resp = await transp.process()
    assert transp.session._remote_closed.called

    assert resp.status == 500