Skip to content

Instantly share code, notes, and snippets.

@mickaelw
Last active June 19, 2020 05:12
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/8951fa2216f64f7de2773d39b6573cfe to your computer and use it in GitHub Desktop.
Save mickaelw/8951fa2216f64f7de2773d39b6573cfe to your computer and use it in GitHub Desktop.
describe('Integration | Gateways | 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('Find the customer', async () => {
const customer = await customerLoader.get(CUSTOMER_ID)
expect(customer).to.eql(new Customer(CUSTOMER_ID, 'name', 'email', 'phone'))
})
it('Not found the customer', 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