From 46e2cd51d8b79bf1f1cfded6fd1c007b554bc441 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Fri, 3 Mar 2017 16:09:55 -0800 Subject: [PATCH] Test improvements (#103) * Fixed duplication kve bug * Some extra testing stuff * A few fixes --- app/__mocks__/dummy.js | 1 + app/__tests__/renderer.test.js | 7 +++++++ app/ui/components/keyvalueeditor/Row.js | 4 +++- app/ui/css/components/keyvalueeditor.less | 4 ++-- package.json | 6 +++++- 5 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 app/__mocks__/dummy.js create mode 100644 app/__tests__/renderer.test.js diff --git a/app/__mocks__/dummy.js b/app/__mocks__/dummy.js new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/app/__mocks__/dummy.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/app/__tests__/renderer.test.js b/app/__tests__/renderer.test.js new file mode 100644 index 000000000..74905f2ec --- /dev/null +++ b/app/__tests__/renderer.test.js @@ -0,0 +1,7 @@ +import * as renderer from '../renderer'; + +describe('imports', () => { + it('ui module should import successfully', () => { + expect(renderer).toBeDefined(); + }); +}); diff --git a/app/ui/components/keyvalueeditor/Row.js b/app/ui/components/keyvalueeditor/Row.js index b40abca49..a65be462a 100644 --- a/app/ui/components/keyvalueeditor/Row.js +++ b/app/ui/components/keyvalueeditor/Row.js @@ -305,9 +305,11 @@ function isAbove (monitor, component) { const hoveredNode = ReactDOM.findDOMNode(component); const hoveredTop = hoveredNode.getBoundingClientRect().top; + const height = hoveredNode.clientHeight; const draggedTop = monitor.getSourceClientOffset().y; - return hoveredTop > draggedTop; + // NOTE: Not quite sure why it's height / 3 (seems to work) + return hoveredTop > draggedTop - (height / 3); } const dragTarget = { diff --git a/app/ui/css/components/keyvalueeditor.less b/app/ui/css/components/keyvalueeditor.less index 3d9b6bc44..b914098ba 100644 --- a/app/ui/css/components/keyvalueeditor.less +++ b/app/ui/css/components/keyvalueeditor.less @@ -12,8 +12,8 @@ flex-direction: row; width: 100%; padding-left: @padding-md; - margin-top: @padding-xs; - margin-bottom: @padding-xs; + padding-top: @padding-xs; + padding-bottom: @padding-xs; box-sizing: border-box; &.key-value-editor__row-wrapper--disabled .input, diff --git a/package.json b/package.json index 3c82e7fd9..1ed0b4183 100644 --- a/package.json +++ b/package.json @@ -40,14 +40,18 @@ "setupFiles": [ "./__jest__/setup.js" ], + "moduleNameMapper": { + "\\.(css|less|png)$": "/__mocks__/dummy.js" + }, "rootDir": "app", "verbose": false, "collectCoverage": false, "collectCoverageFrom": [ "**/*.js", + "!**/*.min.js", "!**/main.development.js", "!**/static/**", - "!**/ui/**", + "!**/ui/components/**", "!**/__fixtures__/**", "!**/__tests__/**", "!**/__jest__/**",