UnitTests.icl 1.15 KB
Newer Older
1 2 3
module iTasks.WF.Tasks.Core.UnitTests
import iTasks.Util.Testing
import qualified Data.Map as DM
Steffen Michels's avatar
Steffen Michels committed
4
import Data.Either, Data.Maybe
5
import Text.GenPrint
6

7 8
derive gPrint TaskOutputMessage
derive gPrint UIChange, UIChildChange, UIAttributeChange, UI, UIType, Map, JSONNode
9

10
minimalInteractUI = skip (testTaskOutput "Initial UI of minimal interaction task" task events exp checkEqual)
11 12
where
	task :: Task ((),String)
13
	task = interactR unitShare handlers gEditor{|*|}
Steffen Michels's avatar
Steffen Michels committed
14
	handlers = {onInit = \() -> ((),Update "Hello world"), onEdit = \_ l -> (l,Nothing), onRefresh = \_ l v -> (l,fromJust v,Nothing)}
15 16 17 18

	events = [Left ResetEvent]
	exp = [TOUIChange (ReplaceUI expMinimalEditorUI)]

19
	expMinimalEditorUI = editor
20 21 22 23 24 25 26 27 28
	where
		editor = uia UITextField ('DM'.fromList
			[("hint-type",JSONString "valid")
			,("editorId",JSONString "v")
 			,("hint",JSONString "You have correctly entered a single line of text")
			,("optional",JSONBool False)
			,("mode",JSONString "update")
			,("taskId",JSONString "1-0")
			,("value",JSONString "Hello world")
29
			,("minlength",JSONInt 1)
30
			,("task-type",JSONString "interact")
31 32 33 34 35
			])

tests = [minimalInteractUI]

Start world = runUnitTests tests world