diff --git a/app/webpack/javascripts/modules/determination.js b/app/webpack/javascripts/modules/determination.mjs
similarity index 100%
rename from app/webpack/javascripts/modules/determination.js
rename to app/webpack/javascripts/modules/determination.mjs
diff --git a/app/webpack/javascripts/modules/determination_spec.mjs b/app/webpack/javascripts/modules/determination_spec.mjs
new file mode 100644
index 0000000000..9df444dfb9
--- /dev/null
+++ b/app/webpack/javascripts/modules/determination_spec.mjs
@@ -0,0 +1,54 @@
+import { Determination } from './determination.mjs'
+
+describe('Determination', () => {
+ let determination = null
+
+ beforeEach(() => {
+ document.body.classList.add("govuk-frontend-supported")
+ document.body.append(`
+
+ `)
+
+ const elements = window.document.querySelectorAll('[data-module="govuk-determination"]')
+ determination = new Determination(elements[0])
+ determination.init()
+ })
+
+ describe('parsedValue', () => {
+ it('should parse a positive integer', () => {
+ const field = document.createElement('input')
+ field.value = '100'
+
+ expect(determination.parsedValue(field)).toEqual(100.0)
+ })
+
+ it('should parse a positive float', () => {
+ const field = document.createElement('input')
+ field.value = '99.99'
+
+ expect(determination.parsedValue(field)).toEqual(99.99)
+ })
+
+ it('should return zero for a negative integer', () => {
+ const field = document.createElement('input')
+ field.value = '-100'
+
+ expect(determination.parsedValue(field)).toEqual(0.0)
+ })
+
+ it('should return zero for a negative float', () => {
+ const field = document.createElement('input')
+ field.value = '-99.99'
+
+ expect(determination.parsedValue(field)).toEqual(0.0)
+ })
+
+ it('should return zero for a value that cannot be parsed', () => {
+ const field = document.createElement('input')
+ field.value = 'test'
+
+ expect(determination.parsedValue(field)).toEqual(0.0)
+ })
+ })
+})
diff --git a/app/webpack/packs/govuk-frontend.js b/app/webpack/packs/govuk-frontend.js
index 0ba7b9a2b5..31edeaf33e 100644
--- a/app/webpack/packs/govuk-frontend.js
+++ b/app/webpack/packs/govuk-frontend.js
@@ -1,6 +1,6 @@
import '../stylesheets/govuk-frontend.scss'
-import { Determination } from '../javascripts/modules/determination.js'
+import { Determination } from '../javascripts/modules/determination.mjs'
// fonts & images
require.context('govuk-frontend/govuk/assets', true)
diff --git a/spec/support/jasmine-browser.json b/spec/support/jasmine-browser.json
index 827f170c8f..34f9b07446 100644
--- a/spec/support/jasmine-browser.json
+++ b/spec/support/jasmine-browser.json
@@ -3,12 +3,13 @@
"srcFiles": [
"app/assets/builds/*.js"
],
- "specDir": "spec/javascripts",
+ "specDir": "./",
"specFiles": [
- "**/*[sS]pec.?(m)js"
+ "app/webpack/javascripts/modules/**/*[sS]pec.?(m)js",
+ "spec/javascripts/**/*[sS]pec.?(m)js"
],
"helpers": [
- "helpers/**/*.?(m)js"
+ "spec/javascripts/helpers/**/*.?(m)js"
],
"env": {
"stopSpecOnExpectationFailure": false,