/
TemporarilyDisablingCommandTest.class.st
70 lines (54 loc) · 2.53 KB
/
TemporarilyDisablingCommandTest.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"
A TemporarilyDisablingCommandTest is a test class for testing the behavior of TemporarilyDisablingCommand
"
Class {
#name : #TemporarilyDisablingCommandTest,
#superclass : #WARenderingTest,
#category : 'Willow-Tests-WebInteraction'
}
{ #category : #'tests-accessing' }
TemporarilyDisablingCommandTest >> testClientIndependentActions [
self assert: (TemporarilyDisablingCommand transformingCurrentViewInto: [ :canvas | ]) clientIndependentActions isEmpty
]
{ #category : #'tests-accessing' }
TemporarilyDisablingCommandTest >> testModelLoadingActions [
self assert: (TemporarilyDisablingCommand transformingCurrentViewInto: [ :canvas | ]) modelLoadingActions isEmpty
]
{ #category : #'tests-accessing' }
TemporarilyDisablingCommandTest >> testPriorityActions [
| command html |
command := TemporarilyDisablingCommand transformingCurrentViewInto: [ :canvas | canvas span apply: [ :span | span addClass loading ] ].
html := self
renderUsing: [ :canvas |
| asynchronousCall anchor |
asynchronousCall := canvas jQuery ajax.
command priorityActions do: [ :action | action value: asynchronousCall value: canvas ].
anchor := canvas anchor.
canvas ensureIdFor: anchor.
anchor script: (canvas jQuery this onClick: asynchronousCall) ].
self
assert: html
equals:
'<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){$.ajax({"complete":function(){$(".willow-disabled-component").attr("disabled",false).removeClass("willow-disabled-component").html(disabledComponent)}})});</script>'
]
{ #category : #'tests-testing' }
TemporarilyDisablingCommandTest >> testRequiresSerialization [
self deny: (TemporarilyDisablingCommand transformingCurrentViewInto: [ :canvas | ]) requiresSerialization
]
{ #category : #'tests-accessing' }
TemporarilyDisablingCommandTest >> testServerIndependentActions [
| command html |
command := TemporarilyDisablingCommand transformingCurrentViewInto: [ :canvas | canvas span apply: [ :span | span addClass loading ] ].
html := self
renderUsing: [ :canvas |
| script anchor |
script := canvas javascript.
command serverIndependentActions do: [ :action | action value: script value: canvas ].
anchor := canvas anchor.
canvas ensureIdFor: anchor.
anchor script: (canvas jQuery this onClick: script) ].
self
assert: html
equals:
'<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){disabledComponent=$(this).html();$(this).addClass("willow-disabled-component").attr("disabled",true).html("<span class=\"willow-loading\"></span>")});</script>'
]