added error component and coverage for new components

This commit is contained in:
William Welling
2017-10-04 14:17:19 -05:00
parent a9faab6833
commit 7937a47aa5
14 changed files with 138 additions and 20 deletions

View File

@@ -31,6 +31,7 @@
[title]="'collection.page.license'"> [title]="'collection.page.license'">
</ds-comcol-page-content> </ds-comcol-page-content>
</div> </div>
<ds-error *ngIf="collectionData.hasFailed | async" message="Error fetching collection"></ds-error>
<ds-loading *ngIf="collectionData.isLoading | async" message="Loading collection..."></ds-loading> <ds-loading *ngIf="collectionData.isLoading | async" message="Loading collection..."></ds-loading>
<br> <br>
<div *ngIf="itemData.hasSucceeded | async"> <div *ngIf="itemData.hasSucceeded | async">
@@ -42,5 +43,6 @@
[hideGear]="false"> [hideGear]="false">
</ds-object-list> </ds-object-list>
</div> </div>
<ds-error *ngIf="itemData.hasFailed | async" message="Error fetching items"></ds-error>
<ds-loading *ngIf="itemData.isLoading | async" message="Loading items..."></ds-loading> <ds-loading *ngIf="itemData.isLoading | async" message="Loading items..."></ds-loading>
</div> </div>

View File

@@ -24,4 +24,5 @@
</ds-comcol-page-content> </ds-comcol-page-content>
<ds-community-page-sub-collection-list></ds-community-page-sub-collection-list> <ds-community-page-sub-collection-list></ds-community-page-sub-collection-list>
</div> </div>
<ds-error *ngIf="communityData.hasFailed | async" message="Error fetching community"></ds-error>
<ds-loading *ngIf="communityData.isLoading | async" message="Loading community..."></ds-loading> <ds-loading *ngIf="communityData.isLoading | async" message="Loading community..."></ds-loading>

View File

@@ -9,4 +9,5 @@
(paginationChange)="updatePage($event)"> (paginationChange)="updatePage($event)">
</ds-object-list> </ds-object-list>
</div> </div>
<ds-error *ngIf="topLevelCommunities.hasFailed | async" message="Error fetching top level communities"></ds-error>
<ds-loading *ngIf="topLevelCommunities.isLoading | async" message="Loading top level communities..."></ds-loading> <ds-loading *ngIf="topLevelCommunities.isLoading | async" message="Loading top level communities..."></ds-loading>

View File

@@ -17,4 +17,5 @@
<ds-item-page-full-file-section [item]="item.payload | async"></ds-item-page-full-file-section> <ds-item-page-full-file-section [item]="item.payload | async"></ds-item-page-full-file-section>
<ds-item-page-collections [item]="item.payload | async"></ds-item-page-collections> <ds-item-page-collections [item]="item.payload | async"></ds-item-page-collections>
</div> </div>
<ds-error *ngIf="item.hasFailed | async" message="Error fetching item"></ds-error>
<ds-loading *ngIf="item.isLoading | async" message="Loading item..."></ds-loading> <ds-loading *ngIf="item.isLoading | async" message="Loading item..."></ds-loading>

View File

@@ -21,4 +21,5 @@
</div> </div>
</div> </div>
</div> </div>
<ds-error *ngIf="item.hasFailed | async" message="Error fetching item"></ds-error>
<ds-loading *ngIf="item.isLoading | async" message="Loading item..."></ds-loading> <ds-loading *ngIf="item.isLoading | async" message="Loading item..."></ds-loading>

View File

@@ -1,7 +1,6 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule, APP_BASE_HREF } from '@angular/common'; import { CommonModule, APP_BASE_HREF } from '@angular/common';
import { HttpModule } from '@angular/http'; import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { EffectsModule } from '@ngrx/effects'; import { EffectsModule } from '@ngrx/effects';

View File

@@ -0,0 +1 @@
<div>{{ message }}</div>

View File

@@ -0,0 +1,45 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { ErrorComponent } from './error.component';
describe('ErrorComponent (inline template)', () => {
let comp: ErrorComponent;
let fixture: ComponentFixture<ErrorComponent>;
let de: DebugElement;
let el: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ErrorComponent ], // declare the test component
}).compileComponents(); // compile template and css
}));
beforeEach(() => {
fixture = TestBed.createComponent(ErrorComponent);
comp = fixture.componentInstance; // ErrorComponent test instance
// query for the title <div> by CSS element selector
de = fixture.debugElement.query(By.css('div'));
el = de.nativeElement;
});
it('should create', () => {
expect(comp).toBeTruthy();
});
it('should display default message', () => {
fixture.detectChanges();
expect(el.textContent).toContain(comp.message);
});
it('should display input message', () => {
comp.message = 'Test Message';
fixture.detectChanges();
expect(el.textContent).toContain('Test Message');
});
});

View File

@@ -0,0 +1,12 @@
import { Component, Input } from '@angular/core';
@Component({
selector: 'ds-error',
styleUrls: ['./error.component.scss'],
templateUrl: './error.component.html'
})
export class ErrorComponent {
@Input() message = 'Error...';
}

View File

@@ -0,0 +1,45 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { LoadingComponent } from './loading.component';
describe('LoadingComponent (inline template)', () => {
let comp: LoadingComponent;
let fixture: ComponentFixture<LoadingComponent>;
let de: DebugElement;
let el: HTMLElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoadingComponent ], // declare the test component
}).compileComponents(); // compile template and css
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoadingComponent);
comp = fixture.componentInstance; // LoadingComponent test instance
// query for the title <div> by CSS element selector
de = fixture.debugElement.query(By.css('div'));
el = de.nativeElement;
});
it('should create', () => {
expect(comp).toBeTruthy();
});
it('should display default message', () => {
fixture.detectChanges();
expect(el.textContent).toContain(comp.message);
});
it('should display input message', () => {
comp.message = 'Test Message';
fixture.detectChanges();
expect(el.textContent).toContain('Test Message');
});
});

View File

@@ -7,6 +7,6 @@ import { Component, Input } from '@angular/core';
}) })
export class LoadingComponent { export class LoadingComponent {
@Input() message: 'Loading...'; @Input() message = 'Loading...';
} }

View File

@@ -9,25 +9,26 @@ import { TranslateModule } from '@ngx-translate/core';
import { NgxPaginationModule } from 'ngx-pagination'; import { NgxPaginationModule } from 'ngx-pagination';
import { PaginationComponent } from './pagination/pagination.component'; import { EnumKeysPipe } from './utils/enum-keys-pipe';
import { FileSizePipe } from './utils/file-size-pipe'; import { FileSizePipe } from './utils/file-size-pipe';
import { ThumbnailComponent } from '../thumbnail/thumbnail.component';
import { SafeUrlPipe } from './utils/safe-url-pipe'; import { SafeUrlPipe } from './utils/safe-url-pipe';
import { TruncatePipe } from './utils/truncate.pipe';
import { CollectionListElementComponent } from '../object-list/collection-list-element/collection-list-element.component';
import { ComcolPageContentComponent } from './comcol-page-content/comcol-page-content.component'; import { ComcolPageContentComponent } from './comcol-page-content/comcol-page-content.component';
import { ComcolPageHeaderComponent } from './comcol-page-header/comcol-page-header.component'; import { ComcolPageHeaderComponent } from './comcol-page-header/comcol-page-header.component';
import { ComcolPageLogoComponent } from './comcol-page-logo/comcol-page-logo.component'; import { ComcolPageLogoComponent } from './comcol-page-logo/comcol-page-logo.component';
import { EnumKeysPipe } from './utils/enum-keys-pipe'; import { CommunityListElementComponent } from '../object-list/community-list-element/community-list-element.component';
import { ErrorComponent } from './error/error.component';
import { LoadingComponent } from './loading/loading.component';
import { ItemListElementComponent } from '../object-list/item-list-element/item-list-element.component';
import { ObjectListComponent } from './object-list/object-list.component'; import { ObjectListComponent } from './object-list/object-list.component';
import { ObjectListElementComponent } from '../object-list/object-list-element/object-list-element.component'; import { ObjectListElementComponent } from '../object-list/object-list-element/object-list-element.component';
import { ItemListElementComponent } from '../object-list/item-list-element/item-list-element.component'; import { PaginationComponent } from './pagination/pagination.component';
import { CommunityListElementComponent } from '../object-list/community-list-element/community-list-element.component'; import { ThumbnailComponent } from '../thumbnail/thumbnail.component';
import { CollectionListElementComponent } from '../object-list/collection-list-element/collection-list-element.component';
import { TruncatePipe } from './utils/truncate.pipe';
import { WrapperListElementComponent } from '../object-list/wrapper-list-element/wrapper-list-element.component';
import { SearchResultListElementComponent } from '../object-list/search-result-list-element/search-result-list-element.component'; import { SearchResultListElementComponent } from '../object-list/search-result-list-element/search-result-list-element.component';
import { SearchFormComponent } from './search-form/search-form.component'; import { SearchFormComponent } from './search-form/search-form.component';
import { LoadingComponent } from './loading/loading.component'; import { WrapperListElementComponent } from '../object-list/wrapper-list-element/wrapper-list-element.component';
const MODULES = [ const MODULES = [
// Do NOT include UniversalModule, HttpModule, or JsonpModule here // Do NOT include UniversalModule, HttpModule, or JsonpModule here
@@ -42,31 +43,32 @@ const MODULES = [
const PIPES = [ const PIPES = [
// put shared pipes here // put shared pipes here
EnumKeysPipe,
FileSizePipe, FileSizePipe,
SafeUrlPipe, SafeUrlPipe,
EnumKeysPipe,
TruncatePipe TruncatePipe
]; ];
const COMPONENTS = [ const COMPONENTS = [
// put shared components here // put shared components here
PaginationComponent,
ThumbnailComponent,
ComcolPageContentComponent, ComcolPageContentComponent,
ComcolPageHeaderComponent, ComcolPageHeaderComponent,
ComcolPageLogoComponent, ComcolPageLogoComponent,
ErrorComponent,
LoadingComponent,
ObjectListComponent, ObjectListComponent,
ObjectListElementComponent, ObjectListElementComponent,
WrapperListElementComponent, PaginationComponent,
SearchFormComponent, SearchFormComponent,
LoadingComponent ThumbnailComponent,
WrapperListElementComponent
]; ];
const ENTRY_COMPONENTS = [ const ENTRY_COMPONENTS = [
// put shared entry components (components that are created dynamically) here // put shared entry components (components that are created dynamically) here
ItemListElementComponent,
CollectionListElementComponent, CollectionListElementComponent,
CommunityListElementComponent, CommunityListElementComponent,
ItemListElementComponent,
SearchResultListElementComponent SearchResultListElementComponent
]; ];

View File

@@ -5,9 +5,10 @@ const {
/** /**
* Webpack Plugins * Webpack Plugins
*/ */
const ProvidePlugin = require('webpack/lib/ProvidePlugin'); const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
const DefinePlugin = require('webpack/lib/DefinePlugin'); const DefinePlugin = require('webpack/lib/DefinePlugin');
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin'); const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
const ProvidePlugin = require('webpack/lib/ProvidePlugin');
/** /**
* Webpack Constants * Webpack Constants
@@ -75,8 +76,9 @@ module.exports = function (options) {
loader: 'source-map-loader', loader: 'source-map-loader',
exclude: [ exclude: [
// these packages have problems with their sourcemaps // these packages have problems with their sourcemaps
root('node_modules/rxjs'), root('node_modules/@angular'),
root('node_modules/@angular') root('node_modules/@nguniversal'),
root('node_modules/rxjs')
] ]
}, },
@@ -221,6 +223,12 @@ module.exports = function (options) {
*/ */
plugins: [ plugins: [
new ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,
root('./src'),
{}
),
/** /**
* Plugin: DefinePlugin * Plugin: DefinePlugin
* Description: Define free variables. * Description: Define free variables.