Skip to content

Commit

Permalink
gh-470: Fix broken tests
Browse files Browse the repository at this point in the history
(cherry picked from commit 59b2602)
  • Loading branch information
NigelPalmer committed Oct 15, 2024
1 parent 054705d commit 544df94
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/app/data-explorer/pipes/meql.pipe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('MeqlPipe', () => {
condition: 'and',
rules: [
{
field: 'field name',
field: 'some entity.field name',
entity: 'some entity',
operator: '=',
value: 'String 1',
Expand All @@ -52,7 +52,7 @@ describe('MeqlPipe', () => {
};

const line1 = `(${newline}`;
const line2 = `${tab}"${query.rules[0].entity}.${query.rules[0].field}" ${query.rules[0].operator} "${query.rules[0].value}"${newline}`;
const line2 = `${tab}"${query.rules[0].field}" ${query.rules[0].operator} "${query.rules[0].value}"${newline}`;
const line3 = ')';

const actual = pipe.transform(query);
Expand Down
29 changes: 15 additions & 14 deletions src/app/data-explorer/query-builder-wrapper.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
import { QueryBuilderConfig } from './query-builder/query-builder.interfaces';
import { createProfileServiceStub } from '../testing/stubs/profile.stub';
import { QueryBuilderTestingHelper } from '../testing/querybuilder.testing.helpers';
import { Console } from 'console';
describe('QueryBuilderService', () => {
let service: QueryBuilderWrapperService;
const profilesStub = createProfileServiceStub();
Expand Down Expand Up @@ -255,7 +256,7 @@ describe('QueryBuilderService', () => {
condition: 'and',
rules: [
{
field: `field (${expectedMappedType})`,
field: `schema.class.field (${expectedMappedType})`,
operator: '=',
value: 'value-1',
},
Expand All @@ -268,15 +269,15 @@ describe('QueryBuilderService', () => {
fields:
expectedMappedType !== undefined
? {
field: {
[`${entityName}.field`]: {
defaultValue:
expectedMappedType === 'number'
? 0
: expectedMappedType === 'string'
? ''
: expectedMappedType === 'boolean'
? false
: null,
? ''
: expectedMappedType === 'boolean'
? false
: null,
name: `field (${expectedMappedType})`,
entity: entityName,
options:
Expand All @@ -286,14 +287,14 @@ describe('QueryBuilderService', () => {
{ name: 'Option 2', value: 'Option 2' },
]
: expectedMappedType === 'terminology'
? [
{
name: 'modelResourceDomainType',
value: dataType.modelResourceDomainType,
},
{ name: 'modelResourceId', value: dataType.modelResourceId },
]
: [],
? [
{
name: 'modelResourceDomainType',
value: dataType.modelResourceDomainType,
},
{ name: 'modelResourceId', value: dataType.modelResourceId },
]
: [],
type: expectedMappedType,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,15 @@ SPDX-License-Identifier: Apache-2.0
*/
import { QueryBuilderWrapperComponent } from './query-builder-wrapper.component';

import {
ComponentHarness,
setupTestModuleForComponent,
} from 'src/app/testing/testing.helpers';
import { ComponentHarness, setupTestModuleForComponent } from 'src/app/testing/testing.helpers';
import { createTerminologyServiceStub } from 'src/app/testing/stubs/terminology.stub';
import { TerminologyService } from 'src/app/mauro/terminology.service';
import { MockComponent } from 'ng-mocks';
import { MeqlOutputComponent } from '../meql-output/meql-output.component';
import { MatCard } from '@angular/material/card';
import { QueryCondition } from '../data-explorer.types';
import { mapModelDataTypeToOptionsArray } from '../query-builder-wrapper.service';
import {
CatalogueItemDomainType,
MdmResourcesConfiguration,
} from '@maurodatamapper/mdm-resources';
import { CatalogueItemDomainType, MdmResourcesConfiguration } from '@maurodatamapper/mdm-resources';
import { of } from 'rxjs';
import { AutocompleteSelectOptionSet } from 'src/app/shared/autocomplete-select/autocomplete-select.component';
import { QueryBuilderComponent } from '../query-builder/query-builder.component';
Expand Down Expand Up @@ -133,12 +127,8 @@ describe('QueryBuilderComponent', () => {
options: [],
};

expect(harness.component.termSearchResults['testField1']).toStrictEqual(
expectedSetup
);
expect(harness.component.termSearchResults['testField2']).toStrictEqual(
expectedSetup
);
expect(harness.component.termSearchResults['testField1']).toStrictEqual(expectedSetup);
expect(harness.component.termSearchResults['testField2']).toStrictEqual(expectedSetup);
});

it('should reset the query when empty', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class QueryBuilderWrapperComponent implements OnInit {
options: terms.items.map((item) => {
return {
name: item.definition,
value: item.definition,
value: item,
};
}),
};
Expand Down

0 comments on commit 544df94

Please sign in to comment.