All files / src/mock MockObserveModelApi.ts

42.85% Statements 3/7
100% Branches 0/0
0% Functions 0/3
50% Lines 3/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18      1x     1x     1x                
// Package: com.lightningkite.lightningdb.mock
// Generated by Khrysalis - this file will be overwritten.
import { HasId } from '../HasId'
import { ObserveModelApi } from '../ObserveModelApi'
import { Query } from '../Query'
import { MockTable } from './MockTable'
import { Observable, concat, of } from 'rxjs'
 
//! Declares com.lightningkite.lightningdb.mock.MockObserveModelApi
export class MockObserveModelApi<Model extends HasId> extends ObserveModelApi<Model> {
    public constructor(public readonly table: MockTable<Model>) {
        super();
    }
    
    public observe(query: Query<Model>): Observable<Array<Model>> {
        return concat(of(this.table.asList().filter((item: Model): boolean => query.condition.invoke(item))), this.table.observe(query.condition));
    }
}