All files / dist/mock MockReadModelApi.js

42.1% Statements 8/19
0% Branches 0/10
0% Functions 0/7
47.05% Lines 8/17

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 19 20 21 22 23 24 25 26 27 28 29 30 31 32  1x 1x 1x 1x 1x 1x 1x                                             1x  
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MockReadModelApi = void 0;
const ReadModelApi_1 = require("../ReadModelApi");
const SortPart_1 = require("../SortPart");
const ItemNotFound_1 = require("./ItemNotFound");
const khrysalis_runtime_1 = require("@lightningkite/khrysalis-runtime");
const rxjs_1 = require("rxjs");
//! Declares com.lightningkite.lightningdb.mock.MockReadModelApi
class MockReadModelApi extends ReadModelApi_1.ReadModelApi {
    constructor(table) {
        super();
        this.table = table;
    }
    list(query) {
        var _a;
        return (0, rxjs_1.of)(this.table
            .asList().filter((item) => query.condition.invoke(item)).slice().sort((_a = (0, SortPart_1.xListComparatorGet)(query.orderBy)) !== null && _a !== void 0 ? _a : (0, khrysalis_runtime_1.compareBy)((it) => it._id)).slice(query.skip).slice(0, query.limit));
    }
    get(id) {
        var _a;
        return (_a = (() => {
            const temp9 = this.table.getItem(id);
            if (temp9 === null) {
                return null;
            }
            return ((it) => (0, rxjs_1.of)(it))(temp9);
        })()) !== null && _a !== void 0 ? _a : (0, rxjs_1.throwError)(new ItemNotFound_1.ItemNotFound(`404 item with key ${id} not found`));
    }
}
exports.MockReadModelApi = MockReadModelApi;
//# sourceMappingURL=MockReadModelApi.js.map