@@ -7,7 +7,7 @@ import { render } from "lit";
77import { describe , expect , it } from "vitest" ;
88import type { WorkspaceWidget } from "../types.ts" ;
99import { mapActivity , renderActivity } from "./activity.ts" ;
10- import { mapChart , normalizeChartData , renderChart } from "./chart.ts" ;
10+ import { renderChart } from "./chart.ts" ;
1111import { mapCron , renderCron } from "./cron.ts" ;
1212import { evaluateEmbedUrl , renderIframeEmbed } from "./iframe-embed.ts" ;
1313import { mapInstances , renderInstances } from "./instances.ts" ;
@@ -238,38 +238,6 @@ describe("activity mapping", () => {
238238} ) ;
239239
240240describe ( "chart mapping" , ( ) => {
241- it ( "accepts finite numeric series and rejects malformed chart data" , ( ) => {
242- expect ( normalizeChartData ( [ 1 , 2 , 3 ] ) ) . toEqual ( { ok : true , values : [ 1 , 2 , 3 ] } ) ;
243- expect ( normalizeChartData ( { points : [ { y : 4 } , { value : "5" } ] } ) ) . toEqual ( {
244- ok : true ,
245- values : [ 4 , 5 ] ,
246- } ) ;
247- expect ( normalizeChartData ( [ 1 , "bad" , 2 ] ) ) . toMatchObject ( { ok : false } ) ;
248- expect ( normalizeChartData ( { points : [ { label : "missing value" } ] } ) ) . toMatchObject ( {
249- ok : false ,
250- } ) ;
251- expect ( normalizeChartData ( { points : Array . from ( { length : 501 } , ( ) => 1 ) } ) ) . toMatchObject ( {
252- ok : false ,
253- } ) ;
254- } ) ;
255-
256- it ( "validates chart options and derives a bounded model" , ( ) => {
257- expect ( mapChart ( widget ( { props : { type : "bar" } } ) , [ 3 , 1 , 5 ] ) ) . toMatchObject ( {
258- status : "ready" ,
259- type : "bar" ,
260- values : [ 3 , 1 , 5 ] ,
261- min : 0 ,
262- max : 5 ,
263- dataMin : 1 ,
264- dataMax : 5 ,
265- } ) ;
266- expect ( mapChart ( widget ( { props : { type : "pie" } } ) , [ 1 ] ) ) . toMatchObject ( { status : "error" } ) ;
267- expect ( mapChart ( widget ( { props : { type : null } } ) , [ 1 ] ) ) . toMatchObject ( { status : "error" } ) ;
268- expect ( mapChart ( widget ( { props : { min : 10 , max : 2 } } ) , [ 4 ] ) ) . toMatchObject ( {
269- status : "error" ,
270- } ) ;
271- } ) ;
272-
273241 it ( "renders single-point and constant series visibly" , ( ) => {
274242 const line = renderToContainer ( renderChart ( widget ( { props : { type : "line" } } ) , [ 5 ] ) ) ;
275243 expect ( line . querySelector ( ".workspace-chart__point" ) ) . not . toBeNull ( ) ;
@@ -331,6 +299,18 @@ describe("chart mapping", () => {
331299 const invalid = renderToContainer ( renderChart ( widget ( ) , [ 1 , "bad" ] ) ) ;
332300 expect ( invalid . querySelector ( '[data-test-id="workspace-chart-error"]' ) ) . not . toBeNull ( ) ;
333301 expect ( invalid . querySelector ( "svg" ) ) . toBeNull ( ) ;
302+
303+ for ( const [ configuredWidget , value ] of [
304+ [ widget ( { props : { type : "pie" } } ) , [ 1 ] ] ,
305+ [ widget ( { props : { type : null } } ) , [ 1 ] ] ,
306+ [ widget ( { props : { min : 10 , max : 2 } } ) , [ 4 ] ] ,
307+ [ widget ( ) , { points : [ { label : "missing value" } ] } ] ,
308+ [ widget ( ) , { points : Array . from ( { length : 501 } , ( ) => 1 ) } ] ,
309+ ] as const ) {
310+ const error = renderToContainer ( renderChart ( configuredWidget , value ) ) ;
311+ expect ( error . querySelector ( '[data-test-id="workspace-chart-error"]' ) ) . not . toBeNull ( ) ;
312+ expect ( error . querySelector ( "svg" ) ) . toBeNull ( ) ;
313+ }
334314 } ) ;
335315} ) ;
336316
0 commit comments