Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should upload a file', () => {
// create component with 1 file
const personFileService = TestBed.get(PersonFileService);
spyOn(personFileService, 'list').and.returnValues(of([files[0]]), of(files));
const fakeEvents = new Subject();
spyOn(personFileService, 'create').and.returnValues(fakeEvents);
const fixture = TestBed.createComponent(PersonFilesComponent);
fixture.detectChanges();
// trigger change
const fileChangeEvent = {
target: {
files: [{
name: files[1].name
}]
}
} as any;
import {Component, OnDestroy, OnInit} from "@angular/core";
import {of} from "rxjs";
import {map, takeUntil} from "rxjs/operators";
import {untilComponentDestroyed} from "../index";
class SomeClass {
subscribe() {
}
}
@Component({})
class BadComponent implements OnInit, OnDestroy {
observable = of(1);
stop = of(1);
ngOnInit() {
// Error
this.observable.pipe(
map(i => i),
takeUntil(this.stop),
map(i => i),
).subscribe();
// Error
this.observable.pipe(
map(i => i),
untilComponentDestroyed(this),
map(i => i),
).subscribe();
// 1) emit a 'loading...' message if fetching the symbol results takes more than half a second
// 2) emit the actual results
const incrementalResults = merge(
of(LOADING).pipe(
delay(500),
takeUntil(symbolResults)
),
symbolResults
)
if (queryText.length === 1) {
// The user has likely just typed a brand-new autocomplete
// query. Clear out the results from any previous symbol fetch requests.
return concat(of(undefined), incrementalResults)
}
return incrementalResults
}
get(): Observable {
return of(mockUserDetails);
}
load(): void {}
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptionsTo }) => {
const left = hot('--a--^--b--c--#', undefined, 'jenga');
const leftSubs = '^ !';
const right = hot('-----^----------d--e--f--|');
const rightSubs = '^ !';
const expected = '---------#';
const result = of(left, right).pipe(combineAll());
expectObservable(result).toBe(expected, null, 'jenga');
expectSubscriptionsTo(left).toBe(leftSubs);
expectSubscriptionsTo(right).toBe(rightSubs);
});
});
catchError(e => of(new actions.DeleteFolderFailAction({ error: e })))
)
'dc.contributor.author': [
{
language: 'en_US',
value: 'Smith, Donald'
}
],
'dc.date.issued': [
{
language: null,
value: '2015-06-26'
}
]
}
});
const rd = createSuccessfulRemoteDataObject(item);
mockObject = Object.assign(new WorkflowItem(), { item: observableOf(rd), id: '1234', uuid: '1234' });
describe('WorkflowitemActionsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: MockTranslateLoader
}
})
],
declarations: [WorkflowitemActionsComponent],
providers: [
{ provide: Injector, useValue: {} },
{ provide: Router, useValue: new RouterStub() },
getActive(): Observable {
return of(mockCart);
}
getEntries(): Observable {
return this.modalService
.dialog({
title: _('catalog.confirm-adding-options-delete-default-title'),
body: _('catalog.confirm-adding-options-delete-default-body'),
buttons: [
{ type: 'seconday', label: _('common.cancel') },
{ type: 'danger', label: _('catalog.delete-default-variant'), returnValue: true },
],
})
.pipe(
mergeMap(res => {
return res === true ? of(true) : EMPTY;
}),
);
} else {
return of(true);
}
}
const getRequestEntry$ = (successful:boolean, statusCode:number, statusText:string) => {
return observableOf({
response: new RestResponse(successful, statusCode, statusText)
} as RequestEntry);
};