Skip to content

Instantly share code, notes, and snippets.

@laugri
laugri / ddd-example-usecase-test.js
Last active December 3, 2018 17:55
DDD Example - use case test
import { articleTestFactory } from '~/domain/article';
import { shoppingCartTestFactory, itemTestFactory } from '~/domain/shoppingCart';
import { InMemoryShoppingCartRepository } from '~/infrastructure/InMemoryShoppingCartRepository';
import { InMemoryArticleRepository } from '~/infrastructure/InMemoryArticleRepository';
describe('addArticleToCart', () => {
it('should update, persist and return the cart with a new article', async () => {
// Arrange
const shoppingCartRepository = new InMemoryShoppingCartRepository();
const shoppingCart = shoppingCartTestFactory({items: []})