Skip to content

Commit

Permalink
WIP (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
fulls1z3 committed Mar 19, 2019
1 parent 00072f3 commit b4c8070
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ t.describe('AirlineDetailContainerComponent', () => {

t.it('should `getSelected` from AirlineSelectors on init', () => {
const fixture = TestBed.createComponent(AirlineDetailContainerComponent);
const instance = fixture.componentInstance;
const store$ = TestBed.get(Store);
const state = getState<Airline>(AIRLINE, MOCK_AIRLINE);
store$.setState(state);
fixture.detectChanges();

const actual = fixture.componentInstance.airline$;
const expected = cold('a', { a: MOCK_AIRLINE });

t.e(instance.airline$).toBeObservable(expected);
t.e(actual).toBeObservable(expected);
});

t.it('should dispatch `airUniversalAddOneAirline` action on init', () => {
Expand All @@ -93,7 +93,6 @@ t.describe('AirlineDetailContainerComponent', () => {

t.it('should dispatch `airUniversalCreateOneAirline` action on save', () => {
const fixture = TestBed.createComponent(AirlineDetailContainerComponent);
const instance = fixture.componentInstance;
const store$ = TestBed.get(Store);
const spy = t.spyOn(store$, 'dispatch');
fixture.detectChanges();
Expand All @@ -107,6 +106,7 @@ t.describe('AirlineDetailContainerComponent', () => {
saveClick.emit(MOCK_AIRLINE);

const router = fixture.debugElement.injector.get(Router);
const instance = fixture.componentInstance;
const action = airlineActions.airUniversalCreateOneAirline({
resource,
router,
Expand Down Expand Up @@ -137,7 +137,6 @@ t.describe('AirlineDetailContainerComponent for renderFlag=`Update`', () => {

t.it('should dispatch `airUniversalUpdateOneAirline` action on save', () => {
const fixture = TestBed.createComponent(AirlineDetailContainerComponent);
const instance = fixture.componentInstance;
const store$ = TestBed.get(Store);
const spy = t.spyOn(store$, 'dispatch');
fixture.detectChanges();
Expand All @@ -150,6 +149,7 @@ t.describe('AirlineDetailContainerComponent for renderFlag=`Update`', () => {
saveClick.emit(MOCK_AIRLINE);

const router = fixture.debugElement.injector.get(Router);
const instance = fixture.componentInstance;
const action = airlineActions.airUniversalUpdateOneAirline({
resource: MOCK_AIRLINE,
router,
Expand All @@ -162,7 +162,6 @@ t.describe('AirlineDetailContainerComponent for renderFlag=`Update`', () => {

t.it('should dispatch `airUniversalDeleteOneAirline` action on delete', () => {
const fixture = TestBed.createComponent(AirlineDetailContainerComponent);
const instance = fixture.componentInstance;
const store$ = TestBed.get(Store);
const spy = t.spyOn(store$, 'dispatch');
fixture.detectChanges();
Expand All @@ -175,6 +174,7 @@ t.describe('AirlineDetailContainerComponent for renderFlag=`Update`', () => {
deleteClick.emit(MOCK_AIRLINE._id);

const router = fixture.debugElement.injector.get(Router);
const instance = fixture.componentInstance;
const action = airlineActions.airUniversalDeleteOneAirline({
id: MOCK_AIRLINE._id,
router,
Expand Down
4 changes: 2 additions & 2 deletions src/app/+air-universal/airline/airline.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ t.describe('AirlineComponent', () => {

t.it('should `getMany` from AirlineSelectors on init', () => {
const fixture = TestBed.createComponent(AirlineComponent);
const instance = fixture.componentInstance;
const store$ = TestBed.get(Store);
const state = getState<Airline>(AIRLINE, MOCK_AIRLINE);
store$.setState(state);
fixture.detectChanges();

const actual = fixture.componentInstance.airlines$;
const expected = cold('a', { a: [MOCK_AIRLINE] });

t.e(instance.airlines$).toBeObservable(expected);
t.e(actual).toBeObservable(expected);
});

t.it('should dispatch `airUniversalGetManyAirlines` action on init', () => {
Expand Down
1 change: 0 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = { supp
],
declarations: [HeaderComponent, MainComponent, LoginComponent, AppComponent],
providers: [
// I18N_ROUTER_PROVIDERS
{
provide: PERFECT_SCROLLBAR_CONFIG,
useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG
Expand Down
21 changes: 15 additions & 6 deletions src/app/framework/analytics/analytics.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ t.describe('AnalyticsService', () => {
label: 'Testing'
});

const actual = angulartics.eventTrack;
const expected = cold('c', {
c: {
action: 'click',
Expand All @@ -40,7 +41,7 @@ t.describe('AnalyticsService', () => {
}
});

t.e(angulartics.eventTrack).toBeObservable(expected);
t.e(actual).toBeObservable(expected);
})
);

Expand All @@ -54,7 +55,9 @@ t.describe('AnalyticsService', () => {
label: 'Testing'
});

t.e((angulartics.eventTrack as any)._events).not.toHaveProperty('value');
const actual = (angulartics.eventTrack as any)._events;

t.e(actual).not.toHaveProperty('value');
})
);

Expand All @@ -64,13 +67,14 @@ t.describe('AnalyticsService', () => {
analyticsService.devMode(false);
analyticsService.pageTrack('/testing');

const actual = angulartics.pageTrack;
const expected = cold('c', {
c: {
path: '/testing'
}
});

t.e(angulartics.pageTrack).toBeObservable(expected);
t.e(actual).toBeObservable(expected);
})
);

Expand All @@ -81,7 +85,9 @@ t.describe('AnalyticsService', () => {
analyticsService.devMode(true);
analyticsService.pageTrack('/testing');

t.e((angulartics.pageTrack as any)._events).not.toHaveProperty('value');
const actual = (angulartics.pageTrack as any)._events;

t.e(actual).not.toHaveProperty('value');
})
);

Expand All @@ -95,6 +101,7 @@ t.describe('AnalyticsService', () => {
email: 'name@domain.com'
});

const actual = angulartics.setUserProperties;
const expected = cold('c', {
c: {
userId: 1,
Expand All @@ -103,7 +110,7 @@ t.describe('AnalyticsService', () => {
}
});

t.e(angulartics.setUserProperties).toBeObservable(expected);
t.e(actual).toBeObservable(expected);
})
);

Expand All @@ -118,7 +125,9 @@ t.describe('AnalyticsService', () => {
email: 'name@domain.com'
});

t.e((angulartics.setUserProperties as any)._events).not.toHaveProperty('value');
const actual = (angulartics.setUserProperties as any)._events;

t.e(actual).not.toHaveProperty('value');
})
);
});
Expand Down
8 changes: 4 additions & 4 deletions src/app/framework/http/base-url.interceptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ t.describe('getBaseUrl for `server` platform', () => {
t.describe('BaseUrlInterceptor', () => {
t.it(
'should build without a problem',
t.inject([BaseUrlInterceptor], (interceptor: BaseUrlInterceptor) => {
t.e(interceptor).toBeTruthy();
t.inject([BaseUrlInterceptor], (instance: BaseUrlInterceptor) => {
t.e(instance).toBeTruthy();
})
);

Expand All @@ -71,10 +71,10 @@ t.describe('BaseUrlInterceptor', () => {
t.e(res).toBeTruthy();
});

const actual = http.expectOne({ method: 'GET' });
const { request } = http.expectOne({ method: 'GET' });
const expected = 'http://localhost:4200/test';

t.e(actual.request.url).toEqual(expected);
t.e(request.url).toEqual(expected);

http.verify();
})
Expand Down
11 changes: 7 additions & 4 deletions src/app/framework/http/universal.interceptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ t.describe('getAbsolutePath for `browser` platform', () => {
t.it('should bypass the request', () => {
const request = new HttpRequest<any>('GET', './test');
const res = getAbsolutePath(MOCK_REQUEST)(request)(false);

const expected = './test';

t.e(res.url).toEqual(expected);
Expand All @@ -64,6 +65,7 @@ t.describe('getAbsolutePath for `server` platform', () => {
t.it('should return an intercepted request with `baseServerUrl`', () => {
const request = new HttpRequest<any>('GET', './test');
const res = getAbsolutePath(MOCK_REQUEST)(request)(true);

const expected = `${MOCK_BASE_URL}/test`;

t.e(res.url).toEqual(expected);
Expand All @@ -72,6 +74,7 @@ t.describe('getAbsolutePath for `server` platform', () => {
t.it('should bypass the request when the request has absolute url', () => {
const request = new HttpRequest<any>('GET', `${MOCK_BASE_URL}/test`);
const res = getAbsolutePath(MOCK_REQUEST)(request)(true);

const expected = `${MOCK_BASE_URL}/test`;

t.e(res.url).toEqual(expected);
Expand All @@ -81,8 +84,8 @@ t.describe('getAbsolutePath for `server` platform', () => {
t.describe('UniversalInterceptor', () => {
t.it(
'should build without a problem',
t.inject([UniversalInterceptor], (interceptor: UniversalInterceptor) => {
t.e(interceptor).toBeTruthy();
t.inject([UniversalInterceptor], (instance: UniversalInterceptor) => {
t.e(instance).toBeTruthy();
})
);

Expand All @@ -94,10 +97,10 @@ t.describe('UniversalInterceptor', () => {
t.e(res).toBeTruthy();
});

const actual = http.expectOne({ method: 'GET' });
const { request } = http.expectOne({ method: 'GET' });
const expected = './test';

t.e(actual.request.url).toEqual(expected);
t.e(request.url).toEqual(expected);

http.verify();
})
Expand Down
40 changes: 26 additions & 14 deletions src/app/framework/i18n/i18n.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ t.describe('I18NService', () => {

t.it(
'should build without a problem',
t.inject([I18NService], (i18n: I18NService) => {
t.e(i18n).toBeTruthy();
t.inject([I18NService], (instance: I18NService) => {
t.e(instance).toBeTruthy();
})
);

Expand Down Expand Up @@ -74,9 +74,9 @@ t.describe('I18NService w/o init', () => {
t.it(
'should get `undefined` (by code)',
t.inject([I18NService], (i18n: I18NService) => {
const language = i18n.getLanguageByCode('en');
const actual = i18n.getLanguageByCode('en');

t.e(language).toBeUndefined();
t.e(actual).toBeUndefined();
})
);
});
Expand All @@ -91,9 +91,9 @@ t.describe('I18NService for `server` platform', () => {
t.inject([I18NService], (i18n: I18NService) => {
i18n.defaultLanguage = MOCK_DEFAULT_LANGUAGE;

const languageCode = i18n.getLanguageCodeFromBrowser();
const actual = i18n.getLanguageCodeFromBrowser();

t.e(languageCode).toEqual('en');
t.e(actual).toEqual('en');
})
);
});
Expand All @@ -103,13 +103,19 @@ t.describe('I18NService for `fr` browser', () => {
testModuleConfig({ window: MockWindowFrench });
});

t.it(
'should support `french` by default (window)',
t.inject([WindowService], (win: WindowService) => {
t.e(win.navigator.language).toEqual('fr-FR');
})
);

t.it(
'should support `french` by default',
t.inject([I18NService, WindowService], (i18n: I18NService, win: WindowService) => {
const languageCode = i18n.getLanguageCodeFromBrowser();
t.inject([I18NService, WindowService], (i18n: I18NService) => {
const actual = i18n.getLanguageCodeFromBrowser();

t.e(win.navigator.language).toEqual('fr-FR');
t.e(languageCode).toEqual('fr');
t.e(actual).toEqual('fr');
})
);
});
Expand All @@ -119,15 +125,21 @@ t.describe('I18NService for browser w/o language', () => {
testModuleConfig({ window: MockWindowNoLanguage });
});

t.it(
'should support `english` by default (window)',
t.inject([WindowService], (win: WindowService) => {
t.e(win.navigator.language).toBeUndefined();
})
);

t.it(
'should support `english` by default',
t.inject([I18NService, WindowService], (i18n: I18NService, win: WindowService) => {
t.inject([I18NService], (i18n: I18NService) => {
i18n.defaultLanguage = MOCK_DEFAULT_LANGUAGE;

const languageCode = i18n.getLanguageCodeFromBrowser();
const actual = i18n.getLanguageCodeFromBrowser();

t.e(win.navigator.language).toBeUndefined();
t.e(languageCode).toEqual('en');
t.e(actual).toEqual('en');
})
);
});
4 changes: 2 additions & 2 deletions src/app/framework/ngrx/base-entity.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ t.describe('BaseEntityService', () => {

t.it(
'should build without a problem',
t.inject([MockEntityService], (entity: MockEntityService) => {
t.e(entity).toBeTruthy();
t.inject([MockEntityService], (instance: MockEntityService) => {
t.e(instance).toBeTruthy();
})
);

Expand Down

0 comments on commit b4c8070

Please sign in to comment.