11import * as Plot from "@observablehq/plot" ;
22import * as d3 from "d3" ;
3- import assert from "assert" ;
3+ import assert from "../ assert.js " ;
44import it from "../jsdom.js" ;
55
66it ( "Plot throws an error if an ordinal position scale has a huge inferred domain" , ( ) => {
@@ -411,7 +411,10 @@ it("plot(…).scale(name) handles a reversed diverging scale with a descending d
411411} ) ;
412412
413413it ( "plot(…).scale(name) ignores extra domain elements with a diverging scale" , async ( ) => {
414- const plot = Plot . plot ( { color : { type : "diverging" , domain : [ - 5 , 5 , 10 ] } } ) ;
414+ const plot = assert . warns (
415+ ( ) => Plot . plot ( { color : { type : "diverging" , domain : [ - 5 , 5 , 10 ] } } ) ,
416+ / d o m a i n c o n t a i n s e x t r a /
417+ ) ;
415418 const { interpolate, ...color } = plot . scale ( "color" ) ;
416419 scaleEqual ( color , {
417420 type : "diverging" ,
@@ -722,9 +725,13 @@ it("plot(…).scale('color') can return a “polylinear” piecewise linear scal
722725} ) ;
723726
724727it ( "plot(…).scale('color') ignores extra domain elements with an explicit range" , ( ) => {
725- const plot = Plot . cellX ( [ 100 , 200 , 300 , 400 ] , { fill : Plot . identity } ) . plot ( {
726- color : { type : "linear" , domain : [ 0 , 100 , 200 ] , range : [ "red" , "blue" ] }
727- } ) ;
728+ const plot = assert . warns (
729+ ( ) =>
730+ Plot . cellX ( [ 100 , 200 , 300 , 400 ] , { fill : Plot . identity } ) . plot ( {
731+ color : { type : "linear" , domain : [ 0 , 100 , 200 ] , range : [ "red" , "blue" ] }
732+ } ) ,
733+ / d o m a i n c o n t a i n s e x t r a /
734+ ) ;
728735 scaleEqual ( plot . scale ( "color" ) , {
729736 type : "linear" ,
730737 domain : [ 0 , 100 ] ,
@@ -735,9 +742,13 @@ it("plot(…).scale('color') ignores extra domain elements with an explicit rang
735742} ) ;
736743
737744it ( "plot(…).scale('color') ignores extra range elements with an explicit range" , ( ) => {
738- const plot = Plot . cellX ( [ 100 , 200 , 300 , 400 ] , { fill : Plot . identity } ) . plot ( {
739- color : { type : "linear" , domain : [ 0 , 100 ] , range : [ "red" , "blue" , "green" ] }
740- } ) ;
745+ const plot = assert . warns (
746+ ( ) =>
747+ Plot . cellX ( [ 100 , 200 , 300 , 400 ] , { fill : Plot . identity } ) . plot ( {
748+ color : { type : "linear" , domain : [ 0 , 100 ] , range : [ "red" , "blue" , "green" ] }
749+ } ) ,
750+ / r a n g e c o n t a i n s e x t r a /
751+ ) ;
741752 scaleEqual ( plot . scale ( "color" ) , {
742753 type : "linear" ,
743754 domain : [ 0 , 100 ] ,
@@ -748,9 +759,13 @@ it("plot(…).scale('color') ignores extra range elements with an explicit range
748759} ) ;
749760
750761it ( "plot(…).scale('color') ignores extra domain elements with an explicit range when reversed" , ( ) => {
751- const plot = Plot . cellX ( [ 100 , 200 , 300 , 400 ] , { fill : Plot . identity } ) . plot ( {
752- color : { type : "linear" , domain : [ 0 , 100 , 200 ] , range : [ "red" , "blue" ] , reverse : true }
753- } ) ;
762+ const plot = assert . warns (
763+ ( ) =>
764+ Plot . cellX ( [ 100 , 200 , 300 , 400 ] , { fill : Plot . identity } ) . plot ( {
765+ color : { type : "linear" , domain : [ 0 , 100 , 200 ] , range : [ "red" , "blue" ] , reverse : true }
766+ } ) ,
767+ / d o m a i n c o n t a i n s e x t r a /
768+ ) ;
754769 scaleEqual ( plot . scale ( "color" ) , {
755770 type : "linear" ,
756771 domain : [ 100 , 0 ] ,
@@ -761,9 +776,13 @@ it("plot(…).scale('color') ignores extra domain elements with an explicit rang
761776} ) ;
762777
763778it ( "plot(…).scale('color') ignores extra range elements with an explicit range when reversed" , ( ) => {
764- const plot = Plot . cellX ( [ 100 , 200 , 300 , 400 ] , { fill : Plot . identity } ) . plot ( {
765- color : { type : "linear" , domain : [ 0 , 100 ] , range : [ "red" , "blue" , "green" ] , reverse : true }
766- } ) ;
779+ const plot = assert . warns (
780+ ( ) =>
781+ Plot . cellX ( [ 100 , 200 , 300 , 400 ] , { fill : Plot . identity } ) . plot ( {
782+ color : { type : "linear" , domain : [ 0 , 100 ] , range : [ "red" , "blue" , "green" ] , reverse : true }
783+ } ) ,
784+ / r a n g e c o n t a i n s e x t r a /
785+ ) ;
767786 scaleEqual ( plot . scale ( "color" ) , {
768787 type : "linear" ,
769788 domain : [ 100 , 0 ] ,
0 commit comments