Skip to content

Commit

Permalink
Merge pull request NationalBankBelgium#1089 from SuperITMan/bugfix/st…
Browse files Browse the repository at this point in the history
…ark-ui-hammerjs-warnings

test(stark-ui): mock HammerJS in some stark-ui tests to remove useless warnings about HammerJS support
  • Loading branch information
christophercr authored Feb 1, 2019
2 parents c556475 + f196aee commit 7ebcd5a
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"test:starter": "cd starter && npm run test-fast && cd ../..",
"test:starter:e2e": "cd starter && npm run e2e && cd ../..",
"test:starter:e2e:browserstack": "cd starter && npm run e2e:browserstack && cd ../..",
"test:ci:all": "npm run test:ci:stark-core && npm run test:ci:stark-ui && npm run test:ci:starter && npm run test:ci:starter",
"test:ci:all": "npm run test:ci:stark-core && npm run test:ci:stark-ui && npm run test:ci:starter && npm run test:ci:showcase",
"test:ci:stark-core": "cd packages/stark-core && npm run test-fast:ci && cd ../..",
"test:ci:stark-ui": "cd packages/stark-ui && npm run test-fast:ci && cd ../..",
"test:ci:showcase": "cd showcase && npm run test-fast:ci && cd ../..",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { async, ComponentFixture, TestBed } from "@angular/core/testing";
import { MatButtonModule } from "@angular/material/button";
import { MatMenuModule } from "@angular/material/menu";
import { MatTooltipModule } from "@angular/material/tooltip";
import { HAMMER_LOADER } from "@angular/platform-browser";
import { STARK_LOGGING_SERVICE, STARK_ROUTING_SERVICE } from "@nationalbankbelgium/stark-core";
import { MockStarkLoggingService, MockStarkRoutingService } from "@nationalbankbelgium/stark-core/testing";
import { Subject } from "rxjs";
import { StarkSvgViewBoxModule } from "../../svg-view-box/svg-view-box.module";
import { StarkActionBarComponent } from "./action-bar.component";
import { StarkActionBarConfig } from "./action-bar-config.intf";
Expand All @@ -24,7 +26,12 @@ describe("ActionBarComponent", () => {
providers: [
{ provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() },
{ provide: STARK_ROUTING_SERVICE, useClass: MockStarkRoutingService },
TranslateService
TranslateService,
{
// See https://github.com/NationalBankBelgium/stark/issues/1088
provide: HAMMER_LOADER,
useValue: () => new Subject<any>().toPromise()
}
],
schemas: [NO_ERRORS_SCHEMA] // tells the Angular compiler to ignore unrecognized elements and attributes (svgIcon)
}).compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import {
import { MockStarkLoggingService, MockStarkRoutingService, MockStarkSessionService } from "@nationalbankbelgium/stark-core/testing";
import { StarkAppLogoutComponent } from "./app-logout.component";
import { StarkSvgViewBoxModule } from "../../svg-view-box/svg-view-box.module";
import { MatTooltipModule } from "@angular/material/tooltip";
import { MatButtonModule } from "@angular/material/button";
import { MatTooltipModule } from "@angular/material/tooltip";
import { HAMMER_LOADER } from "@angular/platform-browser";
import { TranslateModule } from "@ngx-translate/core";
import { Subject } from "rxjs";
import Spy = jasmine.Spy;

describe("AppLogoutComponent", () => {
Expand All @@ -37,7 +39,12 @@ describe("AppLogoutComponent", () => {
{ provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() },
{ provide: STARK_SESSION_SERVICE, useValue: new MockStarkSessionService() },
{ provide: STARK_ROUTING_SERVICE, useClass: MockStarkRoutingService },
{ provide: STARK_SESSION_CONFIG, useValue: mockStarkSessionConfig }
{ provide: STARK_SESSION_CONFIG, useValue: mockStarkSessionConfig },
{
// See https://github.com/NationalBankBelgium/stark/issues/1088
provide: HAMMER_LOADER,
useValue: () => new Subject<any>().toPromise()
}
],
schemas: [NO_ERRORS_SCHEMA] // tells the Angular compiler to ignore unrecognized elements and attributes (svgIcon)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe("AppSidebarComponent", () => {
}
);

mockBreakPointObserver = jasmine.createSpyObj("BreakPointObserver", ["isMatched", "observe"]);
mockBreakPointObserver = jasmine.createSpyObj("BreakPointObserver", ["isMatched", "observe", "ngOnDestroy"]);
// add functionality to the `observe` Spy
mockBreakPointObserver.observe.and.callFake((value: string | string[]) => {
expect([[BREAKPOINT_STRING], BREAKPOINT_STRING]).toContain(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { StarkMinimapComponent } from "./minimap.component";
import { StarkMinimapItemProperties } from "./item-properties.intf";
import { async, ComponentFixture, TestBed } from "@angular/core/testing";
import { FormsModule } from "@angular/forms";
import { HAMMER_LOADER } from "@angular/platform-browser";
import { NoopAnimationsModule } from "@angular/platform-browser/animations";
import { TranslateModule, TranslateService } from "@ngx-translate/core";
import { STARK_LOGGING_SERVICE } from "@nationalbankbelgium/stark-core";
import { MockStarkLoggingService } from "@nationalbankbelgium/stark-core/testing";
import { Component, EventEmitter, NO_ERRORS_SCHEMA, ViewChild } from "@angular/core";
import { MatCheckboxModule } from "@angular/material/checkbox";
import { MatTooltipModule } from "@angular/material/tooltip";
import { Subject } from "rxjs";
import { ItemVisibility } from "./item-visibility.intf";
import createSpyObj = jasmine.createSpyObj;
import SpyObj = jasmine.SpyObj;
Expand Down Expand Up @@ -39,7 +41,15 @@ describe("MinimapComponent", () => {
return TestBed.configureTestingModule({
imports: [FormsModule, MatCheckboxModule, MatTooltipModule, NoopAnimationsModule, TranslateModule.forRoot()],
declarations: [StarkMinimapComponent, TestHostComponent],
providers: [{ provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() }, TranslateService],
providers: [
{ provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() },
TranslateService,
{
// See https://github.com/NationalBankBelgium/stark/issues/1088
provide: HAMMER_LOADER,
useValue: () => new Subject<any>().toPromise()
}
],
schemas: [NO_ERRORS_SCHEMA] // to avoid errors due to "mat-icon" directive not known (which we don't want to add in these tests)
}).compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { MatFormFieldModule } from "@angular/material/form-field";
import { MatAutocompleteModule } from "@angular/material/autocomplete";
import { MatSelectModule } from "@angular/material/select";
import { MatOptionModule } from "@angular/material/core";
import { HAMMER_LOADER } from "@angular/platform-browser";
import { TranslateModule, TranslateService } from "@ngx-translate/core";
import { Ng2StateDeclaration, StateDeclaration } from "@uirouter/angular";
import {
Expand All @@ -24,7 +25,7 @@ import { MockStarkLoggingService, MockStarkRoutingService } from "@nationalbankb
import { StarkRouteSearchComponent } from "./route-search.component";
import { StarkRouteSearchEntry } from "../components/route-search-entry.intf";
import { StarkMenuConfig, StarkMenuGroup } from "../../app-menu";
import { of, throwError } from "rxjs";
import { of, Subject, throwError } from "rxjs";
import { mergeUiTranslations } from "../../../common/translations/merge-translations";
import Spy = jasmine.Spy;

Expand Down Expand Up @@ -110,7 +111,12 @@ describe("RouteSearchComponent", () => {
declarations: [StarkRouteSearchComponent, TestHostComponent],
providers: [
{ provide: STARK_ROUTING_SERVICE, useValue: mockRoutingService },
{ provide: STARK_LOGGING_SERVICE, useValue: mockLoggingService }
{ provide: STARK_LOGGING_SERVICE, useValue: mockLoggingService },
{
// See https://github.com/NationalBankBelgium/stark/issues/1088
provide: HAMMER_LOADER,
useValue: () => new Subject<any>().toPromise()
}
],
schemas: [NO_ERRORS_SCHEMA] // to avoid errors due to "mat-icon" directive not known (which we don't want to add in these tests)
}).compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import { MatCheckboxModule } from "@angular/material/checkbox";
import { MatTooltipModule } from "@angular/material/tooltip";
import { MatPaginatorModule } from "@angular/material/paginator";
import { MatDialogModule } from "@angular/material/dialog";
import { StarkTableMultisortDialogComponent } from "./dialogs/multisort.component";
import { MatSelectModule } from "@angular/material/select";
import { MatInputModule } from "@angular/material/input";
import { HAMMER_LOADER } from "@angular/platform-browser";
import { TranslateModule, TranslateService } from "@ngx-translate/core";
import { STARK_LOGGING_SERVICE } from "@nationalbankbelgium/stark-core";
import { MockStarkLoggingService } from "@nationalbankbelgium/stark-core/testing";
import { Subject } from "rxjs";
import { StarkTableMultisortDialogComponent } from "./dialogs/multisort.component";
import { StarkTableComponent } from "./table.component";
import { StarkTableColumnComponent } from "./column.component";
import { StarkPaginationComponent } from "../../pagination/components";
Expand Down Expand Up @@ -101,7 +103,15 @@ describe("TableComponent", () => {
StarkTableMultisortDialogComponent,
TestHostComponent
],
providers: [{ provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() }, TranslateService],
providers: [
{ provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() },
TranslateService,
{
// See https://github.com/NationalBankBelgium/stark/issues/1088
provide: HAMMER_LOADER,
useValue: () => new Subject<any>().toPromise()
}
],
schemas: [NO_ERRORS_SCHEMA] // to avoid errors due to "mat-icon" directive not known (which we don't want to add in these tests)
}).compileComponents();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { async, ComponentFixture, TestBed } from "@angular/core/testing";
import { MatButtonModule } from "@angular/material/button";
import { MatTabsModule } from "@angular/material/tabs";
import { MatTooltipModule } from "@angular/material/tooltip";
import { HAMMER_LOADER } from "@angular/platform-browser";
import { Observable, of, Subject, throwError } from "rxjs";
import { delay, filter } from "rxjs/operators";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core";
Expand All @@ -30,6 +31,11 @@ describe("ExampleViewerComponent", () => {
{
provide: FileService,
useValue: jasmine.createSpyObj("FileServiceSpy", ["fetchFile"])
},
{
// See https://github.com/NationalBankBelgium/stark/issues/1088
provide: HAMMER_LOADER,
useValue: () => new Subject<any>().toPromise()
}
],
schemas: [NO_ERRORS_SCHEMA] // tells the Angular compiler to ignore unrecognized elements and attributes: mat-icon
Expand Down

0 comments on commit 7ebcd5a

Please sign in to comment.