Last active
June 19, 2020 05:12
-
-
Save mickaelw/8951fa2216f64f7de2773d39b6573cfe 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 | 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