Skip to content

Instantly share code, notes, and snippets.

View IAfanasov's full-sized avatar

IAfanasov

  • CloudKitchens
  • the Netherlands
  • 04:49 (UTC +02:00)
  • LinkedIn in/iafanasov
View GitHub Profile
it(`returns state 'active' when the due date is in the future`, ()=>{
const futureTask = {...taskDtoMock};
futureTask.dueDate = new Date(3000, 10, 10);
const taskViewModel = sut.taskToViewModel(futureTask);
expect(taskViewModel.state).toEqual('active');
})
@Component({
selector: 'app-dummy-component',
templateUrl: './dummy-component.component.html',
})
export class DummyComponent implements OnInit {
constructor(public route: ActivatedRoute) {
}
ngOnInit(): void {
@Component({
selector: 'app-dummy-component',
templateUrl: './dummy-component.component.html',
})
export class DummyComponent implements OnInit {
constructor(public route: ActivatedRoute) {
}
ngOnInit(): void {
@IAfanasov
IAfanasov / the alert method.ts
Created August 31, 2020 08:01
the alert method.ts
showAlert(data: SomeDataType) {
const alertString = Utils.getAlertText(data);
alert(alertString);
}
@IAfanasov
IAfanasov / AAA SHARED.TS
Created August 31, 2020 07:56
AAA SHARED.TS
describe('documentTypeClicked with NON-PDF', () => {
beforeEach(async () => {
// ARRANGE
userDocumentServiceSpy.retrieveFileUri.and.returnValue(Promise.resolve('url/url.doc'));
spyOn(component, 'showAlert').and.callThrough();
// ACT
await component.documentTypeClicked('UploadFile');
});
@IAfanasov
IAfanasov / AAA.ts
Last active August 31, 2020 06:55
AAA.ts
it('should open modal when linkText clicked', async () => {
// ARRANGE
await fixture.whenRenderingDone();
// ACT
clickByTestAttr(fixture.debugElement, 'skillsPicker-linkText');
await fixture.whenStable();
// ASSERT
expect(modalService.open).toHaveBeenCalled();
@IAfanasov
IAfanasov / http request testing setup.ts
Created August 30, 2020 07:25
http request testing setup.ts
describe('AppComponent', () => {
let component: AppComponent;
let fixture: ComponentFixture<AppComponent>;
let httpMock: HttpTestingController;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
declarations: [AppComponent]
})
@IAfanasov
IAfanasov / http interceptor test setup.ts
Created August 30, 2020 07:17
http interceptor test setup.ts
let client: HttpClient;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule
],
providers: [{
provide: HTTP_INTERCEPTORS,
useClass: GitHubApiVersionInterceptor,
describe('placement="left"', () => {
let windowEl;
beforeEach(() => {
const fixture = createTestComponent(`<div ngbTooltip="Great tip!" placement="left"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbTooltip));
triggerEvent(directive, 'mouseenter');
fixture.detectChanges();
windowEl = getWindow(fixture.nativeElement);
});
describe('placement="left"', () => {
let windowEl;
beforeEach(() => {
const fixture = createTestComponent(`<div ngbTooltip="!" placement="left"></div>`);
const directive = fixture.debugElement.query(By.directive(NgbTooltip));
triggerEvent(directive, 'mouseenter');
fixture.detectChanges();
windowEl = getWindow(fixture.nativeElement);
});