Skip to content

Commit 8943693

Browse files
committed
(refactor/test): rewrite resize test output as more BDD
- noun / verb of describe and it for better readability - export it from Jest ES Module as well
1 parent 58da3e5 commit 8943693

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/index.spec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, test, expect } from 'jest'
1+
import { describe, it, test, expect } from 'jest'
22
import { mount } from 'enzyme'
33
import React from 'react'
44

@@ -136,20 +136,20 @@ describe('get methods return correct canvases', () => {
136136
})
137137

138138
// comes after props, wrappers, and gets as it uses them all
139-
describe('resizing works correctly', () => {
139+
describe('canvas resizing', () => {
140140
const wrapper = mount(<SignatureCanvas />)
141141
const instance = wrapper.instance()
142142
const canvas = instance.getCanvas()
143143

144-
test('canvas should clear on resize', () => {
144+
it('should clear on resize', () => {
145145
instance.fromData(dotF.data)
146146
expect(instance.isEmpty()).toBe(false)
147147

148148
window.resizeTo(500, 500)
149149
expect(instance.isEmpty()).toBe(true)
150150
})
151151

152-
test('canvas should not clear when clearOnResize is false', () => {
152+
it('should not clear when clearOnResize is false', () => {
153153
wrapper.setProps({ clearOnResize: false })
154154

155155
instance.fromData(dotF.data)
@@ -160,23 +160,23 @@ describe('resizing works correctly', () => {
160160
})
161161

162162
const size = { width: 100, height: 100 }
163-
test('canvas should not change size if fixed width & height', () => {
163+
it('should not change size if fixed width & height', () => {
164164
wrapper.setProps({ canvasProps: size })
165165
window.resizeTo(500, 500)
166166

167167
expect(canvas.width).toBe(size.width)
168168
expect(canvas.height).toBe(size.height)
169169
})
170170

171-
test('canvas should change size if no width or height', () => {
171+
it('should change size if no width or height', () => {
172172
wrapper.setProps({ canvasProps: {} })
173173
window.resizeTo(500, 500)
174174

175175
expect(canvas.width).not.toBe(size.width)
176176
expect(canvas.height).not.toBe(size.height)
177177
})
178178

179-
test('canvas should partially change size if one of width or height', () => {
179+
it('should partially change size if one of width or height', () => {
180180
wrapper.setProps({ canvasProps: { width: size.width } })
181181
window.resizeTo(500, 500)
182182

test-utils/jest-export.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// export Jest as an ES Module (https://github.com/facebook/jest/pull/7571#issuecomment-498634094)
22
/* global jest */
33
export default jest
4-
export const { expect, test, describe } = global
4+
export const { expect, test, describe, it } = global

0 commit comments

Comments
 (0)