Skip to content

Commit

Permalink
fix: addressed interfaces issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mariocoski committed Aug 25, 2019
1 parent 5b06e7e commit c369a94
Show file tree
Hide file tree
Showing 18 changed files with 126 additions and 118 deletions.
4 changes: 2 additions & 2 deletions dist/errors/conflictingItemError.d.ts
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion dist/errors/conflictingItemError.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/errors/itemNotFoundError.d.ts
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion dist/errors/itemNotFoundError.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/facade.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ReplaceItem from "./functions/ReplaceItem";
import UpdateItem from "./functions/UpdateItem";
import Item from "./interfaces/Item";
export default interface Facade<I extends Item> {
readonly countItems: CountItems<I>;
readonly countItems?: CountItems<I>;
readonly createItem: CreateItem<I>;
readonly getItem: GetItem<I>;
readonly getItems: GetItems<I>;
Expand Down
4 changes: 2 additions & 2 deletions dist/functions/countItems/test.d.ts
Original file line number Diff line number Diff line change
@@ -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<TestItem>) => void;
export default _default;
114 changes: 58 additions & 56 deletions dist/functions/countItems/test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/functions/countItems/test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/functions/createItem/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Item from '../../interfaces/Item';
export interface Options<I extends Item> {
readonly id: string;
readonly id?: string;
readonly item: I;
}
export interface Result<I extends Item> {
Expand Down
4 changes: 2 additions & 2 deletions dist/testFacade.d.ts
Original file line number Diff line number Diff line change
@@ -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<TestItem>) => void;
export default _default;
6 changes: 4 additions & 2 deletions dist/testFacade.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/testFacade.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UpdateItem from "./functions/UpdateItem";
import Item from "./interfaces/Item";

export default interface Facade<I extends Item> {
readonly countItems: CountItems<I>;
readonly countItems?: CountItems<I>;
readonly createItem: CreateItem<I>;
readonly getItem: GetItem<I>;
readonly getItems: GetItems<I>;
Expand Down
4 changes: 2 additions & 2 deletions src/errors/ConflictingItemError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/errors/ItemNotFoundError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
57 changes: 30 additions & 27 deletions src/functions/CountItems/test.ts
Original file line number Diff line number Diff line change
@@ -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<TestItem>) => {
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);
},
});
});
});
}
};
2 changes: 1 addition & 1 deletion src/functions/CreateItem/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Item from '../../interfaces/Item';

export interface Options<I extends Item> {
readonly id: string;
readonly id?: string;
readonly item: I;
}

Expand Down
27 changes: 14 additions & 13 deletions src/testFacade.ts
Original file line number Diff line number Diff line change
@@ -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<TestItem>) => {
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);
Expand Down

0 comments on commit c369a94

Please sign in to comment.