Skip to content

Commit

Permalink
[dsch] fix for example after tsconfig is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
DScheglov committed Nov 15, 2024
1 parent a5bc95a commit 966341d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('ECommerceService', () => {
const fakeDataSource = {
getOrderItems: jest.fn(
(predicate?: (orderItem: OrderItem) => boolean) =>
Promise.resolve(fakeOrderItems.filter(predicate)),
Promise.resolve(fakeOrderItems.filter(predicate != null ? predicate : () => true)),
),
};
const ecommerceService: IECommerceService = new ECommerceService(fakeLogger, fakeDataSource);
Expand Down
8 changes: 4 additions & 4 deletions examples/getting-started/src/Orders/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ describe('Orders', () => {
const orderItem: OrderItem = createOrderItem();

expect(orderItem).toEqual({
id: null,
orderId: null,
sku: null,
id: '',
orderId: '',
sku: '',
unitPrice: 0,
quantity: 0,
});
Expand All @@ -33,7 +33,7 @@ describe('Orders', () => {
const order: Order = createOrder();

expect(order).toEqual({
id: null,
id: '',
items: [],
total: 0,
});
Expand Down
10 changes: 5 additions & 5 deletions examples/getting-started/src/Orders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Order, OrderItem } from './types';
const round2 = (value: number): number => Math.round(value * 100) / 100;

export const createOrderItem = (
id: string = null,
orderId: string = null,
sku: string = null,
id: string = '',
orderId: string = '',
sku: string = '',
unitPrice: number = 0,
quantity: number = 0,
): OrderItem => ({
Expand All @@ -17,14 +17,14 @@ const orderItemPrice = ({ unitPrice, quantity }: OrderItem): number =>
round2(unitPrice * quantity);

export const createOrder = (
id: string = null,
id: string = '',
items: OrderItem[] = [],
total: number = 0,
): Order => ({ id, items, total });

export const ordersFromItems = groupBy(
({ orderId }: OrderItem) => orderId,
(order: Order = createOrder(), orderItem) => {
(order: Order = createOrder(), orderItem) => { // eslint-disable-line default-param-last
order.id = orderItem.orderId;
order.items.push(orderItem);
order.total = round2(order.total + orderItemPrice(orderItem));
Expand Down
4 changes: 2 additions & 2 deletions examples/getting-started/src/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const fakeResponse = (): Express.Response => ({
const fakeRequest = <P extends {} >(params: P = {} as P): Express.Request<P> => ({ params }) as any;

describe('controller.getOrders', () => {
it('sends json recieved from the ecommerceService.getOrders', async () => {
it('sends json received from the ecommerceService.getOrders', async () => {
expect.assertions(4);

const ecommerceService = fakeGetOrdersService([]);
Expand All @@ -39,7 +39,7 @@ describe('controller.getOrders', () => {
});

describe('controller.getOrderById', () => {
it('sends json recieved from the ecommerceService.getOrderById', async () => {
it('sends json received from the ecommerceService.getOrderById', async () => {
expect.assertions(5);
const ecommerceService = fakeGetOrderByIdService([{} as Order]);
const res = fakeResponse();
Expand Down
2 changes: 1 addition & 1 deletion examples/getting-started/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const getOrders = (req: Request, res: Response, next: Next) =>
.getOrders()
.then(sendJson(res), next);

export const getOrderById = ({ params }: Request<{ id: string }>, res: Response, next: Next) =>
export const getOrderById = ({ params }: Request, res: Response, next: Next) =>
({ ecommerceService }: { ecommerceService: IGetOrderById }) =>
ecommerceService
.getOrderById(params.id)
Expand Down
2 changes: 1 addition & 1 deletion examples/getting-started/src/middlewares.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IErrorLogger, IWarnLogger } from './interfaces';
import { handleErrors } from './middlewares';
import { NotFoundError } from './utils/NotFoundError';

function returnThis() { return this; }
function returnThis<T>(this: T): T { return this; }

const fakeResponse = (): Express.Response => ({
status: jest.fn(returnThis),
Expand Down
2 changes: 1 addition & 1 deletion examples/getting-started/src/utils/sendJson.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Express from 'express';
import { sendJson } from './sendJson';

function returnThis() { return this; }
function returnThis<T>(this: T): T { return this; }

const fakeResponse: Express.Response = {
type: jest.fn(returnThis),
Expand Down

0 comments on commit 966341d

Please sign in to comment.