From c369a94a4c3b95889f6cfb09e737573ab61cf1a5 Mon Sep 17 00:00:00 2001 From: kube-js Date: Sun, 25 Aug 2019 23:09:05 +0100 Subject: [PATCH] fix: addressed interfaces issues --- dist/errors/conflictingItemError.d.ts | 4 +- dist/errors/conflictingItemError.js.map | 2 +- dist/errors/itemNotFoundError.d.ts | 4 +- dist/errors/itemNotFoundError.js.map | 2 +- dist/facade.d.ts | 2 +- dist/functions/countItems/test.d.ts | 4 +- dist/functions/countItems/test.js | 114 ++++++++++++------------ dist/functions/countItems/test.js.map | 2 +- dist/functions/createItem/index.d.ts | 2 +- dist/testFacade.d.ts | 4 +- dist/testFacade.js | 6 +- dist/testFacade.js.map | 2 +- src/Facade.ts | 2 +- src/errors/ConflictingItemError.ts | 4 +- src/errors/ItemNotFoundError.ts | 4 +- src/functions/CountItems/test.ts | 57 ++++++------ src/functions/CreateItem/index.ts | 2 +- src/testFacade.ts | 27 +++--- 18 files changed, 126 insertions(+), 118 deletions(-) diff --git a/dist/errors/conflictingItemError.d.ts b/dist/errors/conflictingItemError.d.ts index b39f68b..927d391 100644 --- a/dist/errors/conflictingItemError.d.ts +++ b/dist/errors/conflictingItemError.d.ts @@ -1,6 +1,6 @@ import { BaseError } from "make-error"; export default class ConflictingItemError extends BaseError { readonly itemName: string; - readonly itemId: string; - constructor(itemName: string, itemId: string); + readonly itemId?: string; + constructor(itemName: string, itemId?: string); } diff --git a/dist/errors/conflictingItemError.js.map b/dist/errors/conflictingItemError.js.map index 80930c3..dae58e0 100644 --- a/dist/errors/conflictingItemError.js.map +++ b/dist/errors/conflictingItemError.js.map @@ -1 +1 @@ -{"version":3,"file":"ConflictingItemError.js","sourceRoot":"","sources":["../../src/errors/ConflictingItemError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAuC;AAEvC;IAAkD,wCAAS;IAKzD,8BAAmB,QAAgB,EAAE,MAAc;QAAnD,YACE,iBAAO,SAGR;QAFC,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;IACvB,CAAC;IACH,2BAAC;AAAD,CAAC,AAVD,CAAkD,sBAAS,GAU1D"} \ No newline at end of file +{"version":3,"file":"ConflictingItemError.js","sourceRoot":"","sources":["../../src/errors/ConflictingItemError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAuC;AAEvC;IAAkD,wCAAS;IAKzD,8BAAmB,QAAgB,EAAE,MAAe;QAApD,YACE,iBAAO,SAGR;QAFC,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;IACvB,CAAC;IACH,2BAAC;AAAD,CAAC,AAVD,CAAkD,sBAAS,GAU1D"} \ No newline at end of file diff --git a/dist/errors/itemNotFoundError.d.ts b/dist/errors/itemNotFoundError.d.ts index eb63f14..f0b7071 100644 --- a/dist/errors/itemNotFoundError.d.ts +++ b/dist/errors/itemNotFoundError.d.ts @@ -1,6 +1,6 @@ import { BaseError } from "make-error"; export default class ItemNotFoundError extends BaseError { readonly itemName: string; - readonly itemId: string; - constructor(itemName: string, itemId: string); + readonly itemId?: string; + constructor(itemName: string, itemId?: string); } diff --git a/dist/errors/itemNotFoundError.js.map b/dist/errors/itemNotFoundError.js.map index 147a6c9..76f0e44 100644 --- a/dist/errors/itemNotFoundError.js.map +++ b/dist/errors/itemNotFoundError.js.map @@ -1 +1 @@ -{"version":3,"file":"ItemNotFoundError.js","sourceRoot":"","sources":["../../src/errors/ItemNotFoundError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAuC;AAEvC;IAA+C,qCAAS;IAKtD,2BAAmB,QAAgB,EAAE,MAAc;QAAnD,YACE,iBAAO,SAGR;QAFC,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;IACvB,CAAC;IACH,wBAAC;AAAD,CAAC,AAVD,CAA+C,sBAAS,GAUvD"} \ No newline at end of file +{"version":3,"file":"ItemNotFoundError.js","sourceRoot":"","sources":["../../src/errors/ItemNotFoundError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAuC;AAEvC;IAA+C,qCAAS;IAKtD,2BAAmB,QAAgB,EAAE,MAAe;QAApD,YACE,iBAAO,SAGR;QAFC,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;IACvB,CAAC;IACH,wBAAC;AAAD,CAAC,AAVD,CAA+C,sBAAS,GAUvD"} \ No newline at end of file diff --git a/dist/facade.d.ts b/dist/facade.d.ts index 1e8f7d6..b4d6514 100644 --- a/dist/facade.d.ts +++ b/dist/facade.d.ts @@ -8,7 +8,7 @@ import ReplaceItem from "./functions/ReplaceItem"; import UpdateItem from "./functions/UpdateItem"; import Item from "./interfaces/Item"; export default interface Facade { - readonly countItems: CountItems; + readonly countItems?: CountItems; readonly createItem: CreateItem; readonly getItem: GetItem; readonly getItems: GetItems; diff --git a/dist/functions/countItems/test.d.ts b/dist/functions/countItems/test.d.ts index 5f97cc4..03ca4d6 100644 --- a/dist/functions/countItems/test.d.ts +++ b/dist/functions/countItems/test.d.ts @@ -1,4 +1,4 @@ -import Options from "../../interfaces/Options"; -import { TestItem } from "../utils/testItem"; +import Options from '../../interfaces/Options'; +import { TestItem } from '../utils/testItem'; declare const _default: ({ facade }: Options) => void; export default _default; diff --git a/dist/functions/countItems/test.js b/dist/functions/countItems/test.js index d876d04..2d7f2b8 100644 --- a/dist/functions/countItems/test.js +++ b/dist/functions/countItems/test.js @@ -42,62 +42,64 @@ Object.defineProperty(exports, "__esModule", { value: true }); var testUsingFilter_1 = __importDefault(require("../utils/testUsingFilter")); exports.default = (function (_a) { var facade = _a.facade; - describe("countItems", function () { - testUsingFilter_1.default({ - facade: facade, - toGetAllItems: function (filter) { return __awaiter(_this, void 0, void 0, function () { - var count, expectedCount; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, facade.countItems({ filter: filter })]; - case 1: - count = (_a.sent()).count; - expectedCount = 2; - expect(count).toBe(expectedCount); - return [2 /*return*/]; - } - }); - }); }, - toGetFirstItem: function (filter) { return __awaiter(_this, void 0, void 0, function () { - var count, expectedCount; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, facade.countItems({ filter: filter })]; - case 1: - count = (_a.sent()).count; - expectedCount = 1; - expect(count).toBe(expectedCount); - return [2 /*return*/]; - } - }); - }); }, - toGetNoItems: function (filter) { return __awaiter(_this, void 0, void 0, function () { - var count, expectedCount; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, facade.countItems({ filter: filter })]; - case 1: - count = (_a.sent()).count; - expectedCount = 0; - expect(count).toBe(expectedCount); - return [2 /*return*/]; - } - }); - }); }, - toGetSecondItem: function (filter) { return __awaiter(_this, void 0, void 0, function () { - var count, expectedCount; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, facade.countItems({ filter: filter })]; - case 1: - count = (_a.sent()).count; - expectedCount = 1; - expect(count).toBe(expectedCount); - return [2 /*return*/]; - } - }); - }); } + if (facade.countItems !== undefined) { + describe('countItems', function () { + testUsingFilter_1.default({ + facade: facade, + toGetAllItems: function (filter) { return __awaiter(_this, void 0, void 0, function () { + var count, expectedCount; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, facade.countItems({ filter: filter })]; + case 1: + count = (_a.sent()).count; + expectedCount = 2; + expect(count).toBe(expectedCount); + return [2 /*return*/]; + } + }); + }); }, + toGetFirstItem: function (filter) { return __awaiter(_this, void 0, void 0, function () { + var count, expectedCount; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, facade.countItems({ filter: filter })]; + case 1: + count = (_a.sent()).count; + expectedCount = 1; + expect(count).toBe(expectedCount); + return [2 /*return*/]; + } + }); + }); }, + toGetNoItems: function (filter) { return __awaiter(_this, void 0, void 0, function () { + var count, expectedCount; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, facade.countItems({ filter: filter })]; + case 1: + count = (_a.sent()).count; + expectedCount = 0; + expect(count).toBe(expectedCount); + return [2 /*return*/]; + } + }); + }); }, + toGetSecondItem: function (filter) { return __awaiter(_this, void 0, void 0, function () { + var count, expectedCount; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, facade.countItems({ filter: filter })]; + case 1: + count = (_a.sent()).count; + expectedCount = 1; + expect(count).toBe(expectedCount); + return [2 /*return*/]; + } + }); + }); }, + }); }); - }); + } }); //# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/dist/functions/countItems/test.js.map b/dist/functions/countItems/test.js.map index 220573e..0a6b51e 100644 --- a/dist/functions/countItems/test.js.map +++ b/dist/functions/countItems/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../src/functions/CountItems/test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iBA+BA;;AA7BA,6EAAuD;AAEvD,mBAAe,UAAC,EAA6B;QAA3B,kBAAM;IACtB,QAAQ,CAAC,YAAY,EAAE;QACrB,yBAAe,CAAC;YACd,MAAM,QAAA;YACN,aAAa,EAAE,UAAM,MAAM;;;;gCACP,qBAAM,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;;4BAA7C,KAAK,GAAK,CAAA,SAAmC,CAAA,MAAxC;4BACP,aAAa,GAAG,CAAC,CAAC;4BACxB,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;;;;iBACnC;YACD,cAAc,EAAE,UAAM,MAAM;;;;gCACR,qBAAM,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;;4BAA7C,KAAK,GAAK,CAAA,SAAmC,CAAA,MAAxC;4BACP,aAAa,GAAG,CAAC,CAAC;4BACxB,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;;;;iBACnC;YACD,YAAY,EAAE,UAAM,MAAM;;;;gCACN,qBAAM,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;;4BAA7C,KAAK,GAAK,CAAA,SAAmC,CAAA,MAAxC;4BACP,aAAa,GAAG,CAAC,CAAC;4BACxB,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;;;;iBACnC;YACD,eAAe,EAAE,UAAM,MAAM;;;;gCACT,qBAAM,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;;4BAA7C,KAAK,GAAK,CAAA,SAAmC,CAAA,MAAxC;4BACP,aAAa,GAAG,CAAC,CAAC;4BACxB,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;;;;iBACnC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,EAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../src/functions/CountItems/test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iBAiCA;;AA/BA,6EAAuD;AAEvD,mBAAe,UAAC,EAA6B;QAA3B,kBAAM;IACtB,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE;QACnC,QAAQ,CAAC,YAAY,EAAE;YACrB,yBAAe,CAAC;gBACd,MAAM,QAAA;gBACN,aAAa,EAAE,UAAM,MAAM;;;;oCACP,qBAAO,MAAc,CAAC,UAAU,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;;gCAAtD,KAAK,GAAK,CAAA,SAA4C,CAAA,MAAjD;gCACP,aAAa,GAAG,CAAC,CAAC;gCACxB,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;;;;qBACnC;gBACD,cAAc,EAAE,UAAM,MAAM;;;;oCACR,qBAAO,MAAc,CAAC,UAAU,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;;gCAAtD,KAAK,GAAK,CAAA,SAA4C,CAAA,MAAjD;gCACP,aAAa,GAAG,CAAC,CAAC;gCACxB,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;;;;qBACnC;gBACD,YAAY,EAAE,UAAM,MAAM;;;;oCACN,qBAAO,MAAc,CAAC,UAAU,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;;gCAAtD,KAAK,GAAK,CAAA,SAA4C,CAAA,MAAjD;gCACP,aAAa,GAAG,CAAC,CAAC;gCACxB,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;;;;qBACnC;gBACD,eAAe,EAAE,UAAM,MAAM;;;;oCACT,qBAAO,MAAc,CAAC,UAAU,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,EAAA;;gCAAtD,KAAK,GAAK,CAAA,SAA4C,CAAA,MAAjD;gCACP,aAAa,GAAG,CAAC,CAAC;gCACxB,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;;;;qBACnC;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;KACJ;AACH,CAAC,EAAC"} \ No newline at end of file diff --git a/dist/functions/createItem/index.d.ts b/dist/functions/createItem/index.d.ts index 3ecb558..6edd16a 100644 --- a/dist/functions/createItem/index.d.ts +++ b/dist/functions/createItem/index.d.ts @@ -1,6 +1,6 @@ import Item from '../../interfaces/Item'; export interface Options { - readonly id: string; + readonly id?: string; readonly item: I; } export interface Result { diff --git a/dist/testFacade.d.ts b/dist/testFacade.d.ts index 984fcf2..45ec859 100644 --- a/dist/testFacade.d.ts +++ b/dist/testFacade.d.ts @@ -1,4 +1,4 @@ -import { TestItem } from "./functions/utils/testItem"; -import Options from "./interfaces/Options"; +import { TestItem } from './functions/utils/testItem'; +import Options from './interfaces/Options'; declare const _default: (options: Options) => void; export default _default; diff --git a/dist/testFacade.js b/dist/testFacade.js index eb5213c..362195a 100644 --- a/dist/testFacade.js +++ b/dist/testFacade.js @@ -48,7 +48,7 @@ var test_6 = __importDefault(require("./functions/GetItems/test")); var test_7 = __importDefault(require("./functions/ReplaceItem/test")); var test_8 = __importDefault(require("./functions/UpdateItem/test")); exports.default = (function (options) { - describe("testFacade", function () { + describe('testFacade', function () { beforeEach(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { @@ -59,7 +59,9 @@ exports.default = (function (options) { } }); }); }); - test_1.default(options); + if (options.facade.countItems !== undefined) { + test_1.default(options); + } test_2.default(options); test_3.default(options); test_4.default(options); diff --git a/dist/testFacade.js.map b/dist/testFacade.js.map index 65a8503..f03823a 100644 --- a/dist/testFacade.js.map +++ b/dist/testFacade.js.map @@ -1 +1 @@ -{"version":3,"file":"testFacade.js","sourceRoot":"","sources":["../src/testFacade.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iBA2BA;;AA3BA,qEAAyD;AACzD,qEAAyD;AACzD,qEAAyD;AACzD,sEAA2D;AAC3D,kEAAmD;AACnD,mEAAqD;AACrD,sEAA2D;AAC3D,qEAAyD;AAIzD,mBAAe,UAAC,OAA0B;IACxC,QAAQ,CAAC,YAAY,EAAE;QACrB,UAAU,CAAC;;;4BACT,qBAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAA;;wBAAhD,SAAgD,CAAC;;;;aAClD,CAAC,CAAC;QAEH,cAAc,CAAC,OAAO,CAAC,CAAC;QACxB,cAAc,CAAC,OAAO,CAAC,CAAC;QACxB,cAAc,CAAC,OAAO,CAAC,CAAC;QACxB,cAAe,CAAC,OAAO,CAAC,CAAC;QACzB,cAAW,CAAC,OAAO,CAAC,CAAC;QACrB,cAAY,CAAC,OAAO,CAAC,CAAC;QACtB,cAAe,CAAC,OAAO,CAAC,CAAC;QACzB,cAAc,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,EAAC"} \ No newline at end of file +{"version":3,"file":"testFacade.js","sourceRoot":"","sources":["../src/testFacade.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iBA4BA;;AA5BA,qEAAyD;AACzD,qEAAyD;AACzD,qEAAyD;AACzD,sEAA2D;AAC3D,kEAAmD;AACnD,mEAAqD;AACrD,sEAA2D;AAC3D,qEAAyD;AAIzD,mBAAe,UAAC,OAA0B;IACxC,QAAQ,CAAC,YAAY,EAAE;QACrB,UAAU,CAAC;;;4BACT,qBAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAA;;wBAAhD,SAAgD,CAAC;;;;aAClD,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE;YAC3C,cAAc,CAAC,OAAO,CAAC,CAAC;SACzB;QACD,cAAc,CAAC,OAAO,CAAC,CAAC;QACxB,cAAc,CAAC,OAAO,CAAC,CAAC;QACxB,cAAe,CAAC,OAAO,CAAC,CAAC;QACzB,cAAW,CAAC,OAAO,CAAC,CAAC;QACrB,cAAY,CAAC,OAAO,CAAC,CAAC;QACtB,cAAe,CAAC,OAAO,CAAC,CAAC;QACzB,cAAc,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,EAAC"} \ No newline at end of file diff --git a/src/Facade.ts b/src/Facade.ts index f534762..c0c95d1 100644 --- a/src/Facade.ts +++ b/src/Facade.ts @@ -9,7 +9,7 @@ import UpdateItem from "./functions/UpdateItem"; import Item from "./interfaces/Item"; export default interface Facade { - readonly countItems: CountItems; + readonly countItems?: CountItems; readonly createItem: CreateItem; readonly getItem: GetItem; readonly getItems: GetItems; diff --git a/src/errors/ConflictingItemError.ts b/src/errors/ConflictingItemError.ts index 9bd4623..c7eb1cc 100644 --- a/src/errors/ConflictingItemError.ts +++ b/src/errors/ConflictingItemError.ts @@ -3,9 +3,9 @@ import { BaseError } from "make-error"; export default class ConflictingItemError extends BaseError { public readonly itemName: string; - public readonly itemId: string; + public readonly itemId?: string; - public constructor(itemName: string, itemId: string){ + public constructor(itemName: string, itemId?: string){ super(); this.itemName = itemName; this.itemId = itemId; diff --git a/src/errors/ItemNotFoundError.ts b/src/errors/ItemNotFoundError.ts index bc7c964..14b6ba4 100644 --- a/src/errors/ItemNotFoundError.ts +++ b/src/errors/ItemNotFoundError.ts @@ -3,9 +3,9 @@ import { BaseError } from "make-error"; export default class ItemNotFoundError extends BaseError { public readonly itemName: string; - public readonly itemId: string; + public readonly itemId?: string; - public constructor(itemName: string, itemId: string){ + public constructor(itemName: string, itemId?: string){ super(); this.itemName = itemName; this.itemId = itemId; diff --git a/src/functions/CountItems/test.ts b/src/functions/CountItems/test.ts index 236e320..ed6e00c 100644 --- a/src/functions/CountItems/test.ts +++ b/src/functions/CountItems/test.ts @@ -1,31 +1,34 @@ -import Options from "../../interfaces/Options"; -import { TestItem } from "../utils/testItem"; -import testUsingFilter from "../utils/testUsingFilter"; +// tslint:disable:no-any +import Options from '../../interfaces/Options'; +import { TestItem } from '../utils/testItem'; +import testUsingFilter from '../utils/testUsingFilter'; export default ({ facade }: Options) => { - describe("countItems", () => { - testUsingFilter({ - facade, - toGetAllItems: async filter => { - const { count } = await facade.countItems({ filter }); - const expectedCount = 2; - expect(count).toBe(expectedCount); - }, - toGetFirstItem: async filter => { - const { count } = await facade.countItems({ filter }); - const expectedCount = 1; - expect(count).toBe(expectedCount); - }, - toGetNoItems: async filter => { - const { count } = await facade.countItems({ filter }); - const expectedCount = 0; - expect(count).toBe(expectedCount); - }, - toGetSecondItem: async filter => { - const { count } = await facade.countItems({ filter }); - const expectedCount = 1; - expect(count).toBe(expectedCount); - } + if (facade.countItems !== undefined) { + describe('countItems', () => { + testUsingFilter({ + facade, + toGetAllItems: async filter => { + const { count } = await (facade as any).countItems({ filter }); + const expectedCount = 2; + expect(count).toBe(expectedCount); + }, + toGetFirstItem: async filter => { + const { count } = await (facade as any).countItems({ filter }); + const expectedCount = 1; + expect(count).toBe(expectedCount); + }, + toGetNoItems: async filter => { + const { count } = await (facade as any).countItems({ filter }); + const expectedCount = 0; + expect(count).toBe(expectedCount); + }, + toGetSecondItem: async filter => { + const { count } = await (facade as any).countItems({ filter }); + const expectedCount = 1; + expect(count).toBe(expectedCount); + }, + }); }); - }); + } }; diff --git a/src/functions/CreateItem/index.ts b/src/functions/CreateItem/index.ts index ec34aa5..ae3f3ba 100644 --- a/src/functions/CreateItem/index.ts +++ b/src/functions/CreateItem/index.ts @@ -1,7 +1,7 @@ import Item from '../../interfaces/Item'; export interface Options { - readonly id: string; + readonly id?: string; readonly item: I; } diff --git a/src/testFacade.ts b/src/testFacade.ts index 9ec32f1..0eb00ec 100644 --- a/src/testFacade.ts +++ b/src/testFacade.ts @@ -1,21 +1,22 @@ -import testCountItems from "./functions/CountItems/test"; -import testCreateItem from "./functions/CreateItem/test"; -import testDeleteItem from "./functions/DeleteItem/test"; -import testDeleteItems from "./functions/DeleteItems/test"; -import testGetItem from "./functions/GetItem/test"; -import testGetItems from "./functions/GetItems/test"; -import testReplaceItem from "./functions/ReplaceItem/test"; -import testUpdateItem from "./functions/UpdateItem/test"; -import { TestItem } from "./functions/utils/testItem"; -import Options from "./interfaces/Options"; +import testCountItems from './functions/CountItems/test'; +import testCreateItem from './functions/CreateItem/test'; +import testDeleteItem from './functions/DeleteItem/test'; +import testDeleteItems from './functions/DeleteItems/test'; +import testGetItem from './functions/GetItem/test'; +import testGetItems from './functions/GetItems/test'; +import testReplaceItem from './functions/ReplaceItem/test'; +import testUpdateItem from './functions/UpdateItem/test'; +import { TestItem } from './functions/utils/testItem'; +import Options from './interfaces/Options'; export default (options: Options) => { - describe("testFacade", () => { + describe('testFacade', () => { beforeEach(async () => { await options.facade.deleteItems({ filter: {} }); }); - - testCountItems(options); + if (options.facade.countItems !== undefined) { + testCountItems(options); + } testCreateItem(options); testDeleteItem(options); testDeleteItems(options);