<commit_before>package com.github.unisay.dancher

import com.github.unisay.dancher.Arbitraries._
import com.github.unisay.dancher.Equalities._
import fs2.{Strategy, Stream, Task}
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.scalatest.time._
import org.scalatest.{MustMatchers, PropSpec}

class BindingSpec extends PropSpec with GeneratorDrivenPropertyChecks with MustMatchers with ScalaFutures {

  implicit val defaultPatience = PatienceConfig(timeout = Span(1, Seconds), interval = Span(50, Millis))

  property("test merge") {
    forAll { (xs: List[Int], ys: List[Int]) =>
      implicit val strategy = Strategy.default
      val stream = Stream[Task, Int](xs: _*) merge Stream[Task, Int](ys: _*)
      stream.runLog.unsafeRunAsyncFuture().futureValue must not be empty
    }
  }

  property("element after append") {
    forAll { (parent: Binding, child: Binding) =>
      parent.append(child).element mustEqual parent.element
    }
  }

  property("deepElement after append") {
    forAll { (parent: Binding, child: Binding) =>
      parent.append(child).deepElement.unsafeRunAsyncFuture().futureValue mustEqual parent.element
    }
  }

  property("deepEvents after append") {
    forAll { (parent: Binding, child: Binding, widgetEvent: WidgetEvent) =>
      val testEvents = Stream[Task, WidgetEvent](widgetEvent)
      val childWithEvent = child.copy(events = testEvents)
      val deepEvents = parent.append(childWithEvent).deepEvents
      whenReady((testEvents).runLog.unsafeRunAsyncFuture()) { _ must contain(widgetEvent) }
    }
  }

  property("append") {
    forAll { (parent: Binding, child: Binding) => parent.append(child).nested must contain(child) }
  }

}<commit_msg>AsyncFlatSpec<commit_after>package com.github.unisay.dancher

import com.github.unisay.dancher.Arbitraries._
import com.github.unisay.dancher.Equalities._
import fs2.{Stream, Task}
import org.scalacheck.Arbitrary
import org.scalatest.{AsyncFlatSpec, MustMatchers}

class BindingSpec extends AsyncFlatSpec with MustMatchers {

  implicit override def executionContext = scala.scalajs.concurrent.JSExecutionContext.Implicits.queue

  val arbitrary = Arbitrary.arbitrary[Binding]
  val widgetEvent = Arbitrary.arbitrary[WidgetEvent].sample.get
  val parent = arbitrary.sample.get
  val child = arbitrary.sample.get

  "Append" must "return parent element" in {
    parent.append(child).element mustEqual parent.element
  }

  it must "return deepElement" in {
    parent.append(child).deepElement.unsafeRunAsyncFuture() map { _ mustEqual parent.element }
  }

  it must "return deepEvents" in {
    val testEvents = Stream[Task, WidgetEvent](widgetEvent)
    val childWithEvent = child.copy(events = testEvents)
    val deepEvents = parent.append(childWithEvent).deepEvents
    deepEvents.runLog.unsafeRunAsyncFuture() map { _ must contain(widgetEvent) }
  }

  it must "append" in {
    parent.append(child).nested must contain(child)
  }

}
{'fraction_non_alphanumeric': 0.10484140233722872, 'fraction_numerical': 0.001669449081803005, 'mean_word_length': 4.58955223880597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4821259', 'n_tokens_mistral': 924, 'n_tokens_neox': 902, 'n_words': 198}