function runFromJsonSuiteTests(
  TestedField,
  validValueTestCases,
  invalidValueTestCases,
  validRunAssertField,
  assertFieldDefault,
  customCreateWithJson,
) {
  suite('fromJson', function () {
    if (assertFieldDefault) {
      test('Empty', function () {
        const field = customCreateWithJson
          ? customCreateWithJson.call(this)
          : TestedField.fromJson({});
        assertFieldDefault(field);
      });
    } else {
      test('Empty', function () {
        assert.throws(function () {
          customCreateWithJson
            ? customCreateWithJson.call(this)
            : TestedField.fromJson({});
        });
      });
    }

    /**
     * Creates a field using fromJson and the provided test case.
     * @param {!FieldCreationTestCase} testCase The test case information.
     * @returns {!Blockly.Field} The instantiated field.
     */
    const createWithJson = function (testCase) {
      return customCreateWithJson
        ? customCreateWithJson.call(this, testCase)
        : TestedField.fromJson(testCase.json);
    };
    if (assertFieldDefault) {
      runCreationTests_(
        invalidValueTestCases,
        assertFieldDefault,
        createWithJson,
      );
    } else {
      runCreationTestsAssertThrows_(invalidValueTestCases, createWithJson);
    }
    runCreationTests_(validValueTestCases, validRunAssertField, createWithJson);
  });
}
Runs suite of tests for fromJson creation of specified field.
@param {function(new:Blockly.Field, *=)} TestedField The class of the field
   being tested.
@param {!Array<!FieldCreationTestCase>} validValueTestCases Test cases with
   valid values for given field.
@param {!Array<!FieldCreationTestCase>} invalidValueTestCases Test cases with
   invalid values for given field.
@param {function(!Blockly.Field, !FieldValueTestCase)
   } validRunAssertField Asserts that field has expected values.
@param {function(!Blockly.Field)=} assertFieldDefault Asserts that field has
   default values. If undefined, tests will check that field throws when
   invalid value is passed rather than asserting default.
@param {function(!FieldCreationTestCase=)=} customCreateWithJson Custom
   creation function to use in tests.