From cca228bcb232a2a7d9f7e0da393f9b5f05fa9d91 Mon Sep 17 00:00:00 2001 From: Dierk Koenig Date: Tue, 21 Nov 2023 22:12:08 +0100 Subject: [PATCH] before week 10 (JavaScript) --- .../groovy/rooms/CalculatorSpec.groovy | 1 + .../groovy/rooms/JSTempConverterSpec.groovy | 41 +++++++++++ src/main/resources/public/Temperatures.html | 69 +++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 src/integration-test/groovy/rooms/JSTempConverterSpec.groovy create mode 100644 src/main/resources/public/Temperatures.html diff --git a/src/integration-test/groovy/rooms/CalculatorSpec.groovy b/src/integration-test/groovy/rooms/CalculatorSpec.groovy index 44e37d9..04a4a61 100644 --- a/src/integration-test/groovy/rooms/CalculatorSpec.groovy +++ b/src/integration-test/groovy/rooms/CalculatorSpec.groovy @@ -7,6 +7,7 @@ import spock.lang.Ignore /** * See http://www.gebish.org/manual/current/ for more instructions */ +@Ignore @Integration class CalculatorSpec extends GebSpec { diff --git a/src/integration-test/groovy/rooms/JSTempConverterSpec.groovy b/src/integration-test/groovy/rooms/JSTempConverterSpec.groovy new file mode 100644 index 0000000..633e830 --- /dev/null +++ b/src/integration-test/groovy/rooms/JSTempConverterSpec.groovy @@ -0,0 +1,41 @@ +package rooms + +import geb.spock.GebSpec +import grails.testing.mixin.integration.Integration + +/** + * See http://www.gebish.org/manual/current/ for more instructions + */ +@Integration +class JSTempConverterSpec extends GebSpec { + + void "From celsius to fahrenheit with JavaScript"() { + when: + go '/static/Temperatures.html' + then: + title == "Temperature Converter with JavaScript" + + when: "set celsius without button clicking" + $("form").celsius = "10" + $("form").fahrenheit().click() + + then: "the other field is updated immediately" + $("form").fahrenheit == "50" + } + + void "From fahrenheit to celsius with JavaScript"() { + when: + go '/static/Temperatures.html' + then: + title == "Temperature Converter with JavaScript" + + when: "set fahrenheit without button clicking" + $("form").fahrenheit = "16" + $("form").celsius().click() + + then: "the other field is updated immediately" + $("form").celsius == "-9" + } + + +} diff --git a/src/main/resources/public/Temperatures.html b/src/main/resources/public/Temperatures.html new file mode 100644 index 0000000..22dec3b --- /dev/null +++ b/src/main/resources/public/Temperatures.html @@ -0,0 +1,69 @@ + + + + + + Temperature Converter with JavaScript + + + + + +
+

+ Temperature Converter with JavaScript +

+ +
+ + + + + + + +
+
+ +