diff --git a/src/app/+collection-page/collection-page.component.html b/src/app/+collection-page/collection-page.component.html index ee7d97f4c8..8a8f2f0aad 100644 --- a/src/app/+collection-page/collection-page.component.html +++ b/src/app/+collection-page/collection-page.component.html @@ -31,6 +31,7 @@ [title]="'collection.page.license'"> +
@@ -42,5 +43,6 @@ [hideGear]="false">
+ diff --git a/src/app/+community-page/community-page.component.html b/src/app/+community-page/community-page.component.html index a55a597c74..f29fa364fb 100644 --- a/src/app/+community-page/community-page.component.html +++ b/src/app/+community-page/community-page.component.html @@ -24,4 +24,5 @@ + diff --git a/src/app/+home-page/top-level-community-list/top-level-community-list.component.html b/src/app/+home-page/top-level-community-list/top-level-community-list.component.html index bd5666122f..c8a889a4f7 100644 --- a/src/app/+home-page/top-level-community-list/top-level-community-list.component.html +++ b/src/app/+home-page/top-level-community-list/top-level-community-list.component.html @@ -9,4 +9,5 @@ (paginationChange)="updatePage($event)"> + \ No newline at end of file diff --git a/src/app/+item-page/full/full-item-page.component.html b/src/app/+item-page/full/full-item-page.component.html index d6ff321794..ccd8ca3932 100644 --- a/src/app/+item-page/full/full-item-page.component.html +++ b/src/app/+item-page/full/full-item-page.component.html @@ -17,4 +17,5 @@ + diff --git a/src/app/+item-page/simple/item-page.component.html b/src/app/+item-page/simple/item-page.component.html index 6b650b9476..fe7e1138e6 100644 --- a/src/app/+item-page/simple/item-page.component.html +++ b/src/app/+item-page/simple/item-page.component.html @@ -21,4 +21,5 @@ + diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3ec0cdebab..a80a173297 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,7 +1,6 @@ import { NgModule } from '@angular/core'; import { CommonModule, APP_BASE_HREF } from '@angular/common'; import { HttpModule } from '@angular/http'; -import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; import { EffectsModule } from '@ngrx/effects'; diff --git a/src/app/shared/error/error.component.html b/src/app/shared/error/error.component.html new file mode 100644 index 0000000000..fb5224e1ac --- /dev/null +++ b/src/app/shared/error/error.component.html @@ -0,0 +1 @@ +
{{ message }}
\ No newline at end of file diff --git a/src/app/shared/error/error.component.scss b/src/app/shared/error/error.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/shared/error/error.component.spec.ts b/src/app/shared/error/error.component.spec.ts new file mode 100644 index 0000000000..078aa95592 --- /dev/null +++ b/src/app/shared/error/error.component.spec.ts @@ -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; + 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
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'); + }); + +}); diff --git a/src/app/shared/error/error.component.ts b/src/app/shared/error/error.component.ts new file mode 100644 index 0000000000..b65979f7b0 --- /dev/null +++ b/src/app/shared/error/error.component.ts @@ -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...'; + +} diff --git a/src/app/shared/loading/loading.component.spec.ts b/src/app/shared/loading/loading.component.spec.ts new file mode 100644 index 0000000000..45583ed198 --- /dev/null +++ b/src/app/shared/loading/loading.component.spec.ts @@ -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; + 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
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'); + }); + +}); diff --git a/src/app/shared/loading/loading.component.ts b/src/app/shared/loading/loading.component.ts index 3aa63af3ab..6bc7d99f4b 100644 --- a/src/app/shared/loading/loading.component.ts +++ b/src/app/shared/loading/loading.component.ts @@ -7,6 +7,6 @@ import { Component, Input } from '@angular/core'; }) export class LoadingComponent { - @Input() message: 'Loading...'; + @Input() message = 'Loading...'; } diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 669f490c13..21ca8c51c4 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -9,25 +9,26 @@ import { TranslateModule } from '@ngx-translate/core'; 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 { ThumbnailComponent } from '../thumbnail/thumbnail.component'; 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 { ComcolPageHeaderComponent } from './comcol-page-header/comcol-page-header.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 { ObjectListElementComponent } from '../object-list/object-list-element/object-list-element.component'; -import { ItemListElementComponent } from '../object-list/item-list-element/item-list-element.component'; -import { CommunityListElementComponent } from '../object-list/community-list-element/community-list-element.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 { PaginationComponent } from './pagination/pagination.component'; +import { ThumbnailComponent } from '../thumbnail/thumbnail.component'; import { SearchResultListElementComponent } from '../object-list/search-result-list-element/search-result-list-element.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 = [ // Do NOT include UniversalModule, HttpModule, or JsonpModule here @@ -42,31 +43,32 @@ const MODULES = [ const PIPES = [ // put shared pipes here + EnumKeysPipe, FileSizePipe, SafeUrlPipe, - EnumKeysPipe, TruncatePipe ]; const COMPONENTS = [ // put shared components here - PaginationComponent, - ThumbnailComponent, ComcolPageContentComponent, ComcolPageHeaderComponent, ComcolPageLogoComponent, + ErrorComponent, + LoadingComponent, ObjectListComponent, ObjectListElementComponent, - WrapperListElementComponent, + PaginationComponent, SearchFormComponent, - LoadingComponent + ThumbnailComponent, + WrapperListElementComponent ]; const ENTRY_COMPONENTS = [ // put shared entry components (components that are created dynamically) here - ItemListElementComponent, CollectionListElementComponent, CommunityListElementComponent, + ItemListElementComponent, SearchResultListElementComponent ]; diff --git a/webpack/webpack.test.js b/webpack/webpack.test.js index a353dec9d6..818e348c7e 100644 --- a/webpack/webpack.test.js +++ b/webpack/webpack.test.js @@ -5,9 +5,10 @@ const { /** * Webpack Plugins */ -const ProvidePlugin = require('webpack/lib/ProvidePlugin'); +const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin'); const DefinePlugin = require('webpack/lib/DefinePlugin'); const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin'); +const ProvidePlugin = require('webpack/lib/ProvidePlugin'); /** * Webpack Constants @@ -75,8 +76,9 @@ module.exports = function (options) { loader: 'source-map-loader', exclude: [ // 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: [ + new ContextReplacementPlugin( + /angular(\\|\/)core(\\|\/)@angular/, + root('./src'), + {} + ), + /** * Plugin: DefinePlugin * Description: Define free variables.