Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/v2-shims/src/plugins/config.to.blueprint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,22 @@ describe('v2ConfigToBlueprint', () => {
])
})

it('should convert number field type to number', async () => {
const input: ISettings = {
type: 'Sample',
fields: [
{
key: 'sampleKey',
label: 'sampleLabel',
type: 'number',
},
],
};

const result = await configToBlueprint(input);

expect(result.sheets[0].fields[0].type).toBe(PlatformTypes.Num);
});

// You can also add negative tests, like testing how the function behaves with invalid input
})
2 changes: 2 additions & 0 deletions packages/v2-shims/src/plugins/config.to.blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const configToBlueprint = (schema: ISettings): BlueprintOutput => {
if (field.type === 'select') {
out.type = PlatformTypes.Enum
out.config = { options: field.options }
} else if (field.type === 'number') {
out.type = PlatformTypes.Num;
}
}
if (field.validators) {
Expand Down
2 changes: 1 addition & 1 deletion packages/v2-shims/src/types/settings.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export interface IFieldBase {
shortDescription?: string
alternates?: string[]
validators?: IValidator[]
type?: 'checkbox' | 'string'
type?: 'checkbox' | 'string' | 'number'
sizeHint?: number
}

Expand Down