refactor: Update required validations with custom assertion

This commit is contained in:
Faruk AYDIN
2024-09-23 16:32:36 +03:00
parent f8389ff8ab
commit 9006a0c25f
2 changed files with 5 additions and 19 deletions

View File

@@ -5,7 +5,7 @@ class Datastore extends Base {
static jsonSchema = { static jsonSchema = {
type: 'object', type: 'object',
required: ['key', 'value', 'scope', 'scopeId'], required: ['key', 'value', 'scopeId'],
properties: { properties: {
id: { type: 'string', format: 'uuid' }, id: { type: 'string', format: 'uuid' },

View File

@@ -6,23 +6,9 @@ describe('Datastore model', () => {
expect(Datastore.tableName).toBe('datastore'); expect(Datastore.tableName).toBe('datastore');
}); });
it('jsonSchema should have the correct schema', () => { it('jsonSchema should have correct validations', () => {
const expectedSchema = { expect(Datastore).toRequireProperty('key');
type: 'object', expect(Datastore).toRequireProperty('value');
required: ['key', 'value', 'scope', 'scopeId'], expect(Datastore).toRequireProperty('scopeId');
properties: {
id: { type: 'string', format: 'uuid' },
key: { type: 'string', minLength: 1 },
value: { type: 'string' },
scope: {
type: 'string',
enum: ['flow'],
default: 'flow',
},
scopeId: { type: 'string', format: 'uuid' },
},
};
expect(Datastore.jsonSchema).toStrictEqual(expectedSchema);
}); });
}); });