# Path: sockjs/transports/htmlfile.py
# PRELUDE1 = b"""
# <!doctype html>
# <html><head>
#   <meta http-equiv="X-UA-Compatible" content="IE=edge" />
#   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
# </head><body><h2>Don't panic!</h2>
#   <script>
#     document.domain = document.domain;
#     var c = parent."""
# PRELUDE2 = b""";
#     c.start();
#     function p(d) {c.message(d);};
#     window.onload = function() {c.stop();};
#   </script>"""
# class HTMLFileTransport(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 htmlfile
import pytest
    resp = trans.response = mock.Mock()
    resp.write = make_mocked_coro(None)
    stop = await trans.send("text data")
    resp.write.assert_called_with(b'<script>\np("text data");\n</script>\r\n')
    assert not stop
    assert trans.size == len(b'<script>\np("text data");\n</script>\r\n')

    trans.maxsize = 1
    stop = trans.send("text data")
    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



# Path: sockjs/transports/htmlfile.py
# PRELUDE1 = b"""
# <!doctype html>
# <html><head>
#   <meta http-equiv="X-UA-Compatible" content="IE=edge" />
#   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
# </head><body><h2>Don't panic!</h2>
#   <script>
#     document.domain = document.domain;
#     var c = parent."""
# PRELUDE2 = b""";
#     c.start();
#     function p(d) {c.message(d);};
#     window.onload = function() {c.stop();};
#   </script>"""
# class HTMLFileTransport(StreamingTransport):
#     async def send(self, text):
#     async def process(self):


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

    resp = trans.response = mock.Mock()
    resp.write = make_mocked_coro(None)
    stop = await trans.send("text data")
    resp.write.assert_called_with(b'<script>\np("text data");\n</script>\r\n')
    assert not stop
    assert trans.size == len(b'<script>\np("text data");\n</script>\r\n')

    trans.maxsize = 1
    stop = trans.send("text data")
    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



async def test_process_bad_callback(make_transport, make_fut):