Skip to content

Instantly share code, notes, and snippets.

export const BookInformationCard: FunctionComponent<Props> = ({ book }) => {
return book ? <p>{ book.title }</p> : <p>No book</p>
}
describe('Integration | Component | Book information Card', () => {
it('Matches to snapshot with a book', async () => {
const book = new BookDetails('title', true)
const { asFragment } = render(<BookInformationCard book={ book }/>)
await waitFor(() => {
expect(asFragment()).toMatchSnapshot()
})
})
export const BookInformation: React.FC<Props & DependenciesProps> = ({
bookTitle,
dependencies
}) => {
const [book, setBook] = useState<BookDetails>()
const onRefresh = () => fetchBookInformation()
useEffect(() => {
fetchBookInformation()
}, [])
describe('Integration | Component | Book information', () => {
let dependencies: Dependencies
beforeEach(() => {
dependencies = {
bookInformation: jest.fn().mockResolvedValue(null)
}
})
it('Matches to snapshot', async () => {
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()
})
describe('Integration | Gateways | Http basket repository', () => {
const BASE_API_URL = 'https://www.fakeapi.com'
let httpClient: HTTPClient
let basketRepository: BasketRepository
let basket: Basket
beforeEach(() => {
httpClient = {
get : sinon.stub(),
post: sinon.stub()
export class SequelizeCustomerLoader implements CustomerLoader {
async get(id: string): Promise<Customer> {
const customers = await SequelizeCustomerModel
.findAll({
where: { id: id },
limit: 1
})
.then(this.mapToCustomers)
return customers[0] || Promise.reject(new CustomerNotFoundError())
}
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'
interface BasketBody {
basket_items: string[]
}
interface BasketResponse {
basket_items: string[]
}
export class HTTPBasketRepository implements BasketRepository {
private endpoint = 'https://www.fakeapi.com/baskets'
describe('Integration | Gateways | Http basket repository', () => {
const BASE_API_URL = 'https://www.fakeapi.com'
let httpClient: HTTPClient
let basketRepository: BasketRepository
let basket: Basket
beforeEach(() => {
httpClient = {
get : sinon.stub(),
post: sinon.stub()