From cf8a820b3df10c5de8d4ae6a43692629163cc08d Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 6 May 2021 23:13:28 +0200 Subject: [PATCH] Build fix and more stable tests. --- frontend/app-config/karma.coverage.conf.js | 2 +- .../references/content-creator.component.ts | 2 +- .../state/contents.forms.visitors.spec.ts | 20 ++++++++++++------- .../shared/state/rule-simulator.state.spec.ts | 2 ++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/frontend/app-config/karma.coverage.conf.js b/frontend/app-config/karma.coverage.conf.js index 9b4dff01e..28a244514 100644 --- a/frontend/app-config/karma.coverage.conf.js +++ b/frontend/app-config/karma.coverage.conf.js @@ -32,7 +32,7 @@ module.exports = function (config) { /** * Use a mocha style console reporter, html reporter and the code coverage reporter. */ - reporters: ['mocha', 'html', 'coverage-istanbul'], + reporters: ['kjhtml', 'mocha', 'coverage-istanbul'], htmlReporter: { useCompactStyle: true, diff --git a/frontend/app/features/content/shared/references/content-creator.component.ts b/frontend/app/features/content/shared/references/content-creator.component.ts index 358c0ca7c..21ee0a7f6 100644 --- a/frontend/app/features/content/shared/references/content-creator.component.ts +++ b/frontend/app/features/content/shared/references/content-creator.component.ts @@ -24,7 +24,7 @@ export class ContentCreatorComponent extends ResourceOwner implements OnInit { public initialData: any; @Input() - public schemaName: string; + public schemaName?: string | null; @Input() public schemaIds: ReadonlyArray; diff --git a/frontend/app/shared/state/contents.forms.visitors.spec.ts b/frontend/app/shared/state/contents.forms.visitors.spec.ts index 3090a58de..b71262207 100644 --- a/frontend/app/shared/state/contents.forms.visitors.spec.ts +++ b/frontend/app/shared/state/contents.forms.visitors.spec.ts @@ -287,12 +287,6 @@ describe('DateTimeField', () => { expect(FieldFormatter.format(dateField, '2017-12-12T00:00:00Z')).toBe('12/12/2017'); }); - it('should format to date time', () => { - const field2 = createField({ properties: createProperties('DateTime', { editor: 'DateTime' }) }); - - expect(FieldFormatter.format(field2, '2017-12-12T16:00:00Z')).toBe('12/12/2017, 4:00:00 PM'); - }); - it('should return default from properties value', () => { const field2 = createField({ properties: createProperties('DateTime', { editor: 'DateTime', defaultValue: '2017-10-12T16:00:00Z' }) }); @@ -316,6 +310,14 @@ describe('DateTimeField', () => { expect(FieldDefaultValue.get(field2, 'iv', now)).toEqual('2017-10-12T16:30:10Z'); }); + + if (isUtc()) { + it('should format to date time', () => { + const field2 = createField({ properties: createProperties('DateTime', { editor: 'DateTime' }) }); + + expect(FieldFormatter.format(field2, '2017-12-12T16:00:00Z')).toBe('12/12/2017, 4:00:00 PM'); + }); + } }); describe('GeolocationField', () => { @@ -496,4 +498,8 @@ describe('StringField', () => { expect(FieldDefaultValue.get(field2, 'iv')).toBeNull(); }); -}); \ No newline at end of file +}); + +function isUtc() { + return new Date().getTimezoneOffset() === 0; +} \ No newline at end of file diff --git a/frontend/app/shared/state/rule-simulator.state.spec.ts b/frontend/app/shared/state/rule-simulator.state.spec.ts index 775a2b54a..121d9d00b 100644 --- a/frontend/app/shared/state/rule-simulator.state.spec.ts +++ b/frontend/app/shared/state/rule-simulator.state.spec.ts @@ -64,6 +64,8 @@ describe('RuleSimulatorState', () => { it('should not load simulated rule events if no rule selected', () => { ruleSimulatorState.load().subscribe(); + expect().nothing(); + rulesService.verify(x => x.getSimulatedEvents(app, It.isAnyString()), Times.never()); }); }); \ No newline at end of file