|
| 1 | +import { expect } from 'chai'; |
| 2 | +import { gfSchemaTemplate } from '../../../src/utils/global-field-helper'; |
| 3 | + |
| 4 | +describe('Global Field Helper', () => { |
| 5 | + describe('gfSchemaTemplate', () => { |
| 6 | + it('should export a schema template object', () => { |
| 7 | + expect(gfSchemaTemplate).to.be.an('object'); |
| 8 | + expect(gfSchemaTemplate).to.have.property('global_field'); |
| 9 | + }); |
| 10 | + |
| 11 | + it('should have correct structure for global_field', () => { |
| 12 | + const globalField = gfSchemaTemplate.global_field; |
| 13 | + |
| 14 | + expect(globalField).to.be.an('object'); |
| 15 | + expect(globalField).to.have.property('title', 'Seed'); |
| 16 | + expect(globalField).to.have.property('uid', ''); |
| 17 | + expect(globalField).to.have.property('schema'); |
| 18 | + expect(globalField).to.have.property('description', ''); |
| 19 | + }); |
| 20 | + |
| 21 | + it('should have schema as an array', () => { |
| 22 | + const schema = gfSchemaTemplate.global_field.schema; |
| 23 | + |
| 24 | + expect(schema).to.be.an('array'); |
| 25 | + expect(schema).to.have.lengthOf(1); |
| 26 | + }); |
| 27 | + |
| 28 | + it('should have correct structure for first schema field', () => { |
| 29 | + const firstField = gfSchemaTemplate.global_field.schema[0]; |
| 30 | + |
| 31 | + expect(firstField).to.be.an('object'); |
| 32 | + expect(firstField).to.have.property('display_name', 'Title'); |
| 33 | + expect(firstField).to.have.property('uid', 'title'); |
| 34 | + expect(firstField).to.have.property('data_type', 'text'); |
| 35 | + expect(firstField).to.have.property('field_metadata'); |
| 36 | + expect(firstField).to.have.property('unique', false); |
| 37 | + expect(firstField).to.have.property('mandatory', true); |
| 38 | + expect(firstField).to.have.property('multiple', false); |
| 39 | + }); |
| 40 | + |
| 41 | + it('should have correct field_metadata structure', () => { |
| 42 | + const fieldMetadata = gfSchemaTemplate.global_field.schema[0].field_metadata; |
| 43 | + |
| 44 | + expect(fieldMetadata).to.be.an('object'); |
| 45 | + expect(fieldMetadata).to.have.property('_default', true); |
| 46 | + }); |
| 47 | + }); |
| 48 | +}); |
0 commit comments