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.