Skip to content

Commit faa3c28

Browse files
authored
Merge pull request #2214 from contentstack/tests/DX-3671
DX - 3671 - Added Unit Tests for Utilities
2 parents 13cc65b + 1134f8c commit faa3c28

File tree

8 files changed

+2984
-0
lines changed

8 files changed

+2984
-0
lines changed

.talismanrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,16 @@ fileignoreconfig:
179179
checksum: ea4140a1516630fbfcdd61c4fe216414b733b4df2410b5d090d58ab1a22e7dbf
180180
- filename: packages/contentstack-import/test/unit/import/modules/variant-entries.test.ts
181181
checksum: abcc2ce0b305afb655eb46a1652b3d9e807a2a2e0eef1caeb16c8ae83af4f1a1
182+
- filename: packages/contentstack-import/test/unit/utils/import-path-resolver.test.ts
183+
checksum: 05436c24619b2d79b51eda9ce9a338182cc69b078ede60d310bfd55a62db8369
184+
- filename: packages/contentstack-import/test/unit/utils/interactive.test.ts
185+
checksum: 77a45bd7326062053b98d1333fa59147757a5a8abdb34057a347ca2a1b95b343
186+
- filename: packages/contentstack-import/test/unit/utils/import-config-handler.test.ts
187+
checksum: 20bbfb405a183b577f8ae8f2b47013bc42729aa817d617264e0c3a70b3fa752b
188+
- filename: packages/contentstack-import/test/unit/utils/login-handler.test.ts
189+
checksum: bea00781cdffc2d085b3c85d6bde75f12faa3ee51930c92e59777750a6727325
190+
- filename: packages/contentstack-import/test/unit/utils/marketplace-app-helper.test.ts
191+
checksum: eca2702d1f7ed075b9b857964b9e56f69b16e4a31942423d6b1265e4bf398db5
192+
- filename: packages/contentstack-import/test/unit/utils/logger.test.ts
193+
checksum: 794e06e657a7337c8f094d6042fb04c779683f97b860efae14e075098d2af024
182194
version: "1.0"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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

Comments
 (0)