Skip to content

Commit 2e528cf

Browse files
Color Wheel Optimizations (#40)
1 parent f03ada3 commit 2e528cf

File tree

21 files changed

+464
-230
lines changed

21 files changed

+464
-230
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Refactor z-index out of menu styles
1414
- Improvements to documentation layout and scrolling behavior
1515
- SVG for `ApplicationSelect`,`ArrowChange`,`Beaker`,`BrowseTable`,`ChangeHistory`,`DimensionFill`,`Explore`,`LogoRings`,`NoteOutline`,`Notes`,`Reports`,`SqlRunner`,`User`,`UserAttributes`,`Users`,`ViewGrid`,`VisArea`,`VisBar`,`VisColumn`,`VisLine`,`VisMap`,`VisPie`,`VisScatter`,`VisSingleValue`,`VisTable` icons resized redrawn to fit on the correct icon grid.
16+
- Optimize ColorWheel value change performance
17+
- Restore ColorWheel documentation
1618
- Implement a vertical layout for the Code Sandbox toolbar to prevent unintentional obfuscation of code samples
1719

1820
## [0.7.2] - 2019-11-11

jest.setup.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
MIT License
44
55
Copyright (c) 2019 Looker Data Sciences, Inc.
6-
6+
77
Permission is hereby granted, free of charge, to any person obtaining a copy
88
of this software and associated documentation files (the "Software"), to deal
99
in the Software without restriction, including without limitation the rights
1010
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1111
copies of the Software, and to permit persons to whom the Software is
1212
furnished to do so, subject to the following conditions:
13-
13+
1414
The above copyright notice and this permission notice shall be included in all
1515
copies or substantial portions of the Software.
16-
16+
1717
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1818
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1919
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -27,6 +27,7 @@
2727
const Adapter = require('enzyme-adapter-react-16')
2828
const Enzyme = require('enzyme')
2929
require('@testing-library/jest-dom/extend-expect')
30+
require('jest-canvas-mock')
3031

3132
Enzyme.configure({ adapter: new Adapter() })
3233

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"eslint-plugin-react-hooks": "^2.1.2",
7373
"eslint-plugin-standard": "^4.0.1",
7474
"jest": "^24.7.1",
75+
"jest-canvas-mock": "^2.2.0",
7576
"jest-styled-components": "^6.3.3",
7677
"lerna": "^3.18.4",
7778
"lint-staged": "^9.2.5",

packages/components/src/Form/Fields/FieldColor/ColorWheel/ColorWheel.test.tsx

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,46 @@
2424
2525
*/
2626

27-
import 'jest-styled-components'
27+
import { render, fireEvent } from '@testing-library/react'
2828
import React from 'react'
29-
import { assertSnapshot } from '@looker/components-test-utils'
3029
import { ColorWheel } from './ColorWheel'
3130

32-
test('Color wheel default ', () => {
33-
assertSnapshot(<ColorWheel />)
34-
})
31+
test('ColorWheel updates color on click', async () => {
32+
const handleColorChange = jest.fn()
33+
const { findByTestId } = render(
34+
<ColorWheel
35+
hue={260}
36+
saturation={0.5}
37+
value={1}
38+
size={400}
39+
onColorChange={handleColorChange}
40+
/>
41+
)
3542

36-
test('Color wheel with h, s, v defined ', () => {
37-
assertSnapshot(<ColorWheel hue={260} saturation={0.5} value={1} />)
38-
})
43+
expect(handleColorChange).not.toHaveBeenCalled()
44+
45+
const mouseMarkerCanvas = await findByTestId('mouse-marker')
46+
expect(mouseMarkerCanvas).toBeInTheDocument()
47+
48+
fireEvent(
49+
mouseMarkerCanvas,
50+
new MouseEvent('mousedown', {
51+
bubbles: true,
52+
cancelable: true,
53+
clientX: 20,
54+
clientY: 20,
55+
})
56+
)
57+
58+
fireEvent(
59+
mouseMarkerCanvas,
60+
new MouseEvent('mousedown', {
61+
bubbles: true,
62+
cancelable: true,
63+
clientX: 300,
64+
clientY: 300,
65+
})
66+
)
3967

40-
test('Color wheel with h, s, v, size defined ', () => {
41-
assertSnapshot(<ColorWheel hue={260} saturation={0.5} value={1} size={400} />)
68+
expect(handleColorChange.mock.calls).toMatchSnapshot()
4269
})

0 commit comments

Comments
 (0)