From 8d000dc2e229f08d4c1f2c5e0b42df00aa14d7b7 Mon Sep 17 00:00:00 2001 From: Tom Robinson Date: Tue, 17 Jul 2018 14:20:28 -0700 Subject: [PATCH] Fix pulse/color tests --- .../visualizations/visualizations/Table.jsx | 2 -- src/metabase/pulse/color.clj | 1 - test/metabase/pulse/color_test.clj | 25 +++---------------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/frontend/src/metabase/visualizations/visualizations/Table.jsx b/frontend/src/metabase/visualizations/visualizations/Table.jsx index 6b7181f1bd3ae..41b85d75246f0 100644 --- a/frontend/src/metabase/visualizations/visualizations/Table.jsx +++ b/frontend/src/metabase/visualizations/visualizations/Table.jsx @@ -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"; diff --git a/src/metabase/pulse/color.clj b/src/metabase/pulse/color.clj index a1465e15c3491..74236c32d9c3a 100644 --- a/src/metabase/pulse/color.clj +++ b/src/metabase/pulse/color.clj @@ -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 diff --git a/test/metabase/pulse/color_test.clj b/test/metabase/pulse/color_test.clj index 48538f575f0b7..13ef9ab2b3def 100644 --- a/test/metabase/pulse/color_test.clj +++ b/test/metabase/pulse/color_test.clj @@ -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){ @@ -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})))]))))