|
Play Framework/Scala example source code file (EventSourceSpec.scala)
The EventSourceSpec.scala Play Framework example source codepackage play.api.libs import org.specs2.mutable.Specification object EventSourceSpec extends Specification { import EventSource.Event "EventSource event formatter" should { "format an event" in { Event("foo", None, None).formatted must equalTo ("data: foo\n\n") } "format an event with an id" in { Event("foo", Some("42"), None).formatted must equalTo ("id: 42\ndata: foo\n\n") } "format an event with a name" in { Event("foo", None, Some("message")).formatted must equalTo ("event: message\ndata: foo\n\n") } "split data by lines" in { Event("a\nb").formatted must equalTo ("data: a\ndata: b\n\n") } "support '\\r' as an end of line" in { Event("a\rb").formatted must equalTo ("data: a\ndata: b\n\n") } "support '\\r\\n' as an end of line" in { Event("a\r\nb").formatted must equalTo ("data: a\ndata: b\n\n") } } } Other Play Framework source code examplesHere is a short list of links related to this Play Framework EventSourceSpec.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.