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
export const BookInformationCard: FunctionComponent<Props> = ({ book }) => { | |
return book ? <p>{ book.title }</p> : <p>No book</p> | |
} |
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 | 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() | |
}) | |
}) |
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
export const BookInformation: React.FC<Props & DependenciesProps> = ({ | |
bookTitle, | |
dependencies | |
}) => { | |
const [book, setBook] = useState<BookDetails>() | |
const onRefresh = () => fetchBookInformation() | |
useEffect(() => { | |
fetchBookInformation() | |
}, []) |
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 | Component | Book information', () => { | |
let dependencies: Dependencies | |
beforeEach(() => { | |
dependencies = { | |
bookInformation: jest.fn().mockResolvedValue(null) | |
} | |
}) | |
it('Matches to snapshot', async () => { |
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() | |
}) |
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 | 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() |
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
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()) | |
} |
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' |
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
interface BasketBody { | |
basket_items: string[] | |
} | |
interface BasketResponse { | |
basket_items: string[] | |
} | |
export class HTTPBasketRepository implements BasketRepository { | |
private endpoint = 'https://www.fakeapi.com/baskets' |
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 | 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() |