PHP 8.2.30
Preview: convert-nested-param.spec.js Size: 1.88 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/lib/utils/param-converter/convert-nested-param.spec.js

import { expect } from 'chai';
import { convertNestedParam } from './convert-nested-param.js';
const jsonField = {
  number: '123',
  date: '2020-11-08',
  nested: {
    number: '456'
  },
  nestedList: [{
    number: '789'
  }, {
    number: '111'
  }]
};
describe('module:paramConverter.convertNestedParam', () => {
  it('should convert number property of a JSON to actual number', () => {
    const property = {
      type: 'number',
      propertyPath: 'jsonField.number',
      subProperties: []
    };
    const convertedJson = convertNestedParam(jsonField, property);
    expect(convertedJson.number).to.equal(123);
  });
  it('should convert date property of a JSON to actual number', () => {
    const property = {
      type: 'datetime',
      propertyPath: 'jsonField.date',
      subProperties: []
    };
    const convertedJson = convertNestedParam(jsonField, property);
    expect(convertedJson.date.getTime()).to.equal(new Date('2020-11-08').getTime());
  });
  it('should convert a nested json property\'s number string to actual number', () => {
    const property = {
      type: 'mixed',
      propertyPath: 'jsonField.nested',
      isArray: false,
      subProperties: [{
        propertyPath: 'jsonField.nested.number',
        type: 'number'
      }]
    };
    const convertedJson = convertNestedParam(jsonField, property);
    expect(convertedJson.nested.number).to.equal(456);
  });
  it('should convert a nested json array property\'s number string to actual number', () => {
    const property = {
      type: 'mixed',
      propertyPath: 'jsonField.nestedList',
      isArray: true,
      subProperties: [{
        propertyPath: 'jsonField.nestedList.number',
        type: 'number'
      }]
    };
    const convertedJson = convertNestedParam(jsonField, property);
    expect(convertedJson.nestedList[0].number).to.equal(789);
    expect(convertedJson.nestedList[1].number).to.equal(111);
  });
});

Directory Contents

Dirs: 0 × Files: 9

Name Size Perms Modified Actions
44 B lrw-r--r-- 2026-02-28 00:31:26
Edit Download
828 B lrw-r--r-- 2026-02-28 00:31:26
Edit Download
1.88 KB lrw-r--r-- 2026-02-28 00:31:26
Edit Download
386 B lrw-r--r-- 2026-02-28 00:31:26
Edit Download
824 B lrw-r--r-- 2026-02-28 00:31:26
Edit Download
44 B lrw-r--r-- 2026-02-28 00:31:44
Edit Download
313 B lrw-r--r-- 2026-02-28 00:31:48
Edit Download
1.35 KB lrw-r--r-- 2026-02-28 00:31:48
Edit Download
819 B lrw-r--r-- 2026-02-28 00:31:52
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).