adding a little bit more meat to 2.4

This commit is contained in:
Ken
2019-02-26 14:38:52 -08:00
parent ad065d4b4a
commit 7694019b5e
2 changed files with 94 additions and 36 deletions

View File

@@ -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');
});
});