Skip to content

Commit

Permalink
Fix pulse/color tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tlrobinson committed Jul 18, 2018
1 parent 76a1e83 commit 8d000dc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
2 changes: 0 additions & 2 deletions frontend/src/metabase/visualizations/visualizations/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import { makeCellBackgroundGetter } from "metabase/visualizations/lib/table_form

import _ from "underscore";
import cx from "classnames";
import Color from "color";
import { getColorScale } from "metabase/lib/colors";

import RetinaImage from "react-retina-image";
import { getIn } from "icepick";
Expand Down
1 change: 0 additions & 1 deletion src/metabase/pulse/color.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"Namespaces that uses the Nashorn javascript engine to invoke some shared javascript code that we use to determine
the background color of pulse table cells"
(:require [cheshire.core :as json]
[metabase.query-processor.util :as qputil]
[puppetlabs.i18n.core :refer [trs]]
[schema.core :as s])
(:import java.io.InputStream
Expand Down
25 changes: 3 additions & 22 deletions test/metabase/pulse/color_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
(def ^:private green "#00ff00")

(def ^:private ^String test-script
"function makeCellBackgroundGetter(rows, cols, settings) {
"function makeCellBackgroundGetter(rows, colsJSON, settingsJSON) {
cols = JSON.parse(colsJSON);
settings = JSON.parse(settingsJSON);
cols.map(function (a) { return a; });
return function(value, rowIndex, columnName) {
if(rowIndex % 2 == 0){
Expand Down Expand Up @@ -44,24 +46,3 @@
{:even red, :odd green})]
(for [row-index (range 0 4)]
(get-background-color color-selector "any value" "any column" row-index)))))

(def ^:private ^String test-conversion-script
"function addTestNumbers(data) {
var total = 0;
data.map(function (m){
total = total + m[\"test\"];
});
return total;
}")

;; Test the conversion of clojure data to JS data. This just adds up all of the `"test"` values to ensure we can map
;; over the arrays and access keys in the map like we would any other JS array/map
;;
;; Passing in a vector without convert it will cause this test to fail as the Java objects that get passed in don't
;; support `map`
(expect
10.0
(with-test-js-engine test-conversion-script
(.invokeFunction (deref (var-get #'color/js-engine))
"addTestNumbers"
(object-array [(#'color/convert-to-js-data (vec (repeat 10 {"test" 1, "not-test" 2})))]))))

0 comments on commit 8d000dc

Please sign in to comment.