Browse Source

Test warnings fixed.

pull/297/head
Sebastian 8 years ago
parent
commit
543b2c8cc0
  1. 2
      src/Squidex/app-config/karma-test-shim.js
  2. 8
      src/Squidex/app/features/administration/state/event-consumers.state.spec.ts
  3. 4
      src/Squidex/app/features/administration/state/users.state.spec.ts
  4. 4
      src/Squidex/app/framework/angular/shortcut.component.spec.ts
  5. 4
      src/Squidex/app/framework/services/dialog.service.ts
  6. 22
      src/Squidex/app/framework/services/onboarding.service.spec.ts
  7. 6
      src/Squidex/app/shared/interceptors/auth.interceptor.spec.ts
  8. 4
      src/Squidex/app/shared/services/help.service.ts
  9. 4
      src/Squidex/app/shared/services/schemas.service.ts
  10. 4
      src/Squidex/app/shared/services/users-provider.service.ts
  11. 4
      src/Squidex/app/shared/state/assets.state.spec.ts
  12. 6
      src/Squidex/app/shared/state/backups.state.spec.ts
  13. 2
      src/Squidex/app/shared/state/clients.state.spec.ts
  14. 30
      src/Squidex/app/shared/state/contents.forms.spec.ts
  15. 2
      src/Squidex/app/shared/state/contributors.state.spec.ts
  16. 2
      src/Squidex/app/shared/state/languages.state.spec.ts
  17. 2
      src/Squidex/app/shared/state/patterns.state.spec.ts
  18. 2
      src/Squidex/app/shared/state/plans.state.spec.ts
  19. 6
      src/Squidex/app/shared/state/rule-events.state.spec.ts
  20. 2
      src/Squidex/app/shared/state/rules.state.spec.ts
  21. 4
      src/Squidex/app/shared/state/schemas.state.spec.ts
  22. 17232
      src/Squidex/package-lock.json
  23. 2
      src/Squidex/package.json

2
src/Squidex/app-config/karma-test-shim.js

@ -11,8 +11,6 @@ require('zone.js/dist/jasmine-patch');
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');
require('rxjs/Rx');
var testing = require('@angular/core/testing');
var browser = require('@angular/platform-browser-dynamic/testing');

8
src/Squidex/app/features/administration/state/event-consumers.state.spec.ts

@ -40,12 +40,16 @@ describe('EventConsumersState', () => {
expect(eventConsumersState.snapshot.eventConsumers.values).toEqual(oldConsumers);
expect(eventConsumersState.snapshot.isLoaded).toBeTruthy();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.never());
});
it('should show notification on load when reload is true', () => {
eventConsumersState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});
@ -55,6 +59,8 @@ describe('EventConsumersState', () => {
eventConsumersState.load(true, true).pipe(onErrorResumeNext()).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyError(It.isAny()), Times.once());
});
@ -64,6 +70,8 @@ describe('EventConsumersState', () => {
eventConsumersState.load().pipe(onErrorResumeNext()).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyError(It.isAny()), Times.never());
});

4
src/Squidex/app/features/administration/state/users.state.spec.ts

@ -64,6 +64,8 @@ describe('UsersState', () => {
it('should show notification on load when reload is true', () => {
usersState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});
@ -204,6 +206,8 @@ describe('UsersState', () => {
usersState.goNext().subscribe();
usersState.goPrev().subscribe();
expect().nothing();
usersService.verify(x => x.getUsers(10, 10, undefined), Times.once());
usersService.verify(x => x.getUsers(10, 0, undefined), Times.exactly(2));
});

4
src/Squidex/app/framework/angular/shortcut.component.spec.ts

@ -28,6 +28,8 @@ describe('ShortcutComponent', () => {
shortcutComponent.keys = null!;
shortcutComponent.ngOnInit();
expect().nothing();
});
it('should destroy without keys', () => {
@ -35,6 +37,8 @@ describe('ShortcutComponent', () => {
shortcutComponent.keys = null!;
shortcutComponent.ngOnDestroy();
expect().nothing();
});
it('should raise event when triggered', () => {

4
src/Squidex/app/framework/services/dialog.service.ts

@ -6,7 +6,7 @@
*/
import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { Observable, Subject, throwError } from 'rxjs';
import { ErrorDto } from './../utils/error';
import { Types } from './../utils/types';
@ -71,7 +71,7 @@ export class DialogService {
this.notify(Notification.error(error));
}
return Observable.throw(error);
return throwError(error);
}
public notifyInfo(text: string) {

22
src/Squidex/app/framework/services/onboarding.service.spec.ts

@ -20,7 +20,11 @@ class LocalStoreMock {
}
describe('OnboardingService', () => {
const localStore = new LocalStoreMock();
let localStore: LocalStoreMock;
beforeEach(() => {
localStore = new LocalStoreMock();
});
it('should instantiate from factory', () => {
const onboardingService = OnboardingServiceFactory(<any>localStore);
@ -35,29 +39,27 @@ describe('OnboardingService', () => {
});
it('should return true when value not in store', () => {
localStore.set('squidex.onboarding.disable.feature1', '0');
localStore.set('squidex.onboarding.disable.feature-a1', '0');
const onboardingService = new OnboardingService(<any>localStore);
onboardingService.disable('feature2');
expect(onboardingService.shouldShow('feature1')).toBeTruthy();
expect(onboardingService.shouldShow('feature-a2')).toBeTruthy();
});
it('should return false when value in store', () => {
localStore.set('squidex.onboarding.disable.feature1', '1');
localStore.set('squidex.onboarding.disable.feature-b1', '1');
const onboardingService = new OnboardingService(<any>localStore);
expect(onboardingService.shouldShow('feature1')).toBeFalsy();
expect(onboardingService.shouldShow('feature-b1')).toBeFalsy();
});
it('should return false when disabled', () => {
const onboardingService = new OnboardingService(<any>localStore);
onboardingService.disable('feature1');
onboardingService.disable('feature-c1');
expect(onboardingService.shouldShow('feature1')).toBeFalsy();
expect(onboardingService.shouldShow('feature-c1')).toBeFalsy();
});
it('should return false when all disabled', () => {
@ -65,6 +67,6 @@ describe('OnboardingService', () => {
onboardingService.disableAll();
expect(onboardingService.shouldShow('feature1')).toBeFalsy();
expect(onboardingService.shouldShow('feature-d1')).toBeFalsy();
});
});

6
src/Squidex/app/shared/interceptors/auth.interceptor.spec.ts

@ -100,6 +100,8 @@ describe('AuthInterceptor', () => {
httpMock.expectOne('http://service/p/apps').error(<any>{}, { status: 401 });
httpMock.expectOne('http://service/p/apps').error(<any>{}, { status: 401 });
expect().nothing();
authService.verify(x => x.logoutRedirect(), Times.once());
}));
@ -115,6 +117,8 @@ describe('AuthInterceptor', () => {
req.error(<any>{}, { status: statusCode });
expect().nothing();
authService.verify(x => x.logoutRedirect(), Times.once());
}));
});
@ -131,6 +135,8 @@ describe('AuthInterceptor', () => {
req.error(<any>{}, { status: statusCode });
expect().nothing();
authService.verify(x => x.logoutRedirect(), Times.never());
}));
});

4
src/Squidex/app/shared/services/help.service.ts

@ -7,7 +7,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Observable, of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
@Injectable()
@ -32,6 +32,6 @@ export class HelpService {
return result;
}),
catchError(error => []));
catchError(error => of([])));
}
}

4
src/Squidex/app/shared/services/schemas.service.ts

@ -256,7 +256,7 @@ export class SchemasService {
map(response => {
const body = response.payload.body;
const fields = body.fieldsmap((item: any) => {
const fields = body.fields.map((item: any) => {
const propertiesDto =
createProperties(
item.properties.fieldType,
@ -265,7 +265,7 @@ export class SchemasService {
let nested: NestedFieldDto[] | null = null;
if (item.nested && item.nested.length > 0) {
nested = item.nestedmap((nestedItem: any) => {
nested = item.nested.map((nestedItem: any) => {
const nestedPropertiesDto =
createProperties(
nestedItem.properties.fieldType,

4
src/Squidex/app/shared/services/users-provider.service.ts

@ -6,7 +6,7 @@
*/
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { ConnectableObservable, Observable, of } from 'rxjs';
import { catchError, map, publishLast, share } from 'rxjs/operators';
import { UserDto, UsersService } from './users.service';
@ -34,6 +34,8 @@ export class UsersProviderService {
}),
publishLast());
(<ConnectableObservable<any>>request).connect();
result = this.caches[id] = request;
}

4
src/Squidex/app/shared/state/assets.state.spec.ts

@ -71,6 +71,8 @@ describe('AssetsState', () => {
it('should show notification on load when reload is true', () => {
assetsState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});
@ -110,6 +112,8 @@ describe('AssetsState', () => {
assetsState.goNext().subscribe();
assetsState.goPrev().subscribe();
expect().nothing();
assetsService.verify(x => x.getAssets(app, 30, 30, undefined), Times.once());
assetsService.verify(x => x.getAssets(app, 30, 0, undefined), Times.exactly(2));
});

6
src/Squidex/app/shared/state/backups.state.spec.ts

@ -58,6 +58,8 @@ describe('BackupsState', () => {
it('should show notification on load when reload is true', () => {
backupsState.load(true, false).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});
@ -67,6 +69,8 @@ describe('BackupsState', () => {
backupsState.load(true, true).pipe(onErrorResumeNext()).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyError(It.isAny()), Times.once());
});
@ -76,6 +80,8 @@ describe('BackupsState', () => {
backupsState.load().pipe(onErrorResumeNext()).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyError(It.isAny()), Times.never());
});

2
src/Squidex/app/shared/state/clients.state.spec.ts

@ -64,6 +64,8 @@ describe('ClientsState', () => {
it('should show notification on load when reload is true', () => {
clientsState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});

30
src/Squidex/app/shared/state/contents.forms.spec.ts

@ -209,9 +209,9 @@ describe('BooleanField', () => {
});
it('should return default value for default properties', () => {
Object.assign(field.properties, { defaultValue: true });
const field2 = createField(new BooleanFieldPropertiesDto('Checkbox', { defaultValue: true }));
expect(FieldDefaultValue.get(field)).toBeTruthy();
expect(FieldDefaultValue.get(field2)).toBeTruthy();
});
});
@ -238,27 +238,27 @@ describe('DateTimeField', () => {
});
it('should format to date time', () => {
const dateTimeField = createField(new DateTimeFieldPropertiesDto('DateTime'));
const field2 = createField(new DateTimeFieldPropertiesDto('DateTime'));
expect(FieldFormatter.format(dateTimeField, '2017-12-12T16:00:00Z')).toBe('2017-12-12 16:00:00');
expect(FieldFormatter.format(field2, '2017-12-12T16:00:00Z')).toBe('2017-12-12 16:00:00');
});
it('should return default for DateFieldProperties', () => {
Object.assign(field.properties, { defaultValue: '2017-10-12T16:00:00Z' });
const field2 = createField(new DateTimeFieldPropertiesDto('DateTime', { defaultValue: '2017-10-12T16:00:00Z' }));
expect(FieldDefaultValue.get(field)).toEqual('2017-10-12T16:00:00Z');
expect(FieldDefaultValue.get(field2)).toEqual('2017-10-12T16:00:00Z');
});
it('should return calculated date when Today for DateFieldProperties', () => {
Object.assign(field.properties, { calculatedDefaultValue: 'Today' });
const field2 = createField(new DateTimeFieldPropertiesDto('DateTime', { calculatedDefaultValue: 'Today' }));
expect(FieldDefaultValue.get(field, now)).toEqual('2017-10-12');
expect(FieldDefaultValue.get(field2, now)).toEqual('2017-10-12');
});
it('should return calculated date when Now for DateFieldProperties', () => {
Object.assign(field.properties, { calculatedDefaultValue: 'Now' });
const field2 = createField(new DateTimeFieldPropertiesDto('DateTime', { calculatedDefaultValue: 'Now' }));
expect(FieldDefaultValue.get(field, now)).toEqual('2017-10-12T16:30:10Z');
expect(FieldDefaultValue.get(field2, now)).toEqual('2017-10-12T16:30:10Z');
});
});
@ -314,13 +314,13 @@ describe('NumberField', () => {
});
it('should format to number', () => {
expect(FieldFormatter.format(field, 42)).toBe('42');
expect(FieldFormatter.format(field, 42)).toEqual(<any>42);
});
it('should return default value for default properties', () => {
Object.assign(field.properties, { defaultValue: 13 });
const field2 = createField(new NumberFieldPropertiesDto('Input', { defaultValue: 13 }));
expect(FieldDefaultValue.get(field)).toEqual(13);
expect(FieldDefaultValue.get(field2)).toEqual(13);
});
});
@ -364,9 +364,9 @@ describe('StringField', () => {
});
it('should return default value for default properties', () => {
Object.assign(field.properties, { defaultValue: 'MyDefault' });
const field2 = createField(new StringFieldPropertiesDto('Input', { defaultValue: 'MyDefault' }));
expect(FieldDefaultValue.get(field)).toEqual('MyDefault');
expect(FieldDefaultValue.get(field2)).toEqual('MyDefault');
});
});

2
src/Squidex/app/shared/state/contributors.state.spec.ts

@ -74,6 +74,8 @@ describe('ContributorsState', () => {
it('should show notification on load when reload is true', () => {
contributorsState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});

2
src/Squidex/app/shared/state/languages.state.spec.ts

@ -88,6 +88,8 @@ describe('LanguagesState', () => {
it('should show notification on load when reload is true', () => {
languagesState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});

2
src/Squidex/app/shared/state/patterns.state.spec.ts

@ -62,6 +62,8 @@ describe('PatternsState', () => {
it('should show notification on load when reload is true', () => {
patternsState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});

2
src/Squidex/app/shared/state/plans.state.spec.ts

@ -94,6 +94,8 @@ describe('PlansState', () => {
it('should show notification on load when reload is true', () => {
plansState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});

6
src/Squidex/app/shared/state/rule-events.state.spec.ts

@ -63,6 +63,8 @@ describe('RuleEventsState', () => {
it('should show notification on load when reload is true', () => {
ruleEventsState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});
@ -73,6 +75,8 @@ describe('RuleEventsState', () => {
ruleEventsState.goNext().subscribe();
ruleEventsState.goPrev().subscribe();
expect().nothing();
rulesService.verify(x => x.getEvents(app, 10, 10), Times.once());
rulesService.verify(x => x.getEvents(app, 10, 0), Times.exactly(2));
});
@ -83,6 +87,8 @@ describe('RuleEventsState', () => {
ruleEventsState.enqueue(oldRuleEvents[0]).subscribe();
expect().nothing();
rulesService.verify(x => x.enqueueEvent(app, oldRuleEvents[0].id), Times.once());
});
});

2
src/Squidex/app/shared/state/rules.state.spec.ts

@ -75,6 +75,8 @@ describe('RulesState', () => {
it('should show notification on load when reload is true', () => {
rulesState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});

4
src/Squidex/app/shared/state/schemas.state.spec.ts

@ -114,6 +114,8 @@ describe('SchemasState', () => {
it('should show notification on load when reload is true', () => {
schemasState.load(true).subscribe();
expect().nothing();
dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once());
});
@ -134,6 +136,8 @@ describe('SchemasState', () => {
schemasState.select('name2').subscribe();
schemasService.verify(x => x.getSchema(app, 'name2'), Times.exactly(2));
expect().nothing();
});
it('should return schema on select and load when not loaded', () => {

17232
src/Squidex/package-lock.json

File diff suppressed because it is too large

2
src/Squidex/package.json

@ -29,7 +29,7 @@
"babel-polyfill": "6.26.0",
"bootstrap": "4.1.1",
"core-js": "2.5.7",
"dragula": "^3.7.2",
"dragula": "3.7.2",
"graphiql": "0.11.11",
"moment": "2.22.2",
"mousetrap": "1.6.1",

Loading…
Cancel
Save