Skip to content

Commit

Permalink
Added ui classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mtabacman committed Oct 24, 2024
1 parent 09510ac commit 0b0c912
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 183 deletions.
22 changes: 12 additions & 10 deletions source/Willow-JQueryUI-Tests/JQueryUIButtonSetWebViewTest.class.st
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
Class {
#name : #JQueryUIButtonSetWebViewTest,
#superclass : #BWRenderingTest,
#category : #'Willow-JQueryUI-Tests-WebViews'
#name : 'JQueryUIButtonSetWebViewTest',
#superclass : 'BWRenderingTest',
#category : 'Willow-JQueryUI-Tests-WebViews',
#package : 'Willow-JQueryUI-Tests',
#tag : 'WebViews'
}

{ #category : #tests }
{ #category : 'tests' }
JQueryUIButtonSetWebViewTest >> testOn [

| buttonSet html |

buttonSet := JQueryUIButtonSetWebView applying: [ ] obtainingCommandFrom: [ :each | [ ] ].
buttonSet allowAnyOf: #(one two).
buttonSet allowAnyOf: #( one two ).
buttonSet on trigger inform: 'Triggered'.

html := self renderUsing: [ :canvas | canvas render: buttonSet ].

self
assert: html
equals:
'<div id="id1"><input id="radio-button-id3" name="2" value="1" type="radio"/><label for="radio-button-id3"></label><input id="radio-button-id4" name="2" value="2" type="radio"/><label for="radio-button-id4"></label></div><script type="text/javascript">$("#id1").buttonset();$("#radio-button-id3").change(function(event){alert("Triggered")});$("#radio-button-id4").change(function(event){alert("Triggered")});</script>'
'<div id="id1"><input id="radio-button-id3" name="2" value="1" type="radio"/><label for="radio-button-id3"></label><input id="radio-button-id4" name="2" value="2" type="radio"/><label for="radio-button-id4"></label></div><script type="text/javascript">$("#id1").buttonset();$("#radio-button-id3").change(function(event){alert("Triggered")});$("#radio-button-id4").change(function(event){alert("Triggered")});</script>'
]

{ #category : #tests }
{ #category : 'tests' }
JQueryUIButtonSetWebViewTest >> testRenderContentOn [

| buttonSet html |

buttonSet := JQueryUIButtonSetWebView
applying: [ :view | view addClass willow ]
obtainingCommandFrom: [ :each | [ :optionLabel | optionLabel setTitleTo: each ] ].
buttonSet allowAnyOf: #(one two).
applying: [ :view | view addClass willow ]
obtainingCommandFrom: [ :each | [ :optionLabel | optionLabel setTitleTo: each ] ].
buttonSet allowAnyOf: #( one two ).

html := self renderUsing: [ :canvas | canvas render: buttonSet ].

Expand Down
187 changes: 103 additions & 84 deletions source/Willow-JQueryUI-Tests/JQueryUIComponentSupplierTest.class.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Class {
#name : #JQueryUIComponentSupplierTest,
#superclass : #BWRenderingTest,
#category : #'Willow-JQueryUI-Tests-Frontend'
#name : 'JQueryUIComponentSupplierTest',
#superclass : 'BWRenderingTest',
#category : 'Willow-JQueryUI-Tests-Frontend',
#package : 'Willow-JQueryUI-Tests',
#tag : 'Frontend'
}

{ #category : #private }
{ #category : 'private' }
JQueryUIComponentSupplierTest >> assertRenderingOf: aComponentCreationBlock equals: anExpectedHtml [

| component html |
Expand All @@ -16,172 +18,186 @@ JQueryUIComponentSupplierTest >> assertRenderingOf: aComponentCreationBlock equa
self assert: html equals: anExpectedHtml
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testAsynchronicButtonLabeledApplying [

self
assertRenderingOf:
[ :supplier | supplier asynchronicButtonLabeled: 'Buy' applying: [ :button | button addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier asynchronicButtonLabeled: 'Buy' applying: [ :button | button addClass willow ] ]
equals: '<button class="willow" type="button">Buy</button>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testAsynchronicLinkLabeledApplying [

self
assertRenderingOf:
[ :supplier | supplier asynchronicLinkLabeled: 'Buy' applying: [ :link | link addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier asynchronicLinkLabeled: 'Buy' applying: [ :link | link addClass willow ] ]
equals:
'<a id="a-id1" class="willow">Buy</a><script type="text/javascript">$("#a-id1").click(function(event){arguments[0].preventDefault()});</script>'
'<a id="a-id1" class="willow">Buy</a><script type="text/javascript">$("#a-id1").click(function(event){arguments[0].preventDefault()});</script>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testCheckboxLabeledOnModelOffModelApplying [

self
assertRenderingOf: [ :supplier |
supplier
checkboxLabeled: 'Labelization'
onModel: 3
offModel: 'the off'
applying: [ :checkbox | checkbox addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier
checkboxLabeled: 'Labelization'
onModel: 3
offModel: 'the off'
applying: [ :checkbox | checkbox addClass willow ]
]
equals:
'<input class="willow" checked name="1" id="checkbox-id2" type="checkbox"/><input name="3" type="hidden"/><label for="checkbox-id2">Labelization</label>'
'<input class="willow" checked name="1" id="checkbox-id2" type="checkbox"/><input name="3" type="hidden"/><label for="checkbox-id2">Labelization</label>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testCheckboxUnlabeledOnModelOffModelApplying [

self
assertRenderingOf: [ :supplier |
supplier
checkboxUnlabeledOnModel: 3
offModel: 'the off'
applying: [ :checkbox | checkbox addClass willow ] ]
equals:
'<input class="willow" checked name="1" type="checkbox"/><input name="2" type="hidden"/>'
assertRenderingOf: [ :supplier |
supplier
checkboxUnlabeledOnModel: 3
offModel: 'the off'
applying: [ :checkbox | checkbox addClass willow ]
]
equals: '<input class="willow" checked name="1" type="checkbox"/><input name="2" type="hidden"/>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testDecimalNumberFieldApplying [

self
assertRenderingOf: [ :supplier | supplier decimalNumberFieldApplying: [ :field | field addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier decimalNumberFieldApplying: [ :field | field addClass willow ] ]
equals: '<input value="" name="1" type="number" class="willow"/>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testDropdownListApplying [

self
assertRenderingOf:
[ :supplier | supplier dropdownListApplying: [ :dropdownList | dropdownList addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier dropdownListApplying: [ :dropdownList | dropdownList addClass willow ] ]
equals: '<select name="1" class="willow"></select>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testFieldSetContainingApplyingWithLegendApplying [

self
assertRenderingOf: [ :supplier |
supplier
fieldSetContaining: 'The View'
applying: [ :fieldSet | fieldSet beDisabled ]
withLegend: 'Its Title'
applying: [ :legend | legend beAutofocused ] ]
equals:
'<fieldset disabled><legend autofocus>Its Title</legend>The View</fieldset>'
assertRenderingOf: [ :supplier |
supplier
fieldSetContaining: 'The View'
applying: [ :fieldSet | fieldSet beDisabled ]
withLegend: 'Its Title'
applying: [ :legend | legend beAutofocused ]
]
equals: '<fieldset disabled><legend autofocus>Its Title</legend>The View</fieldset>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testMultiLineTextFieldApplying [

self
assertRenderingOf:
[ :supplier | supplier multiLineTextFieldApplying: [ :textField | textField addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier multiLineTextFieldApplying: [ :textField | textField addClass willow ] ]
equals: '<textarea rows="auto" cols="auto" name="1" class="willow"></textarea>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testMultipleSelectionListBoxDisplayingAtOnceApplying [

self
assertRenderingOf:
[ :supplier | supplier multipleSelectionListBoxDisplayingAtOnce: 10 applying: [ :listBox | ] ]
assertRenderingOf: [ :supplier |
supplier multipleSelectionListBoxDisplayingAtOnce: 10 applying: [ :listBox | ] ]
equals: '<select name="1" size="10" multiple></select><input name="2" type="hidden"/>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testNaturalNumberFieldApplying [

self
assertRenderingOf: [ :supplier | supplier naturalNumberFieldApplying: [ :field | field addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier naturalNumberFieldApplying: [ :field | field addClass willow ] ]
equals: '<input value="" name="1" type="number" min="0" class="willow"/>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testRadioRenderingWithApplyingToLabelApplyingToInput [

self
assertRenderingOf:
[ :supplier | supplier radioRenderingWith: #asUppercase applyingToLabel: [ :radio | radio addClass willow ] applyingToInput: [ :radio | radio addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier
radioRenderingWith: #asUppercase
applyingToLabel: [ :radio | radio addClass willow ]
applyingToInput: [ :radio | radio addClass willow ]
]
equals: ''.

self
assertRenderingOf: [ :supplier |
(supplier radioRenderingWith: #asUppercase applyingToLabel: [ :radio | radio addClass willow ] applyingToInput: [ :radio | radio addClass willow ])
allowAnyOf: #(f h);
yourself ]
assertRenderingOf: [ :supplier |
( supplier
radioRenderingWith: #asUppercase
applyingToLabel: [ :radio | radio addClass willow ]
applyingToInput: [ :radio | radio addClass willow ] )
allowAnyOf: #( f h );
yourself
]
equals:
'<label for="radio-button-id2" class="willow"><input name="1" id="radio-button-id2" class="willow" value="1" type="radio"/>F</label><label for="radio-button-id3" class="willow"><input name="1" id="radio-button-id3" class="willow" value="2" type="radio"/>H</label>'
'<label for="radio-button-id2" class="willow"><input name="1" id="radio-button-id2" class="willow" value="1" type="radio"/>F</label><label for="radio-button-id3" class="willow"><input name="1" id="radio-button-id3" class="willow" value="2" type="radio"/>H</label>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testSingleLineTextFieldApplying [

self
assertRenderingOf:
[ :supplier | supplier singleLineTextFieldApplying: [ :textField | textField addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier singleLineTextFieldApplying: [ :textField | textField addClass willow ] ]
equals: '<input value="" name="1" class="willow" type="text"/>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testSingleSelectionListBoxDisplayingAtOnceApplying [

self
assertRenderingOf: [ :supplier |
supplier
singleSelectionListBoxDisplayingAtOnce: 15
applying: [ :listBox | listBox addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier
singleSelectionListBoxDisplayingAtOnce: 15
applying: [ :listBox | listBox addClass willow ] ]
equals: '<select name="1" size="15" class="willow"></select>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testSynchronicButtonLabeledApplyingEvaluating [

self
assertRenderingOf: [ :supplier |
supplier
synchronicButtonLabeled: 'Buy'
applying: [ :button | button addClass willow ]
evaluating: [ ] ]
assertRenderingOf: [ :supplier |
supplier
synchronicButtonLabeled: 'Buy'
applying: [ :button | button addClass willow ]
evaluating: [ ]
]
equals: '<button name="1" class="willow" type="submit">Buy</button>'
]

{ #category : #'tests-Supplying' }
{ #category : 'tests-Supplying' }
JQueryUIComponentSupplierTest >> testUnorderedListApplyingListingApplyingToEach [

self
assertRenderingOf: [ :supplier |
supplier
unorderedListApplying: [ :list | list labelItemsWith: [ :item | 'N.<1p>' expandMacrosWith: item ] ]
listing: #(1 2 3)
applyingToEach: [ :listItem | listItem addClass willow ] ]
assertRenderingOf: [ :supplier |
supplier
unorderedListApplying: [ :list |
list labelItemsWith: [ :item | 'N.<1p>' expandMacrosWith: item ] ]
listing: #( 1 2 3 )
applyingToEach: [ :listItem | listItem addClass willow ]
]
equals:
'<ul><li class="willow">N.1</li><li class="willow">N.2</li><li class="willow">N.3</li></ul>'
'<ul><li class="willow">N.1</li><li class="willow">N.2</li><li class="willow">N.3</li></ul>'
]

{ #category : #'tests-Processing' }
{ #category : 'tests-Processing' }
JQueryUIComponentSupplierTest >> testUpdateRoot [

| html |
Expand All @@ -197,18 +213,21 @@ JQueryUIComponentSupplierTest >> testUpdateRoot [
'<!DOCTYPE html><html><head><title></title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><script type="text/javascript" src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script><link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.13.2/themes/pepper-grinder/jquery-ui.css"/></head><body onload="onLoad()"><script type="text/javascript">function onLoad(){};</script></body></html>'
]

{ #category : #'tests-Processing' }
{ #category : 'tests-Processing' }
JQueryUIComponentSupplierTest >> testUpdateRootWithSelfHostedLibraries [

| html |

html := WAHtmlCanvas builder
fullDocument: true;
rootBlock: [ :root | (JQueryUIComponentSupplier withJQueryUILibrary: JQueryUIDevelopmentMetadataLibrary default) updateRoot: root ];
render: [ :canvas | ].
fullDocument: true;
rootBlock: [ :root |
( JQueryUIComponentSupplier withJQueryUILibrary:
JQueryUIDevelopmentMetadataLibrary default ) updateRoot: root
];
render: [ :canvas | ].

self
assert: html
equals:
'<!DOCTYPE html><html><head><title></title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link rel="stylesheet" type="text/css" href="/files/jquery-ui-1.13.2/themes/pepper-grinder/theme.css"/><link rel="stylesheet" type="text/css" href="/files/jquery-ui-1.13.2/themes/pepper-grinder/jquery-ui.css"/><script type="text/javascript" src="/files/jquery-ui-1.13.2/jquery-ui.js"></script></head><body onload="onLoad()"><script type="text/javascript">function onLoad(){};</script></body></html>'
'<!DOCTYPE html><html><head><title></title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link rel="stylesheet" type="text/css" href="/files/jquery-ui-1.13.2/themes/pepper-grinder/theme.css"/><link rel="stylesheet" type="text/css" href="/files/jquery-ui-1.13.2/themes/pepper-grinder/jquery-ui.css"/><script type="text/javascript" src="/files/jquery-ui-1.13.2/jquery-ui.js"></script></head><body onload="onLoad()"><script type="text/javascript">function onLoad(){};</script></body></html>'
]
Loading

0 comments on commit 0b0c912

Please sign in to comment.