Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.