mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
const { Shop, Item, RegularItem } = require('../src/gilded_rose')
|
|
|
|
// describe('Gilded Rose', function () {
|
|
// it('should foo', function () {
|
|
// const gildedRose = new Shop([new Item('foo', 0, 0)])
|
|
// const items = gildedRose.updateQuality()
|
|
// expect(items[0].name).toBe('fixme')
|
|
// })
|
|
// })
|
|
|
|
describe('RegularItem', () => {
|
|
const getRegularItemFactory = (itemProps) => () => new RegularItem({
|
|
name: 'Mock RegularItem',
|
|
sellIn: 5,
|
|
quality: 25,
|
|
...itemProps
|
|
})
|
|
|
|
it('should throw an error if initialized with an invalid name', () => {
|
|
expect(getRegularItemFactory({ name: '' })).toThrow()
|
|
})
|
|
|
|
it('should throw an error if initialized with an invalid sellIn property', () => {
|
|
expect(getRegularItemFactory({ sellIn: -1 })).toThrow()
|
|
expect(getRegularItemFactory({ sellIn: 0 })).toThrow()
|
|
})
|
|
|
|
it('should throw an error if initialized with a quality property < 0 || > 50', () => {
|
|
expect(getRegularItemFactory({ quality: -1 })).toThrow()
|
|
expect(getRegularItemFactory({ quality: 51 })).toThrow()
|
|
})
|
|
})
|