first version of sample.component finished
This commit is contained in:
		
							
								
								
									
										3
									
								
								src/app/error/error.component.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/app/error/error.component.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
<rb-alert alertTitle="Error" type="error" okBtnLabel="Discard">
 | 
			
		||||
  {{message}}
 | 
			
		||||
</rb-alert>
 | 
			
		||||
							
								
								
									
										0
									
								
								src/app/error/error.component.scss
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/app/error/error.component.scss
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										45
									
								
								src/app/error/error.component.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src/app/error/error.component.spec.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 | 
			
		||||
 | 
			
		||||
import { ErrorComponent } from './error.component';
 | 
			
		||||
import {ModalService, RbUiComponentsModule} from '@inst-iot/bosch-angular-ui-components';
 | 
			
		||||
import {By} from '@angular/platform-browser';
 | 
			
		||||
 | 
			
		||||
describe('ErrorComponent', () => {
 | 
			
		||||
  let component: ErrorComponent;
 | 
			
		||||
  let fixture: ComponentFixture<ErrorComponent>;
 | 
			
		||||
  let css;   // get native element by css selector
 | 
			
		||||
 | 
			
		||||
  beforeEach(async(() => {
 | 
			
		||||
    TestBed.configureTestingModule({
 | 
			
		||||
      declarations: [ ErrorComponent ],
 | 
			
		||||
      imports: [
 | 
			
		||||
        RbUiComponentsModule,
 | 
			
		||||
      ],
 | 
			
		||||
      providers: [
 | 
			
		||||
        ModalService
 | 
			
		||||
      ]
 | 
			
		||||
    })
 | 
			
		||||
    .compileComponents();
 | 
			
		||||
  }));
 | 
			
		||||
 | 
			
		||||
  beforeEach(() => {
 | 
			
		||||
    fixture = TestBed.createComponent(ErrorComponent);
 | 
			
		||||
    component = fixture.componentInstance;
 | 
			
		||||
    fixture.detectChanges();
 | 
			
		||||
    css = (selector) => fixture.debugElement.query(By.css(selector)).nativeElement;
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should create', () => {
 | 
			
		||||
    expect(component).toBeTruthy();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should show the alert', () => {
 | 
			
		||||
    expect(css('rb-alert')).toBeTruthy();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should have the right message', () => {
 | 
			
		||||
    component.message = 'test';
 | 
			
		||||
    fixture.detectChanges();
 | 
			
		||||
    expect(css('.dialog-text').innerText).toBe('test');
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
							
								
								
									
										17
									
								
								src/app/error/error.component.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/app/error/error.component.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
import { Component, OnInit } from '@angular/core';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-error',
 | 
			
		||||
  templateUrl: './error.component.html',
 | 
			
		||||
  styleUrls: ['./error.component.scss']
 | 
			
		||||
})
 | 
			
		||||
export class ErrorComponent implements OnInit {
 | 
			
		||||
 | 
			
		||||
  message = '';
 | 
			
		||||
 | 
			
		||||
  constructor() { }
 | 
			
		||||
 | 
			
		||||
  ngOnInit(): void {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user