Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ gradleToolingApiVersion=9.6.0
greenmailVersion=2.1.2
javassistVersion=3.30.2-GA
jnrPosixVersion=3.1.20
joddWotVersion=3.3.8
joptSimpleVersion=5.0.4
jspApiVersion=4.0.0
openTest4jVersion=1.3.0
Expand Down
6 changes: 1 addition & 5 deletions grails-fields/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ dependencies {
testImplementation project(':grails-testing-support-datamapping')
testImplementation project(':grails-testing-support-web')
testImplementation "org.javassist:javassist:$javassistVersion"
testImplementation("org.jodd:jodd-wot:$joddWotVersion") {
exclude module: 'slf4j-api'
exclude module: 'asm'
}

testRuntimeOnly 'org.objenesis:objenesis' // Required by Spock for mocking classes without default constructor
}
Expand All @@ -66,4 +62,4 @@ apply {
from rootProject.layout.projectDirectory.file('gradle/docs-config.gradle')
from rootProject.layout.projectDirectory.file('gradle/test-config.gradle')
from rootProject.layout.projectDirectory.file('gradle/grails-extension-gradle-config.gradle')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
package grails.plugin.formfields

import grails.testing.web.taglib.TagLibUnitTest
import jodd.lagarto.dom.jerry.Jerry
import spock.lang.Specification
import static jodd.lagarto.dom.jerry.Jerry.jerry

class DefaultFieldTemplateSpec extends Specification implements TagLibUnitTest<FormFieldsTagLib> {
Map model = [:]

Map model = [:]

void setup() {
model.invalid = false
Expand All @@ -46,54 +44,42 @@ class DefaultFieldTemplateSpec extends Specification implements TagLibUnitTest<F
<%= widget %>
</div>'''
}

static Jerry $(String html) {
jerry(html).children()
}

void "default rendering"() {
when:
def output = tagLib.renderDefaultField(model)

then:
def root = $(output.toString())
root.is('div.fieldcontain')
void "default rendering"() {
when:
String output = tagLib.renderDefaultField(model).toString()

then:
output.contains('<div class="fieldcontain">')

and:
def label = root.find('label')
label.text() == 'label'
label.attr('for') == 'property'

and:
label.next().is('input[name=property]')
}
and:
output.contains('<label class="" for="property">label</label>')
output.indexOf('<label class="" for="property">label</label>') < output.indexOf('<input name="property">')
Comment thread
borinquenkid marked this conversation as resolved.
Outdated
}

void "container marked as invalid"() {
given:
model.invalid = true
void "container marked as invalid"() {
given:
model.invalid = true

when:
def output = tagLib.renderDefaultField(model)

then:
$(output.toString()).hasClass('error')
}
when:
String output = tagLib.renderDefaultField(model).toString()

void "container marked as required"() {
given:
model.required = true
then:
output.contains('<div class="fieldcontain error">')
Comment thread
borinquenkid marked this conversation as resolved.
Outdated
}

when:
def output = tagLib.renderDefaultField(model)
void "container marked as required"() {
given:
model.required = true

then:
def root = $(output.toString())
root.hasClass('required')
and:
def indicator = root.find('label .required-indicator')
indicator.size()
indicator.text() == '*'
}
when:
String output = tagLib.renderDefaultField(model).toString()

then:
output.contains('<div class="fieldcontain required">')

and:
output.contains('<span class="required-indicator">*</span>')
Comment thread
borinquenkid marked this conversation as resolved.
Outdated
}

}
Loading