--[[----------------------------------------------------------------------------

WFRxLoaderTest.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2014 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remain the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and may be covered by U.S. and Foreign
Patents, patents in process, and are protected by trade secret or copyright
law.  Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

--------------------------------------------------------------------------------

Note that RxLua has its own test suite that's pretty comprehensive.
The objective of this test suite is to verify that Rx loads correctly
inside the WF environment.

This particular test partially duplicates Rx's Observable_just_spec as a
sanity check on the loader.

------------------------------------------------------------------------------]]

local Rx = require 'Rx'

local Observable = Rx.Observable
local ReactiveTest = Rx.testing.ReactiveTest
local TestScheduler = Rx.testing.TestScheduler

local onNext = ReactiveTest.onNext
local onCompleted = ReactiveTest.onCompleted

local KSTableUtils = require 'KSTableUtils'


--============================================================================--

local WFRxLoaderTest = {}

----------------------------------------------------------------------------

function WFRxLoaderTest.testCreatesObservable()

	local scheduler = TestScheduler()

	local res = scheduler:startScheduler( function()
		return Observable.just( 42, scheduler )
	end )

	assert( KSTableUtils.deepEquals( res.messages, {
		onNext( 201, 42 ),
		onCompleted( 201 )
	} ) )

end

----------------------------------------------------------------------------

function WFRxLoaderTest.testCreatesObservableWithTuple()

	local scheduler = TestScheduler()

	local res = scheduler:startScheduler(function()
		return Observable.just( 42, "more", 57, scheduler )
	end)

	assert( KSTableUtils.deepEquals( res.messages, {
		onNext( 201, 42, "more", 57 ),
		onCompleted( 201 )
	} ) )

end

--------------------------------------------------------------------------------

return WFRxLoaderTest
