Skip to content

Commit

Permalink
SHIBUI-996 Fixed issue with filter validation
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Nov 30, 2018
1 parent 2091f7c commit 03d3b24
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions ui/src/app/metadata/filter/model/entity-attributes.filter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
import { EntityAttributesFilter } from './entity-attributes.filter';

describe('Entity Attributes filter form', () => {
it('should return an empty object for validators', () => {
expect(EntityAttributesFilter.getValidators()).toEqual({});
describe('getValidators', () => {
it('should return an empty object for validators', () => {
expect(Object.keys(EntityAttributesFilter.getValidators())).toEqual([
'/',
'/name'
]);
});

describe('name `/name` validator', () => {
const validators = EntityAttributesFilter.getValidators(['foo', 'bar']);

it('should return an invalid object when provided values are invalid based on name', () => {
expect(validators['/name']('foo', { path: '/name' })).toBeDefined();
});

it('should return null when provided values are valid based on name', () => {
expect(validators['/name']('baz', { path: '/name' })).toBeNull();
});
});

describe('parent `/` validator', () => {
const validators = EntityAttributesFilter.getValidators(['foo', 'bar']);

it('should return a list of child errors', () => {
expect(validators['/']({ name: 'foo' }, { path: '/name' }, {}).length).toBe(1);
});

it('should ignore properties that don\'t exist a list of child errors', () => {
expect(validators['/']({ foo: 'bar' }, { path: '/foo' }, {})).toBeUndefined();
});
});
});

describe('transformer', () => {
Expand Down

0 comments on commit 03d3b24

Please sign in to comment.