Skip to content

Commit

Permalink
✅ [#4772] Add test for set_datatype_string converter
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Nov 11, 2024
1 parent 076c42b commit 5ca8dbf
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/openforms/formio/tests/test_set_datatype_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from django.test import SimpleTestCase, tag

from openforms.formio.typing import SelectComponent

from ..migration_converters import set_datatype_string


class SetDatatypeStringTests(SimpleTestCase):
@tag("gh-4772")
def test_set_datatype_string(self):
configuration: SelectComponent = {
"type": "select",
"key": "select",
"label": "Select",
"data": {
"values": [
{"label": "Option 1", "value": "1"},
{"label": "Option 2", "value": "2"},
]
},
}

set_datatype_string(configuration)

assert "dataType" in configuration
self.assertEqual(configuration["dataType"], "string")

configuration: SelectComponent = {
"type": "select",
"key": "select",
"label": "Select",
"dataType": "integer",
"data": {
"values": [
{"label": "Option 1", "value": "1"},
{"label": "Option 2", "value": "2"},
]
},
}

set_datatype_string(configuration)

assert "dataType" in configuration
self.assertEqual(configuration["dataType"], "string")

0 comments on commit 5ca8dbf

Please sign in to comment.