This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Force System Language via PowerShell | |
| Run PowerShell as Administrator and execute: | |
| # Set system display language to Polish | |
| Set-WinSystemLocale pl-PL | |
| Set-WinUILanguageOverride pl-PL | |
| Set-WinUserLanguageList pl-PL -Force | |
| Set-Culture pl-PL | |
| Set-WinHomeLocation -GeoId 191 # 191 = Poland |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test("should apply 10% discount if there are exactly 5 business class tickets", () => { | |
| const tickets = Array.from({ length: 5 }, () => ({ | |
| price: 10, | |
| isBusinessClass: true, | |
| })); | |
| const totalPrice = calculator.calculateTotalTicketsPrice(tickets); | |
| expect(totalPrice).toBe(45); // 10% discount | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Ticket } from "./ticket"; | |
| import { TicketsPriceCalculator } from "./ticketsPriceCalculator"; | |
| describe("TicketsPriceCalculator", () => { | |
| let calculator: TicketsPriceCalculator; | |
| beforeEach(() => { | |
| calculator = new TicketsPriceCalculator(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class TicketsPriceCalculator { | |
| calculateTotalTicketsPrice(tickets: Ticket[]): number { | |
| if (tickets.length === 0) { | |
| return 0; | |
| } | |
| let totalPrice = tickets.reduce((sum, ticket) => sum + ticket.price, 0); | |
| const businessClassTickets = tickets.filter( | |
| (ticket) => ticket.isBusinessClass | |
| ).length; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| getAllUsers = async (): Promise<UserViewModel[]> => { | |
| const url = `${this.apiEndpoint}/AllUsers`; | |
| const response = await fetch(url); | |
| const usersJson = await response.json(); | |
| const users = z.array(UserViewModelSchema).parse(usersJson); | |
| return users; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { z } from "zod"; | |
| import { AddressViewModelSchema } from "./addressViewModel"; | |
| export const UserViewModelSchema = z.object({ | |
| id: z.string().uuid(), | |
| name: z.string(), | |
| lastName: z.string(), | |
| login: z.string(), | |
| isActive: z.boolean(), | |
| loyaltyPoints: z.number(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const UserViewModelSchema = z.object({ | |
| id: z.string().uuid(), | |
| name: z.string(), | |
| lastName: z.string(), | |
| login: z.string(), | |
| isActive: z.boolean(), | |
| loyaltyPoints: z.number(), | |
| address: AddressViewModelSchema.nullable(), | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public record UserViewModel(Guid Id, string Name, string LastName, | |
| string Login, bool IsActive, int FidelityPoints, AddressViewModel? Address = null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class UsersService { | |
| private apiEndpoint: string; | |
| constructor() { | |
| this.apiEndpoint = "https://localhost:7131/Users"; | |
| } | |
| getAllUsers = async (): Promise<UserViewModel[]> => { | |
| const url = `${this.apiEndpoint}/AllUsers`; | |
| const response = await fetch(url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export interface UserViewModel { | |
| id: Guid; | |
| name: string; | |
| lastName: string; | |
| login: string; | |
| isActive: boolean; | |
| loyaltyPoints: number; | |
| address: AddressViewModel | null; | |
| } |
NewerOlder