diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 88617c8..0000000 --- a/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -**/bin/ -**/obj/ -CourseApp.Tests/ -CourseApp/CourseApp.sln \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..2cfa619 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,22 @@ +module.exports = { + "env": { + "browser": true, + "es2021": true + }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended" + ], + "overrides": [ + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + } +} diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml deleted file mode 100644 index dffe441..0000000 --- a/.github/workflows/dotnetcore.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: .NET Core - -on: [push, pull_request] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - dotnet: [ '2.1', '5.0.x', '6.0.x' ] - - steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: ${{ matrix.dotnet-version }} - include-prerelease: true - - name: Build with dotnet - run: | - cd CourseApp - dotnet build --configuration Release - - name: Run tests - run: | - cd CourseApp.Tests - dotnet test diff --git a/.gitignore b/.gitignore index 12f59b6..755a027 100644 --- a/.gitignore +++ b/.gitignore @@ -1,206 +1,3 @@ -# Download this file using PowerShell v3 under Windows with the following comand: -# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore -# or wget: -# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# OS generated files # -.DS_Store* -Icon? - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -*.Cache -ClientBin/ -# [Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings -modulesbin/ -tempbin/ - -# EPiServer Site file (VPP) -AppData/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# vim -*.txt~ -*.swp -*.swo - -# svn -.svn - -# Remainings from resolvings conflicts in Source Control -*.orig - -# SQL Server files -**/App_Data/*.mdf -**/App_Data/*.ldf -**/App_Data/*.sdf - - -#LightSwitch generated files -GeneratedArtifacts/ -_Pvt_Extensions/ -ModelManifest.xml - -# ========================= -# Windows detritus -# ========================= - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac desktop service store files -.DS_Store - -# SASS Compiler cache -.sass-cache - -# Visual Studio 2014 CTP -**/*.sln.ide - -# Visual Studio temp something -.vs/ - -# VS 2015+ -*.vc.vc.opendb -*.vc.db - -# Rider -.idea/ - -**/node_modules/* - -# Added by Jskonst -# .vscode/ -Properties/ - -##### -# End of core ignore list, below put you custom 'per project' settings (patterns or path) -##### \ No newline at end of file +node_modules +package-lock.json +dist/**/* \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index e2cc5c5..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "files.exclude": { - "**/.git": true, - "**/.svn": true, - "**/CVS": true, - "**/.DS_Store": true, - "CourseApp": true, - "CourseApp.Tests":true, - "WebApplication":true - } -} \ No newline at end of file diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj deleted file mode 100644 index e43252f..0000000 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - net6.0 - True - false - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - ../_stylecop/stylecop.ruleset - true - - - - - - - diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs deleted file mode 100644 index cf7cbb1..0000000 --- a/CourseApp.Tests/DemoTest.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CourseApp.Tests -{ - using Xunit; - - public class DemoTest - { - [Fact] - public void Test1() - { - Assert.True(true); - } - } -} diff --git a/CourseApp.sln b/CourseApp.sln deleted file mode 100644 index 12714a0..0000000 --- a/CourseApp.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.32014.148 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "CourseApp\CourseApp.csproj", "{F069B4EF-B995-4AF8-8E63-770D1E0A0884}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "CourseApp.Tests\CourseApp.Tests.csproj", "{3F66714D-FFFA-4512-A62B-4D038AB148AD}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F069B4EF-B995-4AF8-8E63-770D1E0A0884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F069B4EF-B995-4AF8-8E63-770D1E0A0884}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F069B4EF-B995-4AF8-8E63-770D1E0A0884}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F069B4EF-B995-4AF8-8E63-770D1E0A0884}.Release|Any CPU.Build.0 = Release|Any CPU - {3F66714D-FFFA-4512-A62B-4D038AB148AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3F66714D-FFFA-4512-A62B-4D038AB148AD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3F66714D-FFFA-4512-A62B-4D038AB148AD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3F66714D-FFFA-4512-A62B-4D038AB148AD}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {064E603C-674E-4DB9-A061-4B08C0ACD98C} - EndGlobalSection -EndGlobal diff --git a/CourseApp/.vscode/launch.json b/CourseApp/.vscode/launch.json deleted file mode 100644 index 211a200..0000000 --- a/CourseApp/.vscode/launch.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceFolder}/bin/Debug/net6.0/CourseApp.dll", - "args": [], - "cwd": "${workspaceFolder}", - "console": "internalConsole", - "stopAtEntry": false - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" - } - ] -} \ No newline at end of file diff --git a/CourseApp/.vscode/tasks.json b/CourseApp/.vscode/tasks.json deleted file mode 100644 index f8c71cd..0000000 --- a/CourseApp/.vscode/tasks.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "dotnet", - "type": "process", - "args": [ - "build", - "${workspaceFolder}/CourseApp.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "publish", - "command": "dotnet", - "type": "process", - "args": [ - "publish", - "${workspaceFolder}/CourseApp.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "watch", - "command": "dotnet", - "type": "process", - "args": [ - "watch", - "run", - "${workspaceFolder}/CourseApp.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - } - ] -} \ No newline at end of file diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj deleted file mode 100644 index eb22147..0000000 --- a/CourseApp/CourseApp.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - Exe - net6.0 - True - - - - - - - - ../_stylecop/stylecop.ruleset - true - - - - - - - diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs deleted file mode 100644 index d6d2c87..0000000 --- a/CourseApp/Program.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CourseApp -{ - using System; - - public class Program - { - public static void Main(string[] args) - { - Console.WriteLine("Hello World"); - } - } -} diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index b2a2650..0000000 --- a/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:5.0 AS build-env -WORKDIR /app - -# Copy csproj and restore as distinct layers -COPY ./CourseApp/*.csproj ./ -RUN dotnet restore - -# Copy everything else and build -COPY ./CourseApp/* ./ -COPY ./_stylecop/ /_stylecop/ -RUN dotnet publish -c Release -o out - -# Build runtime image -FROM mcr.microsoft.com/dotnet/core/aspnet:5.0 -WORKDIR /app -COPY --from=build-env /app/out . -ENTRYPOINT ["dotnet", "CourseApp.dll"] \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index a79bfa3..0000000 --- a/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Tprogramming 2021 - -Master branch :) - -`docker volume create --name=mssqldata` - -### Adding migrations - -To create initial migration in the console please add the following commands. First of all you need to install migration [tools](https://docs.microsoft.com/ru-ru/ef/core/cli/dotnet). - -``` -dotnet tool install --global dotnet-ef -dotnet tool update --global dotnet-ef -``` -Restart you terminal/VScode - and check the following command in terminal. -``` -dotnet ef -``` - -**Note!** If you faced with issues ant the command was not executed - check you environmental variables. For windows in `Path` variable you should be able to see - -``` -%USERPROFILE%\.dotnet\tools -``` - -Execute next command strictly in the `WebApplication` folder - -``` -dotnet add package Microsoft.EntityFrameworkCore.Design -``` - -Finally you may work with migration (from `WebApplication` folder). The following command will create initial migration. - -``` -dotnet ef migrations add InitialMigration -``` \ No newline at end of file diff --git a/_stylecop/stylecop.json b/_stylecop/stylecop.json deleted file mode 100644 index 4a96e8f..0000000 --- a/_stylecop/stylecop.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", - "settings": { - "documentationRules": { - "documentExposedElements": false, - "documentInterfaces": false, - "companyName": "Test Company", - "copyrightText": "This source code is Copyright © {companyName} and MAY NOT be copied, reproduced,\npublished, distributed or transmitted to or stored in any manner without prior\nwritten consent from {companyName} (www.yourcompany.com).", - "xmlHeader":false - } - } -} \ No newline at end of file diff --git a/_stylecop/stylecop.ruleset b/_stylecop/stylecop.ruleset deleted file mode 100644 index f109ca9..0000000 --- a/_stylecop/stylecop.ruleset +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/courseworkspace.code-workspace b/courseworkspace.code-workspace deleted file mode 100644 index 38f6cc3..0000000 --- a/courseworkspace.code-workspace +++ /dev/null @@ -1,22 +0,0 @@ -{ - "folders": [ - { - "path": "CourseApp" - }, - { - "path": "CourseApp.Tests" - }, - { - "name": "Configs (Root)", - "path": "." - }, - ], - "settings": {}, - "extensions": { - "recommendations": [ - "ms-azuretools.vscode-docker", - "ms-dotnettools.csharp", - "ms-mssql.mssql" - ] - } -} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 30b0b11..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: '3' -services: - mssql: - image: mcr.microsoft.com/mssql/server:2019-latest - ports: - - 4433:1433 - environment: - - ACCEPT_EULA=Y - - SA_PASSWORD=Secret1234 - volumes: - - mssqldata:/var/opt/mssql - - ./database/backup:/var/opt/mssql/backup -volumes: - mssqldata: - external: true \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..eaf7069 --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "dish", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "dev": "ts-node --script-mode src/index.ts", + "test": "jest", + "lint": "eslint src --ext .js --ext .jsx --ext .ts --ext .tsx", + "lint:fix": "npm run lint -- --fix" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "@types/jest": "^27.0.3", + "@types/node": "^16.11.0", + "@typescript-eslint/eslint-plugin": "^5.38.1", + "@typescript-eslint/parser": "^5.38.1", + "eslint": "^7.28.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-import": "^2.23.4", + "eslint-plugin-prettier": "^3.4.0", + "jest": "^27.2.5", + "prettier": "^2.4.1", + "ts-jest": "^27.1.2", + "ts-node": "^10.3.0", + "typescript": "^4.4.4" + }, + "jest": { + "preset": "ts-jest" + } +} diff --git a/src/classes/cake.ts b/src/classes/cake.ts new file mode 100644 index 0000000..92c553b --- /dev/null +++ b/src/classes/cake.ts @@ -0,0 +1,25 @@ +import { Dish } from "../dish"; + +export class Cake extends Dish { + constructor(nameOfDish: string, price: number, ingrediens?: number, description?: string) { + super(nameOfDish, price, ingrediens, description); + } + + getMethodCooking(): string { + return `Cake is cooking!`; + } + + getCakeInfo(): string { + return `Cake (name: ${this.nameOfDish} price: ${this.price} ingrediens: ${this.ingrediens} description: ${this.description})`; + } + + methodCooking(): void { + const cook = this.getMethodCooking(); + console.log(cook); + } + + toString(): void { + const info = this.getCakeInfo(); + console.log(info); + } +} \ No newline at end of file diff --git a/src/classes/steak.ts b/src/classes/steak.ts new file mode 100644 index 0000000..2dc8627 --- /dev/null +++ b/src/classes/steak.ts @@ -0,0 +1,25 @@ +import { Dish } from "../dish"; + +export class Steak extends Dish { + constructor(nameOfDish: string, price: number, ingrediens?: number, description?: string) { + super(nameOfDish, price, ingrediens, description); + } + + getMethodCooking(): string { + return `Steak is cooking!`; + } + + getSteakInfo(): string { + return `Steak (name: ${this.nameOfDish} price: ${this.price} ingrediens: ${this.ingrediens} description: ${this.description})`; + } + + methodCooking(): void { + const cook = this.getMethodCooking(); + console.log(cook); + } + + toString(): void { + const info = this.getSteakInfo(); + console.log(info); + } +} \ No newline at end of file diff --git a/src/dish.ts b/src/dish.ts new file mode 100644 index 0000000..e49418e --- /dev/null +++ b/src/dish.ts @@ -0,0 +1,92 @@ +export abstract class Dish { + protected price: number; + protected ingrediens: number; + protected nameOfDish: string; + protected description: string; + + constructor(nameOfDish: string, price: number, ingrediens?: number, + description?: string) { + this.Name = nameOfDish; + this.Price = price; + + if (ingrediens) { + this.Ingrediens = ingrediens + } else { + this.Ingrediens = 1; + } + + if (description) { + this.Description = description; + } else { + this.Description = "UNDEFINED!!!"; + } + } + + get Name(): string { + return this.nameOfDish; + } + + set Name(name: string) { + if (name.length <= 2) { + throw new Error(); + } + + this.nameOfDish = name; + } + + get Price(): number { + return this.price; + } + + set Price(price: number) { + if (price == 0) { + throw new Error(); + } + + this.price = price; + } + + get Ingrediens(): number { + return this.ingrediens; + } + + set Ingrediens(ingrediens: number) { + if (ingrediens == 0) { + throw new Error(); + } + + this.ingrediens = ingrediens; + } + + get Description(): string { + return this.description; + } + + set Description(description: string) { + if (description.length < 10) { + throw new Error(); + } + + this.description = description; + } + + abstract methodCooking(): void; + + getInformation(): string { + return `Dish\nName: ${this.nameOfDish}\nPrice: ${this.price}\nDescription: ${this.description}\nIngrediens: ${this.ingrediens}`; + } + + displayInformation(): void { + const information = this.getInformation(); + console.log(information); + } + + getOrderDish(): string { + return `Your Dish is ${this.nameOfDish}`; + } + + orderDish(): void { + const dish = this.getOrderDish(); + console.log(dish); + } +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..66f4090 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,19 @@ +import { Cake } from "./classes/cake"; +import { Steak } from "./classes/steak"; +import { Dish } from "./dish"; + +const cake = new Cake("cake", 100); +cake.displayInformation() +cake.orderDish(); +cake.Price = 200; +cake.displayInformation(); +cake.toString(); + +const steak = new Steak("steak", 600, 1, "The best steak ever"); +steak.displayInformation(); +steak.Name = "Steak!!!"; +steak.orderDish(); +steak.toString(); + +const array: Dish[] = [cake, steak]; +array.forEach((value) => value.methodCooking()); diff --git a/tests/access.spec.ts b/tests/access.spec.ts new file mode 100644 index 0000000..ae28547 --- /dev/null +++ b/tests/access.spec.ts @@ -0,0 +1,84 @@ +import { Cake } from "../src/classes/cake"; +import { Steak } from "../src/classes/steak"; + +describe('Access Method Get', () => { + it('name', () => { + const name = "Cakee"; + const price = 200; + const cake = new Cake(name, price); + + expect(cake.Name).toEqual(name); + }); + + it('price', () => { + const name = "Steakk"; + const price = 499; + const steak = new Steak(name, price); + + expect(steak.Price).toEqual(price); + }); + + it('ingrediens', () => { + const name = "Steakk"; + const price = 499; + const ingrediens = 3; + const steak = new Steak(name, price, ingrediens); + + expect(steak.Ingrediens).toEqual(ingrediens); + }); + + it('description', () => { + const name = "Steakk"; + const price = 499; + const ingrediens = 3; + const description = "This is a test description"; + const steak = new Steak(name, price, ingrediens, description); + + expect(steak.Description).toEqual(description); + }); +}); + +describe('Access Method Set', () => { + it('name', () => { + let name = "Cakee"; + const price = 200; + const cake = new Cake(name, price); + name = "ULTRA CAKE" + cake.Name = name; + + expect(cake.Name).toEqual(name); + }); + + it('price', () => { + const name = "Steakk"; + let price = 499; + const steak = new Steak(name, price); + price = 200; + steak.Price = price; + + expect(steak.Price).toEqual(price); + }); + + it('ingrediens', () => { + const name = "Steakk"; + const price = 499; + let ingrediens = 3; + const steak = new Steak(name, price, ingrediens); + ingrediens = 4; + steak.Ingrediens = ingrediens; + + expect(steak.Ingrediens).toEqual(ingrediens); + }); + + it('description', () => { + const name = "Steakk"; + const price = 499; + const ingrediens = 3; + let description = "This is a test description"; + const steak = new Steak(name, price, ingrediens, description); + description = "This is a teeest description"; + steak.Description = description; + + expect(steak.Description).toEqual(description); + }); +}); \ No newline at end of file diff --git a/tests/cake.spec.ts b/tests/cake.spec.ts new file mode 100644 index 0000000..ada6adc --- /dev/null +++ b/tests/cake.spec.ts @@ -0,0 +1,27 @@ +import { Cake } from "../src/classes/cake"; + +describe('Cake', () => { + it('get cake method cooking', () => { + const name = "Cakee"; + const price = 300; + const ingrediens = 3; + const description = "This is a usually cake"; + const cake = new Cake(name, price, ingrediens, description); + + const information = `Cake is cooking!`; + + expect(cake.getMethodCooking()).toEqual(information); + }); + + it('get cake info', () => { + const name = "Cakeee"; + const price = 499; + const ingrediens = 1; + const description = "This is a usually cake"; + const cake = new Cake(name, price, ingrediens, description); + + const info = `Cake (name: ${name} price: ${price} ingrediens: ${ingrediens} description: ${description})`; + + expect(cake.getCakeInfo()).toEqual(info); + }); +}); \ No newline at end of file diff --git a/tests/constructors.spec.ts b/tests/constructors.spec.ts new file mode 100644 index 0000000..d276614 --- /dev/null +++ b/tests/constructors.spec.ts @@ -0,0 +1,49 @@ +import { Cake } from "../src/classes/cake"; +import { Steak } from "../src/classes/steak"; + +describe('Constructors', () => { + it('all parameters', () => { + const name = "Cakee"; + const price = 300; + const ingrediens = 3; + const description = "This is a usually cake"; + let condition = false; + const cake = new Cake(name, price, ingrediens, description); + + if (name == cake.Name && price == cake.Price && ingrediens == cake.Ingrediens && description && cake.Description) { + condition = true; + } + + expect(condition).toBeTruthy(); + }); + + it('three parameters', () => { + const name = "Steakk"; + const price = 499; + const ingrediens = 1; + const description = "UNDEFINED!!!"; + let condition = false; + const steak = new Steak(name, price, ingrediens); + + if (name == steak.Name && price == steak.Price && ingrediens == steak.Ingrediens && description && steak.Description) { + condition = true; + } + + expect(condition).toBeTruthy(); + }); + + it('two parameters', () => { + const name = "Steakk"; + const price = 499; + const ingrediens = 1; + const description = "UNDEFINED!!!"; + let condition = false; + const steak = new Steak(name, price); + + if (name == steak.Name && price == steak.Price && ingrediens == steak.Ingrediens && description && steak.Description) { + condition = true; + } + + expect(condition).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/tests/dish.spec.ts b/tests/dish.spec.ts new file mode 100644 index 0000000..0e2663b --- /dev/null +++ b/tests/dish.spec.ts @@ -0,0 +1,27 @@ +import { Cake } from "../src/classes/cake"; +import { Steak } from "../src/classes/steak"; + +describe('Dish', () => { + it('get information', () => { + const name = "Cakee"; + const price = 300; + const ingrediens = 3; + const description = "This is a usually cake"; + const cake = new Cake(name, price, ingrediens, description); + + const information = `Dish\nName: ${name}\nPrice: ${price}\nDescription: ${description}\nIngrediens: ${ingrediens}`; + + expect(cake.getInformation()).toEqual(information); + }); + + it('get order', () => { + const name = "Steakk"; + const price = 499; + const ingrediens = 1; + const steak = new Steak(name, price, ingrediens); + + const order = `Your Dish is ${name}`; + + expect(steak.getOrderDish()).toEqual(order); + }); +}); \ No newline at end of file diff --git a/tests/steak.spec.ts b/tests/steak.spec.ts new file mode 100644 index 0000000..7bb81f2 --- /dev/null +++ b/tests/steak.spec.ts @@ -0,0 +1,27 @@ +import { Steak } from "../src/classes/steak"; + +describe('Steak', () => { + it('get steak method cooking', () => { + const name = "Steak"; + const price = 300; + const ingrediens = 3; + const description = "This is a usually steak"; + const steak = new Steak(name, price, ingrediens, description); + + const information = `Steak is cooking!`; + + expect(steak.getMethodCooking()).toEqual(information); + }); + + it('get steak info', () => { + const name = "Steak"; + const price = 499; + const ingrediens = 1; + const description = "This is a usually steak"; + const steak = new Steak(name, price, ingrediens, description); + + const info = `Steak (name: ${name} price: ${price} ingrediens: ${ingrediens} description: ${description})`; + + expect(steak.getSteakInfo()).toEqual(info); + }); +}); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..8062b24 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "types": ["jest", "node"], + "target": "ES5", + } +} \ No newline at end of file