use super::*;
use bytes::Bytes;
#[test]
fn frames_round_trip_through_tungstenite() {
let cases = [
Frame::Text("{\"type\":\"response.create\"}".to_string()),
Frame::Binary(Bytes::from_static(b"\x00\x01")),
Frame::Ping(Bytes::from_static(b"ping")),
Frame::Pong(Bytes::new()),
Frame::Close(Some(CloseFrame {
code: 1000,
reason: "done".to_string(),
})),
Frame::Close(None),
];
for frame in cases {
assert_eq!(
from_message(into_message(frame.clone())),
Some(frame.clone()),
"frame should round-trip"
);
}
}
#[test]
fn a_raw_frame_carries_no_protocol_payload() {
let raw = Message::Frame(tungstenite::protocol::frame::Frame::message(
Bytes::from_static(b"raw"),
tungstenite::protocol::frame::coding::OpCode::Data(
tungstenite::protocol::frame::coding::Data::Binary,
),
true,
));
assert_eq!(from_message(raw), None);
}