Skip to content

Instantly share code, notes, and snippets.

@chrisza4
Created August 23, 2020 11:11
Show Gist options
  • Select an option

  • Save chrisza4/9ccf1a4b28f8b3fb7d417b851b01b08f to your computer and use it in GitHub Desktop.

Select an option

Save chrisza4/9ccf1a4b28f8b3fb7d417b851b01b08f to your computer and use it in GitHub Desktop.
compare.ts
describe('ProductData.update', () => {
it('can update data', () => {
const context = await Database.InitiateWithOneProduct()
const updatedProduct = await ProductData.update(context.product1.id, { name: 'new' })
expect(updatedProduct.name).toEqual('new')
})
// ถ้าเทสแบบนี้เวลาเราแก้ ProductData.create ให้เป็นแบบอื่นจนฟังก์ชั่น Update ทำงานด้วยไม่ได้ เทสจะไม่พัง
})
describe('ProductData.update', () => {
it('can update data', () => {
const product = ProductData.create({ /* ... */ })
const updatedProduct = await ProductData.update(product.id, { name: 'new' })
expect(updatedProduct.name).toEqual('new')
})
// ถ้าเทสแบบนี้เวลาเราแก้ ProductData.create ให้เป็นแบบอื่นจนฟังก์ชั่น Update ทำงานด้วยไม่ได้ เทสจะฟ้องว่าปัจจุบันมัน Incompatible กันแล้ว
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment