Last active
June 19, 2020 11:18
-
-
Save mickaelw/8eeb55c99186d8446c378545be16bd24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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