@@ -112,23 +112,6 @@ describe('createPalette()', () => {
112112 } ) ;
113113 } ) ;
114114
115- describe ( 'getContrastText' , ( ) => {
116- it ( 'throws an exception with a falsy argument' , ( ) => {
117- const { getContrastText } = createPalette ( { } ) ;
118-
119- [
120- [ undefined , 'missing background argument in getContrastText(undefined)' ] ,
121- [ null , 'missing background argument in getContrastText(null)' ] ,
122- [ '' , 'missing background argument in getContrastText()' ] ,
123- [ 0 , 'missing background argument in getContrastText(0)' ] ,
124- ] . forEach ( ( testEntry ) => {
125- const [ argument , errorMessage ] = testEntry ;
126-
127- expect ( ( ) => getContrastText ( argument ) , errorMessage ) . to . throw ( ) ;
128- } ) ;
129- } ) ;
130- } ) ;
131-
132115 it ( 'should create a palette with unique object references' , ( ) => {
133116 const redPalette = createPalette ( { background : { paper : 'red' } } ) ;
134117 const bluePalette = createPalette ( { background : { paper : 'blue' } } ) ;
@@ -145,24 +128,19 @@ describe('createPalette()', () => {
145128 consoleErrorMock . reset ( ) ;
146129 } ) ;
147130
148- it ( 'logs an error when an invalid type is specified' , ( ) => {
131+ it ( 'throws an exception when an invalid type is specified' , ( ) => {
149132 createPalette ( { type : 'foo' } ) ;
150133 expect ( consoleErrorMock . callCount ( ) ) . to . equal ( 1 ) ;
151134 expect ( consoleErrorMock . messages ( ) [ 0 ] ) . to . include (
152135 'Material-UI: the palette type `foo` is not supported' ,
153136 ) ;
154137 } ) ;
155138
156- it ( 'logs an error when a wrong color is provided' , ( ) => {
157- createPalette ( { primary : '#fff' } ) ;
158- expect ( consoleErrorMock . callCount ( ) ) . to . equal ( 1 ) ;
159- expect ( consoleErrorMock . messages ( ) [ 0 ] ) . to . include (
139+ it ( 'throws an exception when a wrong color is provided' , ( ) => {
140+ expect ( ( ) => createPalette ( { primary : '#fff' } ) ) . to . throw (
160141 'The color object needs to have a `main` property or a `500` property.' ,
161142 ) ;
162-
163- createPalette ( { primary : { main : { foo : 'bar' } } } ) ;
164- expect ( consoleErrorMock . callCount ( ) ) . to . equal ( 2 ) ;
165- expect ( consoleErrorMock . messages ( ) [ 1 ] ) . to . include (
143+ expect ( ( ) => createPalette ( { primary : { main : { foo : 'bar' } } } ) ) . to . throw (
166144 '`color.main` should be a string, but `{"foo":"bar"}` was provided instead.' ,
167145 ) ;
168146 } ) ;
0 commit comments