mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
adding a little bit more meat to 2.4
This commit is contained in:
@@ -1,39 +1,11 @@
|
||||
import { square } from '.';
|
||||
import { multiply } from './multiply';
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { TestMe } from './TestMe';
|
||||
|
||||
// Mocked here by jest for the entire test module file
|
||||
jest.mock('./multiply');
|
||||
|
||||
describe('jest example', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
it('should be passing in the multiple two of the same number', () => {
|
||||
square(5);
|
||||
|
||||
// .toBeCalledTimes() and .toBeCalledWith() only work on mocks - we mocked the multiply function from the
|
||||
expect(multiply).toBeCalledTimes(1);
|
||||
expect(multiply).toBeCalledWith(5, 5);
|
||||
});
|
||||
|
||||
it('should increment counter', () => {
|
||||
const { increment } = require('.');
|
||||
expect(increment()).toBe(1);
|
||||
});
|
||||
|
||||
it('should decrement counter', () => {
|
||||
const { decrement } = require('.');
|
||||
expect(decrement()).toBe(-1);
|
||||
});
|
||||
|
||||
it('should retrieve count', () => {
|
||||
const { decrement, getCount, increment } = require('.');
|
||||
increment();
|
||||
increment();
|
||||
decrement();
|
||||
increment();
|
||||
|
||||
expect(getCount()).toBe(2);
|
||||
describe('TestMe Component', () => {
|
||||
it('should have a non-clickable component when the origina InnerMe is clicked', () => {
|
||||
const wrapper = mount(<TestMe name="world" />);
|
||||
wrapper.find('#innerMe').simulate('click');
|
||||
expect(wrapper.find('#innerMe').text()).toBe('Clicked');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user