Skip to content

Commit

Permalink
feat(2386): Use test.ts (remove hack). Update package.json to support…
Browse files Browse the repository at this point in the history
… Angular 18 and 19.
  • Loading branch information
laurentgrangier committed Nov 26, 2024
1 parent 3d94c0c commit df43d26
Show file tree
Hide file tree
Showing 23 changed files with 1,631 additions and 1,487 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"build:examples-app": "lerna run build:examples-app && node packages/examples-app/prepare-examples-app.js"
},
"devDependencies": {
"@angular/core": "^19.0.0",
"@angular/cli": "^19.0.0",
"@angular/core": "^18.0.0",
"@angular/cli": "^18.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.5",
"@babel/plugin-proposal-optional-chaining": "^7.16.5",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
Expand Down
42 changes: 21 additions & 21 deletions packages/angular-material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
"build": "ng build",
"build:examples-app": "pnpm run build && ng build --project=example",
"dev": "pnpm run build:examples-app && npx http-server ./example/dist/ -c-1 -o",
"clean": "rimraf lib coverage dist .nyc_output 2> /dev/null",
"clean": "rimraf lib coverage example/dist .nyc_output 2> /dev/null",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"report": "nyc report --reporter=html",
"doc": "typedoc --name 'JSON Forms Angular Material Renderers' --out docs src",
"test-dbg": "ng test",
"test": "ng test --watch=false",
"test-ci": "ng test --watch=false",
"test-cov": "ng test --watch=false --code-coverage",
"test-ci": "ng test --watch=false --browsers ChromeHeadlessNoSandbox",
"test-cov": "ng test --watch=false --code-coverage --browsers ChromeHeadlessNoSandbox",
"e2e": "npm run e2e-update && npm run e2e-test",
"e2e-test": "protractor ./test-config/protractor.conf.js",
"e2e-update": "webdriver-manager update --standalone false --gecko false"
Expand All @@ -60,8 +60,8 @@
]
},
"peerDependencies": {
"@angular/cdk": "^18.0.0",
"@angular/material": "^19.0.0",
"@angular/cdk": "^18.0.0 | ^19.0.0",
"@angular/material": "^18.0.0 | ^19.0.0",
"@jsonforms/angular": "3.4.1",
"@jsonforms/core": "3.4.1",
"dayjs": "^1.11.10",
Expand All @@ -72,29 +72,29 @@
"lodash": "^4.17.21"
},
"devDependencies": {
"@angular-devkit/build-angular": "^19.0.0",
"@angular-devkit/core": "^19.0.0",
"@angular-devkit/build-angular": "^18.0.0",
"@angular-devkit/core": "^18.0.0",
"@angular-eslint/eslint-plugin": "^18.0.0",
"@angular-eslint/eslint-plugin-template": "^18.0.0",
"@angular-eslint/schematics": "^18.0.0",
"@angular-eslint/template-parser": "^18.0.0",
"@angular/animations": "^19.0.0",
"@angular/cdk": "^19.0.0",
"@angular/common": "^19.0.0",
"@angular/compiler": "^19.0.0",
"@angular/compiler-cli": "^19.0.0",
"@angular/core": "^19.0.0",
"@angular/forms": "^19.0.0",
"@angular/material": "^19.0.0",
"@angular/platform-browser": "^19.0.0",
"@angular/platform-browser-dynamic": "^19.0.0",
"@angular/router": "^19.0.0",
"@angular/animations": "^18.0.0",
"@angular/cdk": "^18.0.0",
"@angular/common": "^18.0.0",
"@angular/compiler": "^18.0.0",
"@angular/compiler-cli": "^18.0.0",
"@angular/core": "^18.0.0",
"@angular/forms": "^18.0.0",
"@angular/material": "^18.0.0",
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.5",
"@babel/plugin-proposal-optional-chaining": "^7.16.5",
"@jsonforms/angular": "workspace:*",
"@jsonforms/core": "workspace:*",
"@jsonforms/examples": "workspace:*",
"@ngtools/webpack": "^19.0.0",
"@ngtools/webpack": "^18.0.0",
"@types/jasmine": "~3.8.0",
"@types/lodash": "4.14.149",
"@types/node": "^18.19.4",
Expand All @@ -118,7 +118,7 @@
"karma-jasmine-html-reporter": "^1.7.0",
"karma-sourcemap-loader": "^0.3.8",
"karma-webpack": "^5.0.0",
"ng-packagr": "^19.0.0",
"ng-packagr": "^18.0.0",
"null-loader": "^0.1.1",
"nyc": "^15.1.0",
"prettier": "^2.8.4",
Expand All @@ -131,6 +131,6 @@
"typescript": "~5.5.0",
"webpack": "^5.78.0",
"yargs": "^17.7.2",
"zone.js": "~0.15.0"
"zone.js": "~0.14.10"
}
}
3 changes: 0 additions & 3 deletions packages/angular-material/test/autocomplete-control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import { ControlElement, JsonSchema, Actions } from '@jsonforms/core';
import { AutocompleteControlRenderer } from '../src';
import { JsonFormsAngularService } from '@jsonforms/angular';
import { ErrorObject } from 'ajv';
import { initTestEnvironment } from './test';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatAutocompleteHarness } from '@angular/material/autocomplete/testing';
Expand Down Expand Up @@ -83,8 +82,6 @@ const errorTest: ErrorTestExpectation = {
indexOfElement: 0,
};

initTestEnvironment();

describe('Autocomplete control Base Tests', () => {
let fixture: ComponentFixture<AutocompleteControlRenderer>;
let component: AutocompleteControlRenderer;
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/boolean-control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ import {
} from './common';
import { BooleanControlRenderer, booleanControlTester } from '../src';
import { JsonFormsAngularService } from '@jsonforms/angular';
import { initTestEnvironment } from './test';

initTestEnvironment();

describe('Material boolean field tester', () => {
const uischema = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { initTestEnvironment } from './test';

const renderers = [
{ tester: TextControlRendererTester, renderer: TextControlRenderer },
];

initTestEnvironment();

describe('Categorization tab layout', () => {
let fixture: ComponentFixture<any>;
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/date-control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import { Actions, ControlElement, JsonSchema } from '@jsonforms/core';
import { DateControlRenderer, DateControlRendererTester } from '../src';
import { JsonFormsAngularService } from '@jsonforms/angular';
import { createTesterContext } from './util';
import { initTestEnvironment } from './test';

const data = { foo: '2018-01-01' };
const schema: JsonSchema = {
Expand All @@ -66,8 +65,6 @@ const uischema: ControlElement = {
scope: '#/properties/foo',
};

initTestEnvironment();

describe('Material boolean field tester', () => {
it('should succeed', () => {
expect(
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/group-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ import {
GroupLayoutRenderer,
groupLayoutTester,
} from '../src/library/layouts/group-layout.renderer';
import { initTestEnvironment } from './test';

initTestEnvironment();

describe('Group layout tester', () => {
it('should succeed', () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/horizontal-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ import {
horizontalLayoutTester,
} from '../src/library/layouts/horizontal-layout.renderer';
import { LayoutChildrenRenderPropsPipe } from '../src/library/layouts/layout.renderer';
import { initTestEnvironment } from './test';

initTestEnvironment();

describe('Horizontal layout tester', () => {
it('should succeed', () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/label-renderer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { JsonSchema, LabelElement } from '@jsonforms/core';
import { LabelRenderer, LabelRendererTester } from '../src/library/other';
import { setupMockStore } from './common';
import { JsonFormsAngularService } from '@jsonforms/angular';
import { initTestEnvironment } from './test';

const data = {};
const schema: JsonSchema = {
Expand All @@ -45,8 +44,6 @@ const uischema: LabelElement = {
text: 'FooBar',
};

initTestEnvironment();

describe('Material label field tester', () => {
it('should succeed', () => {
expect(LabelRendererTester(uischema, schema, undefined)).toBe(4);
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/master-detail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ import { JsonFormsDetailComponent } from '../src/library/other/master-detail/det
import { getJsonFormsService, setupMockStore } from './common';
import { Actions } from '@jsonforms/core';
import { MatTooltipModule } from '@angular/material/tooltip';
import { initTestEnvironment } from './test';

initTestEnvironment();

describe('Master detail', () => {
let fixture: ComponentFixture<MasterListComponent>;
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/middleware.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { NumberControlRenderer } from '../src';
import { JsonFormsAngularService, JsonFormsControl } from '@jsonforms/angular';
import { baseSetup, getJsonFormsService, prepareComponent } from './common';
import { initTestEnvironment } from './test';

const imports = [
MatFormFieldModule,
Expand All @@ -42,8 +41,6 @@ const providers = [JsonFormsAngularService];
const componentUT: any = NumberControlRenderer;
const testConfig = { imports, providers, componentUT };

initTestEnvironment();

describe('middleware tests', () => {
let component: JsonFormsControl;
const startingValues = {
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/number-control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ import {
} from './common';
import { Actions, ControlElement, JsonFormsCore } from '@jsonforms/core';
import { NumberControlRenderer, NumberControlRendererTester } from '../src';
import { initTestEnvironment } from './test';

initTestEnvironment();

describe('Material number field tester', () => {
const uischema = {
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/object-control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
} from '../src/library/other/object.renderer';
import { getJsonFormsService } from './common';
import { LayoutChildrenRenderPropsPipe } from '../src/library/layouts/layout.renderer';
import { initTestEnvironment } from './test';

const uischema1: ControlElement = { type: 'Control', scope: '#' };
const uischema2: ControlElement = {
Expand Down Expand Up @@ -82,8 +81,6 @@ const renderers = [
{ tester: ObjectControlRendererTester, renderer: ObjectControlRenderer },
];

initTestEnvironment();

describe('Object Control tester', () => {
it('should succeed', () => {
expect(ObjectControlRendererTester(uischema1, schema1, undefined)).toBe(2);
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/range-control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ import {
} from './common';
import { RangeControlRenderer, RangeControlRendererTester } from '../src';
import { JsonFormsAngularService } from '@jsonforms/angular';
import { initTestEnvironment } from './test';

initTestEnvironment();

describe('Material number field tester', () => {
const uischema = {
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/table-control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
import { setupMockStore } from './common';
import { createTesterContext } from './util';
import { MatTooltipModule } from '@angular/material/tooltip';
import { initTestEnvironment } from './test';

const uischema1: ControlElement = { type: 'Control', scope: '#' };
const uischema2: ControlElement = {
Expand Down Expand Up @@ -103,8 +102,6 @@ const renderers = [
{ tester: TableRendererTester, renderer: TableRenderer },
];

initTestEnvironment();

describe('Table tester', () => {
it('should succeed', () => {
expect(
Expand Down
17 changes: 6 additions & 11 deletions packages/angular-material/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import 'zone.js/testing';
import { TestBed } from '@angular/core/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';

export function initTestEnvironment() {
TestBed.resetTestEnvironment();
TestBed.initTestEnvironment(
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{
teardown: { destroyAfterEach: false },
}
);
}
);
3 changes: 0 additions & 3 deletions packages/angular-material/test/text-area.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ import {
import { TextAreaRenderer, TextAreaRendererTester } from '../src';
import { ControlElement, JsonSchema } from '@jsonforms/core';
import { JsonFormsAngularService } from '@jsonforms/angular';
import { initTestEnvironment } from './test';

initTestEnvironment();

describe('Material text field tester', () => {
const uischema = {
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/text-control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ import {
} from './common';
import { TextControlRenderer, TextControlRendererTester } from '../src';
import { JsonFormsAngularService } from '@jsonforms/angular';
import { initTestEnvironment } from './test';

initTestEnvironment();

describe('Material text field tester', () => {
const uischema = {
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/toggle-control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ import {
} from './common';
import { ToggleControlRenderer, ToggleControlRendererTester } from '../src';
import { JsonFormsAngularService } from '@jsonforms/angular';
import { initTestEnvironment } from './test';

initTestEnvironment();

describe('Material boolean field tester', () => {
const uischema = {
Expand Down
3 changes: 0 additions & 3 deletions packages/angular-material/test/vertical-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ import {
verticalLayoutTester,
} from '../src/library/layouts/vertical-layout.renderer';
import { LayoutChildrenRenderPropsPipe } from '../src/library/layouts/layout.renderer';
import { initTestEnvironment } from './test';

initTestEnvironment();

describe('Vertical layout tester', () => {
it('should succeed', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/angular-material/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
]
},
"include": [
"test/test.ts",
"**/*.spec.ts",
"**/*.d.ts"
],
Expand Down
14 changes: 7 additions & 7 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"lodash": "^4.17.21"
},
"peerDependencies": {
"@angular/core": "^19.0.0",
"@angular/forms": "^19.0.0",
"@angular/core": "^18.0.0 | ^19.0.0",
"@angular/forms": "^18.0.0 | ^19.0.0",
"@jsonforms/core": "3.4.1",
"rxjs": "^6.6.0 || ^7.4.0"
},
Expand All @@ -77,10 +77,10 @@
"@angular-eslint/eslint-plugin-template": "^18.0.0",
"@angular-eslint/schematics": "^18.0.0",
"@angular-eslint/template-parser": "^18.0.0",
"@angular/compiler": "^19.0.0",
"@angular/compiler-cli": "^19.0.0",
"@angular/core": "^19.0.0",
"@angular/forms": "^19.0.0",
"@angular/compiler": "^18.0.0",
"@angular/compiler-cli": "^18.0.0",
"@angular/core": "^18.0.0",
"@angular/forms": "^18.0.0",
"@jsonforms/core": "workspace:*",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
Expand All @@ -90,7 +90,7 @@
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"ng-packagr": "^19.0.0",
"ng-packagr": "^18.0.0",
"nyc": "^15.1.0",
"prettier": "^2.8.4",
"rimraf": "^3.0.2",
Expand Down
Loading

0 comments on commit df43d26

Please sign in to comment.