suite "Errors & Warnings", ()->
	suiteSetup(restartSandbox)

	test "Warning when binding a property of a jQuery object containing multiple els", ()-> if not isBrowser then @skip() else
		window.origLog = console.warn
		console.warn = chai.spy()
		
		SimplyBind('value').of $('input')
		expect(console.warn).to.have.been.called()

		console.warn = origLog


	test "Warning when binding a property of a jQuery/NodeList/HTMLCollection object containing zero els", ()-> if not isBrowser then @skip() else
		expect ()-> SimplyBind('value').of $('nonexistent')
			.to.throw()
		
		expect ()-> SimplyBind('value').of document.querySelectorAll('nonexistent')
			.to.throw()
		
		expect ()-> SimplyBind('value').of document.getElementsByTagName('nonexistent')
			.to.throw()


	test "Warning when binding a property of a jQuery object containing zero els", ()-> if not isBrowser then @skip() else
		expect ()-> SimplyBind('value').of $('input[type="nonexistent"]')
			.to.throw()


	test "Warning when binding a property of a NodeList/HTMLCollection containing multiple els", ()-> if not isBrowser then @skip() else
		origLog = console.warn
		console.warn = chai.spy()
		
		SimplyBind('value').of document.querySelectorAll('input')
		expect(console.warn).to.have.been.called()
		
		console.warn = origLog

	
	test "No Warning when binding 'checked' of a jQuery object containing multiple radio/checkbox inputs", ()-> if not isBrowser then @skip() else
		origLog = console.warn
		console.warn = chai.spy()
		
		SimplyBind('checked').of $radioFields
		expect(console.warn).not.to.have.been.called()
		
		SimplyBind('value').of $radioFields
		expect(console.warn).to.have.been.called.exactly(1)

		console.warn = origLog

	
	test "No Warning when binding 'checked' of a NodeList/HTMLCollection/Array containing multiple radio/checkbox inputs", ()-> if not isBrowser then @skip() else
		origLog = console.warn
		console.warn = chai.spy()
		
		SimplyBind('checked').of $radioFields.toArray()
		expect(console.warn).not.to.have.been.called()
		
		SimplyBind('checked').of radioFields
		expect(console.warn).not.to.have.been.called()
		
		SimplyBind('value').of $radioFields.toArray()
		SimplyBind('value').of radioFields
		expect(console.warn).to.have.been.called.exactly(2)

		console.warn = origLog

	
	test "Warning when binding a property of a NodeList/HTMLCollection/Array/jQuery containing elements with mixed types", ()-> if not isBrowser then @skip() else
		origLog = console.warn
		console.warn = chai.spy()
		
		SimplyBind('checked').of $radioFields.add($checkboxFields).toArray()
		expect(console.warn).to.have.been.called.exactly(1)
		
		SimplyBind('checked').of $radioFields.add($checkboxFields)
		expect(console.warn).to.have.been.called.exactly(2)
		
		SimplyBind('checked').of document.querySelectorAll 'input'
		expect(console.warn).to.have.been.called.exactly(3)
		
		console.warn = origLog


	test "Warning when creating a binding and passing a non-function object to .transform/.condition/All", ()->
		binding = SimplyBind('prop1').of(objectA).to('prop1').of(objectB)
		origLog = console.warn
		console.warn = chai.spy()
		timesCalled = 0
	
		binding.transform []
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		binding.transformAll []
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		binding.transform {}
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		binding.transform new Date()
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		if isBrowser
			binding.transform $('<div />')[0]
			expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		if window.Map and window.Set and window.Symbol
			binding.transform new Map()
			expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
		
			binding.transform new WeakMap()
			expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
		
			binding.transform new Set()
			expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
		
			binding.transform new WeakSet()
			expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
			binding.transform Symbol(0)
			expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		binding.transform 's'
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		binding.transform 0
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		binding.transform true
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		binding.transform null
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		binding.transform undefined
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)

		binding.condition []
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
		binding.conditionAll []
		expect(console.warn).to.have.been.called.exactly(timesCalled += 1)
	
	
		console.warn = origLog
		restartSandbox()


	test "Warning when passed a non-number argument selector to an event binding", ()->
		origLog = console.warn
		console.warn = chai.spy()
		
		SimplyBind('event:someEvent#value')
		SimplyBind('event:someEvent#15')
		SimplyBind('event:someEvent#1aos95')
		
		expect(console.warn).to.have.been.called.exactly(1)
		console.warn = origLog
		


	test "No warnings should be thrown when SimplyBind.options.silent is on", ()->
		SimplyBind.settings.silent = true
		
		origLog = console.warn
		console.warn = chai.spy()
		
		SimplyBind('event:someEvent#value')
		SimplyBind('prop3').of(objectA).to('prop3').of(objectB).transform []
		
		expect(console.warn).not.to.have.been.called()
		
		console.warn = origLog
		SimplyBind.settings.silent = false


	test "Errors should still be thrown when SimplyBind.options.silent is on", ()->
		SimplyBind.settings.silent = true
		
		expect ()-> SimplyBind ''
			.to.throw()

		SimplyBind.settings.silent = false


	test "No errors should be thrown when scanning for placeholders on a non-string object", ()->
		dispatcher = 'prop':'value'
		receiver = 'prop':null
		expect(()->
			SimplyBind('prop').of(dispatcher)
				.to('prop.placeholder').of(receiver)
		).not.to.throw()

		expect(receiver.prop).not.to.equal('value')

