Skip to content

Commit

Permalink
Merge branch 'develop-6.7.x' into epic/b2b-commerce-quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
Larisa-Staroverova committed Nov 8, 2023
2 parents 04a681c + 475961e commit 28c27ba
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { StoreModule } from '@ngrx/store';
import { I18nTestingModule } from '@spartacus/core';
import { FeaturesConfigModule, I18nTestingModule } from '@spartacus/core';
import { CONFIGURATOR_FEATURE } from '../../../../core/state/configurator-state';
import { getConfiguratorReducers } from '../../../../core/state/reducers';
import { ItemCounterComponent } from '@spartacus/storefront';
Expand Down Expand Up @@ -101,6 +101,7 @@ describe('ConfigAttributeRadioButtonComponent', () => {
ReactiveFormsModule,
StoreModule.forRoot({}),
StoreModule.forFeature(CONFIGURATOR_FEATURE, getConfiguratorReducers),
FeaturesConfigModule,
],
providers: [
ConfiguratorStorefrontUtilsService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, DebugElement, Input } from '@angular/core';
import { Component, DebugElement, Directive, Input } from '@angular/core';
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { GlobalMessageType, I18nTestingModule } from '@spartacus/core';
Expand All @@ -25,6 +25,13 @@ class MockCxIconComponent {
@Input() type: ICON_TYPE;
}

@Directive({
selector: '[cxAtMessage]',
})
class MockAtMessageDirective {
@Input() cxAtMessage: string | string[] | undefined;
}

describe('MessageComponent', () => {
let component: MessageComponent;
let fixture: ComponentFixture<MessageComponent>;
Expand All @@ -34,7 +41,11 @@ describe('MessageComponent', () => {
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [I18nTestingModule],
declarations: [MessageComponent, MockCxIconComponent],
declarations: [
MessageComponent,
MockCxIconComponent,
MockAtMessageDirective,
],
}).compileComponents();
})
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ChangeDetectionStrategy, DebugElement } from '@angular/core';
import {
ChangeDetectionStrategy,
DebugElement,
Directive,
Input,
} from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ReactiveFormsModule, UntypedFormGroup } from '@angular/forms';
import { By } from '@angular/platform-browser';
Expand Down Expand Up @@ -109,6 +114,13 @@ class MockLaunchDialogService implements Partial<LaunchDialogService> {
}
}

@Directive({
selector: '[cxNgSelectA11y]',
})
class MockNgSelectA11yDirective {
@Input() cxNgSelectA11y: { ariaLabel?: string; ariaControls?: string };
}

describe('AddressFormComponent', () => {
let component: AddressFormComponent;
let fixture: ComponentFixture<AddressFormComponent>;
Expand All @@ -135,7 +147,7 @@ describe('AddressFormComponent', () => {
I18nTestingModule,
FormErrorsModule,
],
declarations: [AddressFormComponent],
declarations: [AddressFormComponent, MockNgSelectA11yDirective],
providers: [
{ provide: LaunchDialogService, useClass: MockLaunchDialogService },
{ provide: UserService, useClass: MockUserService },
Expand Down Expand Up @@ -283,13 +295,16 @@ describe('AddressFormComponent', () => {
});

it('should emit submitAddress if dialog was closed with selected address as parameter', () => {
spyOn(launchDialogService, 'openDialogAndSubscribe');
const mockAddressVerificationResult: AddressValidation = {
decision: 'REVIEW',
};
dialogClose$.next(mockAddress);

component.openSuggestedAddress(mockAddressVerificationResult);

expect(launchDialogService.openDialogAndSubscribe).toHaveBeenCalled();

component.submitAddress.pipe(take(1)).subscribe((address) => {
expect(address).toEqual(mockAddress);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { Address, I18nTestingModule } from '@spartacus/core';
import { LaunchDialogService } from '../../../../../layout';
import { FocusDirective, LaunchDialogService } from '../../../../../layout';
import { of } from 'rxjs';
import { take } from 'rxjs/operators';
import { ICON_TYPE } from '../../../../misc/index';
Expand Down Expand Up @@ -41,7 +41,11 @@ describe('SuggestedAddressDialogComponent', () => {
providers: [
{ provide: LaunchDialogService, useClass: MockLaunchDialogService },
],
declarations: [SuggestedAddressDialogComponent, MockCxIconComponent],
declarations: [
SuggestedAddressDialogComponent,
MockCxIconComponent,
FocusDirective,
],
}).compileComponents();
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Observable, of } from 'rxjs';
import { ICON_TYPE } from '../../../../../cms-components/misc/icon/index';
import { LaunchDialogService } from '../../../../../layout/index';
import { CouponDialogComponent } from './coupon-dialog.component';
import { FocusDirective } from '@spartacus/storefront';

const mockCoupon: CustomerCoupon = {
couponId: 'CustomerCoupon',
Expand Down Expand Up @@ -41,7 +42,11 @@ describe('CouponDialogComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [CouponDialogComponent, MockCxIconComponent],
declarations: [
CouponDialogComponent,
MockCxIconComponent,
FocusDirective,
],
imports: [I18nTestingModule],
providers: [
{ provide: LaunchDialogService, useClass: MockLaunchDialogService },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Component,
DebugElement,
Directive,
EventEmitter,
Input,
Output,
Expand Down Expand Up @@ -89,6 +90,13 @@ class MockGlobalMessageService implements Partial<GlobalMessageService> {
})
class MockSpinnerComponent {}

@Directive({
selector: '[cxAtMessage]',
})
class MockAtMessageDirective {
@Input() cxAtMessage: string | string[] | undefined;
}

const p553637$: Observable<Product> = of({
code: '553637',
name: 'NV10',
Expand Down Expand Up @@ -222,6 +230,7 @@ describe('MyInterestsComponent', () => {
MockPaginationComponent,
MockSortingComponent,
MockFeatureLevelDirective,
MockAtMessageDirective,
],
}).compileComponents();
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, DebugElement, Input } from '@angular/core';
import { Component, DebugElement, Directive, Input } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import {
Expand All @@ -13,6 +13,7 @@ import { EMPTY, Observable, of } from 'rxjs';
import { ICON_TYPE } from '../../../cms-components/misc/icon';
import { CardComponent } from '../../../shared/components/card/card.component';
import { PaymentMethodsComponent } from './payment-methods.component';
import { FocusDirective } from '@spartacus/storefront';

class MockGlobalMessageService {
add = jasmine.createSpy();
Expand All @@ -24,6 +25,13 @@ class MockGlobalMessageService {
})
class MockCxSpinnerComponent {}

@Directive({
selector: '[cxAtMessage]',
})
class MockAtMessageDirective {
@Input() cxAtMessage: string | string[] | undefined;
}

const mockPayment: PaymentDetails = {
defaultPayment: true,
accountHolderName: 'John Doe',
Expand Down Expand Up @@ -71,6 +79,8 @@ describe('PaymentMethodsComponent', () => {
MockCxSpinnerComponent,
CardComponent,
MockCxIconComponent,
MockAtMessageDirective,
FocusDirective,
],
providers: [
{ provide: UserPaymentService, useClass: MockUserPaymentService },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Component,
Directive,
Injector,
Input,
Expand Down Expand Up @@ -39,6 +40,16 @@ class MockOutletDirective implements Partial<OutletDirective> {
@Input() cxOutlet: string;
}

@Component({
selector: 'cx-media',
template: '<img>',
})
class MockMediaComponent {
@Input() container: any;
@Input() format: string;
@Input() alt: string;
}

describe('ProductCarouselItemComponent in product-carousel', () => {
let component: ProductCarouselItemComponent;
let componentInjector: Injector;
Expand Down Expand Up @@ -69,6 +80,7 @@ describe('ProductCarouselItemComponent in product-carousel', () => {
ProductCarouselItemComponent,
MockUrlPipe,
MockOutletDirective,
MockMediaComponent,
],
providers: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Observable, of } from 'rxjs';
import { By } from '@angular/platform-browser';
import { UrlTestingModule } from 'projects/core/src/routing/configurable-routes/url-translation/testing/url-testing.module';
import { LaunchDialogService } from '../../../../layout/launch-dialog/services/index';
import { FocusDirective } from '@spartacus/storefront';

describe('StockNotificationDialogComponent', () => {
let component: StockNotificationDialogComponent;
Expand Down Expand Up @@ -44,7 +45,7 @@ describe('StockNotificationDialogComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [StockNotificationDialogComponent],
declarations: [StockNotificationDialogComponent, FocusDirective],
imports: [
I18nTestingModule,
RouterTestingModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { StockNotificationComponent } from './stock-notification.component';

import { LAUNCH_CALLER } from '../../../layout/launch-dialog/config/index';
import { LaunchDialogService } from '../../../layout/launch-dialog/services/index';
import { FocusDirective } from '@spartacus/storefront';

class MockLaunchDialogService implements Partial<LaunchDialogService> {
openDialog(
Expand Down Expand Up @@ -125,6 +126,7 @@ describe('StockNotificationComponent', () => {
StockNotificationComponent,
StockNotificationDialogComponent,
MockUrlPipe,
FocusDirective,
],
providers: [
{ provide: UserIdService, useValue: userIdService },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { By } from '@angular/platform-browser';
import { I18nTestingModule } from '@spartacus/core';
import { ICON_TYPE } from '../../../cms-components/misc/index';
import { Card, CardComponent, CardLinkAction } from './card.component';
import { FocusDirective } from '@spartacus/storefront';

@Directive({
selector: '[cxAtMessage]',
Expand Down Expand Up @@ -52,9 +53,9 @@ describe('CardComponent', () => {
imports: [I18nTestingModule],
declarations: [
CardComponent,
MockAtMessageDirective,
MockFocusDirective,
MockCxIconComponent,
MockAtMessageDirective,
FocusDirective,
MockCxTruncateTextPopoverComponent,
],
}).compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { IconModule } from '../../../../cms-components';
import { FileUploadModule, FormErrorsModule } from '../../form';
import { MessagingComponent } from './messaging.component';
import { Item, MessageEvent, MessagingConfigs } from './messaging.model';
import { AvatarComponent } from '@spartacus/storefront';

const mockMessageEvent: MessageEvent = {
rightAlign: false,
Expand Down Expand Up @@ -46,7 +47,7 @@ describe('MessagingComponent', () => {
FormErrorsModule,
ReactiveFormsModule,
],
declarations: [MessagingComponent],
declarations: [MessagingComponent, AvatarComponent],
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ import { SortingComponent } from './sorting.component';
import { NgSelectModule } from '@ng-select/ng-select';
import { FormsModule } from '@angular/forms';
import { I18nTestingModule } from '@spartacus/core';
import { Directive, Input } from '@angular/core';

describe('SortingComponent', () => {
@Directive({
selector: '[cxNgSelectA11y]',
})
class MockNgSelectA11yDirective {
@Input() cxNgSelectA11y: { ariaLabel?: string; ariaControls?: string };
}

let component: SortingComponent;
let fixture: ComponentFixture<SortingComponent>;

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [NgSelectModule, FormsModule, I18nTestingModule],
declarations: [SortingComponent],
declarations: [SortingComponent, MockNgSelectA11yDirective],
}).compileComponents();
})
);
Expand Down

0 comments on commit 28c27ba

Please sign in to comment.