Skip to content

Instantly share code, notes, and snippets.

@mickaelw
Last active June 19, 2020 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickaelw/8eeb55c99186d8446c378545be16bd24 to your computer and use it in GitHub Desktop.
Save mickaelw/8eeb55c99186d8446c378545be16bd24 to your computer and use it in GitHub Desktop.
describe('Integration | Sequelize customer loader, () => {
const CUSTOMER_ID = 'id'
let customerLoader: CustomerLoader
beforeEach(async () => {
await SequelizeCustomerModel.create({ id: CUSTOMER_ID, name: 'name', email: 'email', phone: 'phone' })
customerLoader = new SequelizeCustomerLoader()
})
afterEach(async () => {
await SequelizeCustomerModel.destroy({ where: { id: CUSTOMER_ID } })
})
it('Récupérer le client', async () => {
const customer = await customerLoader.get(CUSTOMER_ID)
expect(customer).to.eql(new Customer(CUSTOMER_ID, 'name', 'email', 'phone'))
})
it('Le client n’a pas été trouvé', async () => {
try {
await customerLoader.get('unknown')
fail()
} catch (e) {
expect(e).to.instanceOf(CustomerNotFoundError)
expect(e.message).to.eql('customer not found')
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment