Skip to content

Commit

Permalink
fixup! feat: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
suschneider committed Jul 9, 2024
1 parent 20ca24f commit c437f83
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { MockComponent } from 'ng-mocks';
import { of } from 'rxjs';
import { instance, mock, when } from 'ts-mockito';

import { PunchoutFacade } from '../../facades/punchout.facade';
import { PunchoutUser } from '../../models/punchout-user/punchout-user.model';

import { AccountPunchoutCxmlConfigurationPageComponent } from './account-punchout-cxml-configuration-page.component';
import { CxmlConfigurationFormComponent } from './cxml-configuration-form/cxml-configuration-form.component';

describe('Account Punchout Cxml Configuration Page Component', () => {
let component: AccountPunchoutCxmlConfigurationPageComponent;
Expand All @@ -24,7 +22,7 @@ describe('Account Punchout Cxml Configuration Page Component', () => {
when(punchoutFacade.selectedPunchoutUser$).thenReturn(of(user));
await TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()],
declarations: [AccountPunchoutCxmlConfigurationPageComponent, MockComponent(CxmlConfigurationFormComponent)],
declarations: [AccountPunchoutCxmlConfigurationPageComponent],
providers: [{ provide: PunchoutFacade, useFactory: () => instance(punchoutFacade) }],
}).compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Observable, distinctUntilKeyChanged, switchMap } from 'rxjs';

import { HttpError } from 'ish-core/models/http-error/http-error.model';
import { whenTruthy } from 'ish-core/utils/operators';

import { PunchoutFacade } from '../../facades/punchout.facade';
Expand All @@ -16,8 +15,6 @@ import { PunchoutUser } from '../../models/punchout-user/punchout-user.model';
export class AccountPunchoutCxmlConfigurationPageComponent implements OnInit {
selectedUser$: Observable<PunchoutUser>;
cxmlConfiguration$: Observable<CxmlConfiguration[]>;
loading$: Observable<boolean>;
error$: Observable<HttpError>;

constructor(private punchoutFacade: PunchoutFacade) {}

Expand All @@ -28,8 +25,6 @@ export class AccountPunchoutCxmlConfigurationPageComponent implements OnInit {
distinctUntilKeyChanged('id'),
switchMap(user => this.punchoutFacade.cxmlConfiguration$(user.id))
);
this.loading$ = this.punchoutFacade.punchoutLoading$;
this.error$ = this.punchoutFacade.punchoutError$;
}

onUpdateConfiguration(cxmlConfig: CxmlConfiguration[]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormGroup } from '@angular/forms';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { NgbCollapse } from '@ng-bootstrap/ng-bootstrap';
import { FormlyFieldConfig, FormlyModule } from '@ngx-formly/core';
import { MockComponent, MockDirective } from 'ng-mocks';

import { ServerHtmlDirective } from 'ish-core/directives/server-html.directive';
import { FormlyTestingComponentsModule } from 'ish-shared/formly/dev/testing/formly-testing-components.module';
import { FormlyTestingContainerComponent } from 'ish-shared/formly/dev/testing/formly-testing-container/formly-testing-container.component';
import { FormlyTestingFieldgroupExampleComponent } from 'ish-shared/formly/dev/testing/formly-testing-fieldgroup-example/formly-testing-fieldgroup-example.component';
Expand All @@ -26,12 +22,6 @@ describe('Cxml Help Text Wrapper Component', () => {
}),
FormlyTestingComponentsModule,
],
declarations: [
CxmlHelpTextWrapperComponent,
MockComponent(FaIconComponent),
MockDirective(NgbCollapse),
MockDirective(ServerHtmlDirective),
],
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import { cxmlConfigurationActions, cxmlConfigurationApiActions } from './cxml-co

export interface CxmlConfigurationState {
configuration: CxmlConfiguration[];
loading: boolean;
}

const initialState: CxmlConfigurationState = {
configuration: [],
loading: false,
};

export const cxmlConfigurationReducer = createReducer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { StoreWithSnapshots, provideStoreSnapshots } from 'ish-core/utils/dev/ng
import { PunchoutStoreModule } from '../punchout-store.module';

import { cxmlConfigurationActions, cxmlConfigurationApiActions } from './cxml-configuration.actions';
import { getCxmlConfiguration, getCxmlConfigurationLoading } from './cxml-configuration.selectors';
import { getCxmlConfiguration } from './cxml-configuration.selectors';

describe('Cxml Configuration Selectors', () => {
let store$: StoreWithSnapshots;
Expand All @@ -22,10 +22,6 @@ describe('Cxml Configuration Selectors', () => {
});

describe('initial state', () => {
it('should not be loading when in initial state', () => {
expect(getCxmlConfigurationLoading(store$.state)).toBeFalse();
});

it('should not have entities when in initial state', () => {
expect(getCxmlConfiguration(store$.state)).toBeEmpty();
});
Expand All @@ -38,10 +34,6 @@ describe('Cxml Configuration Selectors', () => {
store$.dispatch(action);
});

it('should set loading to true', () => {
expect(getCxmlConfigurationLoading(store$.state)).toBeTrue();
});

describe('loadCXMLConfigurationSuccess', () => {
const successAction = cxmlConfigurationApiActions.loadCXMLConfigurationSuccess({
configuration: [{ name: 'unitmapping', value: '' }],
Expand All @@ -51,10 +43,6 @@ describe('Cxml Configuration Selectors', () => {
store$.dispatch(successAction);
});

it('should set loading to false', () => {
expect(getCxmlConfigurationLoading(store$.state)).toBeFalse();
});

it('should have data when successfully loading', () => {
expect(getCxmlConfiguration(store$.state)).toMatchInlineSnapshot(`
[
Expand All @@ -74,10 +62,6 @@ describe('Cxml Configuration Selectors', () => {
beforeEach(() => {
store$.dispatch(failAction);
});

it('should set loading to false', () => {
expect(getCxmlConfigurationLoading(store$.state)).toBeFalse();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ import { getPunchoutState } from '../punchout-store';
const getCxmlConfigurationState = createSelector(getPunchoutState, state => state.cxmlConfiguration);

export const getCxmlConfiguration = createSelector(getCxmlConfigurationState, state => state.configuration);

export const getCxmlConfigurationLoading = createSelector(getCxmlConfigurationState, state => state.loading);

0 comments on commit c437f83

Please sign in to comment.