Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Story #11854 fix(design-system): add missing interface in mocked schema service #1966

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('EditObjectService', () => {
describe('EditObject', () => {
it('should create simple editObject', waitForAsync(
inject([MockSchemaService], (schemaService: MockSchemaService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = '';
const data = { Title: 'Hello' };
const template: DisplayRule[] = [{ Path: 'Title', ui: { Path: 'Title', component: 'textfield' } }];
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('EditObjectService', () => {

it('should create nested editObject', waitForAsync(
inject([MockSchemaService], (schemaService: MockSchemaService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = '';
const data = {
Title: 'Hello',
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('EditObjectService', () => {

it('should create projected nested object', waitForAsync(
inject([MockSchemaService, TemplateService, SchemaService], (schemaService: MockSchemaService, templetaService: TemplateService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = '';
const originalData = {
Title: 'Hello',
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('EditObjectService', () => {

it('should create projected nested object and add new items', waitForAsync(
inject([MockSchemaService, TemplateService, SchemaService], (schemaService: MockSchemaService, templetaService: TemplateService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = '';
const originalData = {
Title: 'Hello',
Expand Down Expand Up @@ -282,7 +282,7 @@ describe('EditObjectService', () => {

it('should create projected nested object and remove an item', waitForAsync(
inject([MockSchemaService, TemplateService, SchemaService], (schemaService: MockSchemaService, templetaService: TemplateService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = '';
const originalData = {
Title: 'Hello',
Expand Down Expand Up @@ -354,7 +354,7 @@ describe('EditObjectService', () => {

it('should create projected nested object and do complexe operations on arrays', waitForAsync(
inject([MockSchemaService, TemplateService, SchemaService], (schemaService: MockSchemaService, templetaService: TemplateService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = '';
const originalData = {
Title: 'Hello',
Expand Down Expand Up @@ -439,7 +439,7 @@ describe('EditObjectService', () => {

it('should create with empty data', waitForAsync(
inject([MockSchemaService, TemplateService, SchemaService], (schemaService: MockSchemaService, templetaService: TemplateService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = '';
const originalData = {};
const template: DisplayRule[] = [];
Expand Down Expand Up @@ -579,7 +579,7 @@ describe('EditObjectService', () => {

it('should template schema be same as schema when template does not move data', waitForAsync(
inject([MockSchemaService], (schemaService: MockSchemaService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const template: DisplayRule[] = [{ Path: 'Title', ui: { Path: 'Title', component: 'textfield' } }];
const subschema = schema
.filter((element) => element.Category === 'DESCRIPTION')
Expand All @@ -605,7 +605,7 @@ describe('EditObjectService', () => {

it('should template schema add only one node when moves a primitive from schema into a group a root level', waitForAsync(
inject([MockSchemaService], (schemaService: MockSchemaService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const template: DisplayRule[] = [
{ Path: null, ui: { Path: 'Generalities', component: 'group' } },
{ Path: 'Title', ui: { Path: 'Generalities.Title', component: 'textfield' } },
Expand All @@ -627,7 +627,7 @@ describe('EditObjectService', () => {

it('should template schema add only concerned nodes when moves an object array from schema into a group a root level', waitForAsync(
inject([MockSchemaService], (schemaService: MockSchemaService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const template: DisplayRule[] = [
{ Path: null, ui: { Path: 'Generalities', component: 'group' } },
{ Path: 'Addressee', ui: { Path: 'Generalities.Addressee', component: 'group' } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('SchemaService', () => {
describe('Subschema', () => {
it('should get archive unit schema subschema', waitForAsync(
inject([MockSchemaService], (schemaService: MockSchemaService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const subschema = service.subschema(schema, { collection: Collection.ARCHIVE_UNIT, versions: ['2.1'], pathKey: 'ApiPath' });

expect(subschema.every((element) => element.SedaVersions.includes('2.1'))).toBeTruthy();
Expand All @@ -33,7 +33,7 @@ describe('SchemaService', () => {
describe('Data', () => {
it('should create simple data according schema', waitForAsync(
inject([MockSchemaService], (schemaService: MockSchemaService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = '';
const data = service.data(path, schema, { collection: Collection.ARCHIVE_UNIT, versions: ['2.1'], pathKey: 'ApiPath' });

Expand All @@ -48,7 +48,7 @@ describe('SchemaService', () => {

it('should create data with all root level keys according schema', waitForAsync(
inject([MockSchemaService, PathService], (schemaService: MockSchemaService, pathService: PathService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = '';
const options: SchemaOptions = { collection: Collection.ARCHIVE_UNIT, versions: ['2.1'], pathKey: 'ApiPath' };
const subschema = service.subschema(schema, options);
Expand All @@ -64,7 +64,7 @@ describe('SchemaService', () => {

it('should create archive unit addressee block according schema', waitForAsync(
inject([MockSchemaService, PathService], (schemaService: MockSchemaService, pathService: PathService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = 'Addressee';
const options: SchemaOptions = { collection: Collection.ARCHIVE_UNIT, versions: ['2.1'], pathKey: 'ApiPath' };
const subschema = service.subschema(schema, options);
Expand All @@ -85,7 +85,7 @@ describe('SchemaService', () => {

it('should create archive unit addressee birth place block according schema', waitForAsync(
inject([MockSchemaService, PathService], (schemaService: MockSchemaService, pathService: PathService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = 'Addressee.BirthPlace';
const options: SchemaOptions = { collection: Collection.ARCHIVE_UNIT, versions: ['2.1'], pathKey: 'ApiPath' };
const subschema = service.subschema(schema, options);
Expand All @@ -109,7 +109,7 @@ describe('SchemaService', () => {

it('should work when a primitive node is provided', waitForAsync(
inject([MockSchemaService, PathService], (schemaService: MockSchemaService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = 'AcquiredDate';
const options: SchemaOptions = { collection: Collection.ARCHIVE_UNIT, versions: ['2.1'], pathKey: 'ApiPath' };
const subschema = service.subschema(schema, options);
Expand All @@ -123,7 +123,7 @@ describe('SchemaService', () => {

it('should work when a primitive array node is provided', waitForAsync(
inject([MockSchemaService], (schemaService: MockSchemaService) => {
schemaService.getSchema().subscribe((schema) => {
schemaService.getSchema(Collection.ARCHIVE_UNIT).subscribe((schema) => {
const path = 'Tag';
const options: SchemaOptions = { collection: Collection.ARCHIVE_UNIT, versions: ['2.1'], pathKey: 'ApiPath' };
const subschema = service.subschema(schema, options);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { Collection, SchemaElement } from '../models';
import { SchemaService } from 'vitamui-library';
import { Collection, Schema, SchemaElement } from '../models';
import { SchemaService } from './schema.service';

@Injectable()
export class MockSchemaService extends SchemaService {
Expand Down Expand Up @@ -13480,11 +13480,11 @@ export class MockSchemaService extends SchemaService {
},
];

getSchema(): Observable<SchemaElement[]> {
getSchema(_collection: Collection): Observable<Schema> {
return of(this.schema);
}

getSchemas(): Observable<SchemaElement[][]> {
getSchemas(_collections: Collection[]): Observable<Schema[]> {
return of([this.schema]);
}
}