Skip to content

Feature/test2 #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: create a constant MAX_STOCK In FlowerStock.test.ts
  • Loading branch information
mbarreche committed Nov 6, 2022
commit db47abe8c5cd6a4eb8ca001f05b85f11e691f5ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { LowStock } from "../src/LowStock"
import { NotEnoughStock } from "../src/NotEnoughStock"
import { OutOfStock } from "../src/OutOfStock"

const MAX_STOCK = 50;
describe('flower stock management', () => {

it('should add a flower to the stock', () => {
Expand Down Expand Up @@ -34,7 +35,7 @@ describe('flower stock management', () => {
})

it('should reach low stock when getting a single flower from a stock of 50', () => {
const stockFlowerIds = makeFlowerIds(50)
const stockFlowerIds = makeFlowerIds(MAX_STOCK)
const stock = new FlowerStock(stockFlowerIds)

stock.get()
Expand All @@ -46,7 +47,7 @@ describe('flower stock management', () => {
})

it('should not reach low stock when getting a single flower from a stock greater than 50', () => {
const flowerIds = makeFlowerIds(51)
const flowerIds = makeFlowerIds(MAX_STOCK + 1)
const stock = new FlowerStock(flowerIds)

stock.get()
Expand All @@ -71,10 +72,9 @@ describe('flower stock management', () => {
})

it('should reach low stock when getting multiple flowers and the limit of 50 is exceeded', () => {
const lowStockLevel = 50
const unitsToLowStock = 5
const unitsToGetFromTheStock = 6
const totalStock = lowStockLevel + unitsToLowStock
const totalStock = MAX_STOCK + unitsToLowStock
const stockFlowerIds = makeFlowerIds(totalStock)
const stock = new FlowerStock(stockFlowerIds)

Expand All @@ -87,10 +87,9 @@ describe('flower stock management', () => {
})

it('should not reach low stock when getting multiple flowers and the limit of 50 is not exceeded', () => {
const lowStockLimit = 50
const unitsToLowStock = 5
const unitsToGetFromTheStock = 5
const totalStock = lowStockLimit + unitsToLowStock
const totalStock = MAX_STOCK + unitsToLowStock
const flowerIds = makeFlowerIds(totalStock)
const stock = new FlowerStock(flowerIds)

Expand Down Expand Up @@ -119,10 +118,9 @@ describe('flower stock management', () => {


it('should reach low stock when removing dead flowers and the limit of 50 is exceeded', () => {
const lowStockLevel = 50
const unitsToLowStock = 5
const totalDeadFlowers = 6
const totalStock = lowStockLevel + unitsToLowStock
const totalStock = MAX_STOCK + unitsToLowStock
const stockFlowerIds = makeFlowerIds(totalStock)
const stock = new FlowerStock(stockFlowerIds)

Expand All @@ -136,10 +134,9 @@ describe('flower stock management', () => {
})

it('should not reach low stock when removing flowers and the limit of 50 is not exceeded', () => {
const lowStockLimit = 50
const unitsToLowStock = 5
const totalDeadFlowers = 5
const totalStock = lowStockLimit + unitsToLowStock
const totalStock = MAX_STOCK + unitsToLowStock
const flowerIds = makeFlowerIds(totalStock)
const stock = new FlowerStock(flowerIds)

Expand Down