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 = {
type: 'object',
required: ['key', 'value', 'scope', 'scopeId'],
required: ['key', 'value', 'scopeId'],
properties: {
id: { type: 'string', format: 'uuid' },

View File

@@ -6,23 +6,9 @@ describe('Datastore model', () => {
expect(Datastore.tableName).toBe('datastore');
});
it('jsonSchema should have the correct schema', () => {
const expectedSchema = {
type: 'object',
required: ['key', 'value', 'scope', '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);
it('jsonSchema should have correct validations', () => {
expect(Datastore).toRequireProperty('key');
expect(Datastore).toRequireProperty('value');
expect(Datastore).toRequireProperty('scopeId');
});
});