Skip to content

Commit

Permalink
refactor(eslint): code adaptions to respect "no-negated-async" rule
Browse files Browse the repository at this point in the history
  • Loading branch information
SGrueber authored and MaxKless committed Jan 17, 2022
1 parent 6194435 commit c98c4d1
Show file tree
Hide file tree
Showing 25 changed files with 45 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ish-error-message [error]="error$ | async"></ish-error-message>
<ish-info-box heading="account.requisitions.widget.budget_title" class="infobox-wrapper" cssClass="infobox-widget">
<div class="loading-container">
<div *ngIf="!(budgetLoading$ | async); else loading">
<div *ngIf="(budgetLoading$ | async) !== true; else loading">
<div class="row">
<div class="col-12">
<ish-user-budget progressBarClass="background-inverse" [budget]="userBudget$ | async"></ish-user-budget>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ish-info-box heading="account.costcenter.widget.title" class="infobox-wrapper" cssClass="infobox-widget">
<div class="loading-container">
<div *ngIf="!(loading$ | async); else loading">
<div *ngIf="(loading$ | async) !== true; else loading">
<ng-container *ngIf="costCenters$ | async as costCenters; else emptyList">
<ng-container *ngIf="costCenters.length; else emptyList">
<ng-container *ngFor="let cc of costCenters$ | async">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h1>{{ 'account.costcenter.details.buyers.heading' | translate }}</h1>
</div>
</ng-container>
<ng-template #emptyList>
<p *ngIf="!(error$ | async)" data-testing-id="empty-buyer-list">
<p *ngIf="!!(error$ | async) === false" data-testing-id="empty-buyer-list">
{{ 'account.costcenter.details.add.buyers.list.empty' | translate }}
</p>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<h1>
{{ 'account.organization.cost_center_management' | translate }}
<a *ngIf="!(error$ | async)" routerLink="create" class="btn btn-secondary" data-testing-id="add-cost-center-link">{{
'account.costcenter.list.link.add' | translate
}}</a>
<a
*ngIf="!!(error$ | async) === false"
routerLink="create"
class="btn btn-secondary"
data-testing-id="add-cost-center-link"
>{{ 'account.costcenter.list.link.add' | translate }}</a
>
</h1>

<div class="loading-container">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<h1>
{{ 'account.organization.user_management' | translate }}
<a *ngIf="!(error$ | async)" routerLink="create" class="btn btn-secondary" data-testing-id="add-user-link">{{
'account.user.list.link.add_user' | translate
}}</a>
<a
*ngIf="!!(error$ | async) === false"
routerLink="create"
class="btn btn-secondary"
data-testing-id="add-user-link"
>{{ 'account.user.list.link.add_user' | translate }}</a
>
</h1>

<ish-error-message [error]="error$ | async"></ish-error-message>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cssClass="infobox-color-widget d-flex flex-column"
>
<div class="loading-container mt-auto">
<div *ngIf="!(requisitionsLoading$ | async); else loading">
<div *ngIf="(requisitionsLoading$ | async) !== true; else loading">
<div class="row align-items-end">
<div class="col">
<div class="infobox-count-large" data-testing-id="pending-counter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cssClass="infobox-color-widget d-flex flex-column"
>
<div class="loading-container mt-auto">
<div *ngIf="!(requisitionsLoading$ | async); else loading">
<div *ngIf="(requisitionsLoading$ | async) !== true; else loading">
<div class="row align-items-end">
<div class="col">
<div class="infobox-count-large" data-testing-id="pending-counter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cssClass="infobox-color-widget d-flex flex-column"
>
<div class="loading-container">
<div *ngIf="!(loading$ | async); else loading" class="pb-2">
<div *ngIf="(loading$ | async) !== true; else loading" class="pb-2">
<ng-container *ngIf="orderTemplates$ | async as orderTemplates; else emptyList">
<ng-container *ngIf="orderTemplates.length; else emptyList">
<div *ngFor="let orderTemplate of orderTemplates" class="mb-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('Order Template Widget Component', () => {
beforeEach(async () => {
orderTemplatesFacade = mock(OrderTemplatesFacade);
when(orderTemplatesFacade.orderTemplates$).thenReturn(of(orderTemplates));
when(orderTemplatesFacade.orderTemplateLoading$).thenReturn(of(false));

await TestBed.configureTestingModule({
imports: [RouterTestingModule, TranslateModule.forRoot()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<ng-template #quotePending>
<ish-info-message
*ngIf="state === 'Responded' && !(isQuoteStarted$ | async)"
*ngIf="state === 'Responded' && (isQuoteStarted$ | async) === false"
message="quote.error.not_started"
[toast]="false"
></ish-info-message>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cssClass="infobox-color-widget d-flex flex-column"
>
<div class="loading-container mt-auto">
<div *ngIf="!(loading$ | async); else loading">
<div *ngIf="(loading$ | async) !== true; else loading">
<div class="row align-items-end no-gutters">
<div class="col">
<div class="infobox-count" data-testing-id="responded-counter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Quote Widget Component', () => {
beforeEach(async () => {
quotingFacade = mock(QuotingFacade);
when(quotingFacade.quotingEntities$()).thenReturn(of([]));
when(quotingFacade.loading$).thenReturn(of(false));

await TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1>{{ 'checkout.shipping.pagetitle' | translate }}</h1>
<div class="col-md-12 col-lg-8">
<div class="section" *ngIf="shippingMethods$ | async as shippingMethods">
<div *ngIf="shippingMethods.length; else noShippingMethods" class="shipping-methods">
<div *ngIf="!(basketError$ | async) && nextDisabled" role="alert" class="alert alert-danger">
<div *ngIf="(basketError$ | async) === undefined && nextDisabled" role="alert" class="alert alert-danger">
{{ 'checkout.shipping_method.no_Selection.error' | translate }}
</div>
<h3>{{ 'checkout.shipping_method.selection.heading' | translate }}</h3>
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/login/login-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1>&nbsp;</h1>
<div class="row" data-testing-id="account-login-page">
<div class="col-lg-6">
<div class="section">
<div *ngIf="!(isLoggedIn$ | async)">
<div *ngIf="(isLoggedIn$ | async) !== true">
<h2>{{ 'account.login.signin.heading' | translate }}</h2>
<p *ngIf="loginMessageKey$ | async as loginMessageKey" class="alert alert-info">
{{ loginMessageKey | translate }}
Expand Down
9 changes: 7 additions & 2 deletions src/app/pages/login/login-page.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { MockComponent } from 'ng-mocks';
import { instance, mock } from 'ts-mockito';
import { of } from 'rxjs';
import { instance, mock, when } from 'ts-mockito';

import { AccountFacade } from 'ish-core/facades/account.facade';
import { AppFacade } from 'ish-core/facades/app.facade';
Expand All @@ -16,8 +17,12 @@ describe('Login Page Component', () => {
let fixture: ComponentFixture<LoginPageComponent>;
let component: LoginPageComponent;
let element: HTMLElement;
let accountFacade: AccountFacade;

beforeEach(async () => {
accountFacade = mock(AccountFacade);
when(accountFacade.isLoggedIn$).thenReturn(of(false));

await TestBed.configureTestingModule({
imports: [RouterTestingModule, TranslateModule.forRoot()],
declarations: [
Expand All @@ -26,7 +31,7 @@ describe('Login Page Component', () => {
MockComponent(LoadingComponent),
],
providers: [
{ provide: AccountFacade, useFactory: () => instance(mock(AccountFacade)) },
{ provide: AccountFacade, useFactory: () => instance(accountFacade) },
{ provide: AppFacade, useFactory: () => instance(mock(AppFacade)) },
],
}).compileComponents();
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/product/product-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
</div>

<ng-container *ishFeature="'recently'"
><ish-recently-viewed *ngIf="!(productLoading$ | async)"></ish-recently-viewed
><ish-recently-viewed *ngIf="(productLoading$ | async) !== true"></ish-recently-viewed
></ng-container>
1 change: 1 addition & 0 deletions src/app/pages/product/product-page.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('Product Page Component', () => {
beforeEach(async () => {
context = mock(ProductContextFacade);
when(context.select('product')).thenReturn(EMPTY);
when(context.select('loading')).thenReturn(of(false));

await TestBed.configureTestingModule({
imports: [FeatureToggleModule.forTesting('recently')],
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/search/search-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

<!-- empty search result -->
<ng-template #noResult>
<ish-search-no-result *ngIf="!(searchLoading$ | async)" [searchTerm]="searchTerm"></ish-search-no-result>
<ish-search-no-result *ngIf="(searchLoading$ | async) === false" [searchTerm]="searchTerm"></ish-search-no-result>
</ng-template>
</ng-container>
1 change: 1 addition & 0 deletions src/app/pages/search/search-page.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('Search Page Component', () => {
beforeEach(async () => {
shoppingFacade = mock(ShoppingFacade);
when(shoppingFacade.searchTerm$).thenReturn(of('search'));
when(shoppingFacade.searchLoading$).thenReturn(of(false));

await TestBed.configureTestingModule({
imports: [RouterTestingModule],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h2>{{ 'checkout.address.billing.label' | translate }}</h2>
data-testing-id="create-invoice-address-link"
class="btn btn-link"
(click)="showAddressForm()"
[attr.aria-expanded]="!(collapseChange | async)"
[attr.aria-expanded]="(collapseChange | async) === false"
aria-controls="collapseBasic"
>
{{ 'checkout.create_address.link' | translate }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2>{{ 'checkout.address.shipping.label' | translate }}</h2>
<ng-container *ngIf="shippingAddress$ | async as address">
<div class="address-box">
<ng-container *ngIf="!(basketInvoiceAndShippingAddressEqual$ | async)">
<ng-container *ngIf="(basketInvoiceAndShippingAddressEqual$ | async) === false">
<div class="float-right">
<!-- edit shipping address -->
<a
Expand Down Expand Up @@ -67,7 +67,7 @@ <h2>{{ 'checkout.address.shipping.label' | translate }}</h2>
data-testing-id="create-shipping-address-link"
class="btn btn-link"
(click)="showAddressForm()"
[attr.aria-expanded]="!(collapseChange | async)"
[attr.aria-expanded]="(collapseChange | async) === false"
aria-controls="collapseBasic"
>
{{ 'checkout.create_address.link' | translate }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('Basket Shipping Address Widget Component', () => {
checkoutFacade = mock(CheckoutFacade);
when(checkoutFacade.basket$).thenReturn(EMPTY);
when(checkoutFacade.basketShippingAddress$).thenReturn(EMPTY);
when(checkoutFacade.basketInvoiceAndShippingAddressEqual$).thenReturn(of(false));

accountFacade = mock(AccountFacade);
when(accountFacade.addresses$()).thenReturn(EMPTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
data-testing-id="addToCartButton"
(click)="addToBasket()"
>
<ng-container *ngIf="!(displaySpinner$ | async); else spinning">
<ng-container *ngIf="(displaySpinner$ | async) !== true; else spinning">
<!-- Add to Cart button -->
<ng-container *ngIf="displayIcon; else defaultButton">
<fa-icon [icon]="['fas', 'shopping-cart']"></fa-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { TranslateModule } from '@ngx-translate/core';
import { MockComponent } from 'ng-mocks';
import { of } from 'rxjs';
import { EMPTY, of } from 'rxjs';
import { instance, mock, when } from 'ts-mockito';

import { CheckoutFacade } from 'ish-core/facades/checkout.facade';
Expand All @@ -19,7 +19,7 @@ describe('Product Add To Basket Component', () => {

beforeEach(async () => {
const checkoutFacade = mock(CheckoutFacade);
when(checkoutFacade.basketLoading$).thenReturn(of(false));
when(checkoutFacade.basketLoading$).thenReturn(EMPTY);

context = mock(ProductContextFacade);
when(context.select('displayProperties', 'addToBasket')).thenReturn(of(true));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="product-list row">
<div *ngIf="!products.length">
<ng-container *ngIf="!(listingLoading$ | async)">
<ng-container *ngIf="(listingLoading$ | async) !== true">
{{ 'search.noresult.filtered_products.message' | translate }}
</ng-container>
</div>
Expand Down

0 comments on commit c98c4d1

Please sign in to comment.