package com.eddsteel.posts.leastpower
package endpoints

import model._
import services._
import webapp._

import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.concurrent.ScalaFutures

import scala.concurrent.{Future, ExecutionContext}
import java.time.{LocalDateTime, LocalDate}

class EndpointsV3Test extends FlatSpec with Matchers with ScalaFutures {
  import ExecutionContext.Implicits.global

  "maybeSendGift" should "order a gift for a user on their birthday" in {

    def successfulGiftOrder(id: Long, thing: String) =
      Future.successful((s"$thing ordered for user $id", Some(id)))

    val result =
      EndpointsV3.maybeSendGift(1, LocalDate.of(1980, 1, 1), "booze",
                                LocalDateTime.of(2016, 1, 1, 0, 0, 0, 0),
                                successfulGiftOrder)

    result.futureValue.shouldEqual(("booze ordered for user 1", Some(1)))

  }
}