|
|
@ -3,6 +3,7 @@ import * as React from 'react'; |
|
|
|
import genRadius from '../themes/shared/genRadius'; |
|
|
|
import { render, renderHook } from '../../../tests/utils'; |
|
|
|
import ConfigProvider from '../../config-provider'; |
|
|
|
import Row from '../../row'; |
|
|
|
import theme from '..'; |
|
|
|
|
|
|
|
const { useToken } = theme; |
|
|
@ -142,4 +143,66 @@ describe('Theme', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
const rowShouldThrow = (screens: any, error: string) => { |
|
|
|
const demoRender = () => |
|
|
|
render( |
|
|
|
<ConfigProvider theme={{ token: screens }}> |
|
|
|
<Row /> |
|
|
|
</ConfigProvider>, |
|
|
|
); |
|
|
|
expect(demoRender).toThrow(error); |
|
|
|
}; |
|
|
|
|
|
|
|
describe('invalid breakpoints order values should raise an error', () => { |
|
|
|
const tests: Array<[string, number, string]> = [ |
|
|
|
['screenXS', 1000, 'screenXSMax<=screenSMMin fails : !(1010<=576)'], |
|
|
|
['screenSM', 1000, 'screenSMMax<=screenMDMin fails : !(1010<=768)'], |
|
|
|
['screenMD', 1000, 'screenMDMax<=screenLGMin fails : !(1010<=992)'], |
|
|
|
['screenLG', 2000, 'screenLGMax<=screenXLMin fails : !(2010<=1200)'], |
|
|
|
['screenXL', 2000, 'screenXLMax<=screenXXLMin fails : !(2010<=1600)'], |
|
|
|
]; |
|
|
|
|
|
|
|
tests.forEach(([screen, value, error]: any) => { |
|
|
|
it(`Screen ${screen} is too big`, () => { |
|
|
|
rowShouldThrow( |
|
|
|
{ [screen]: value, [`${screen}Min`]: value, [`${screen}Max`]: value + 10 }, |
|
|
|
error, |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('invalid breakpoints MIN<=BP values should raise an error', () => { |
|
|
|
const tests: Array<[string, number, string]> = [ |
|
|
|
['screenXSMin', 1000, 'screenXSMin<=screenXS fails : !(1000<=480)'], |
|
|
|
['screenSMMin', 1000, 'screenSMMin<=screenSM fails : !(1000<=576)'], |
|
|
|
['screenMDMin', 1000, 'screenMDMin<=screenMD fails : !(1000<=768)'], |
|
|
|
['screenLGMin', 2000, 'screenLGMin<=screenLG fails : !(2000<=992)'], |
|
|
|
['screenXLMin', 2000, 'screenXLMin<=screenXL fails : !(2000<=1200)'], |
|
|
|
['screenXXLMin', 2000, 'screenXXLMin<=screenXXL fails : !(2000<=1600)'], |
|
|
|
]; |
|
|
|
|
|
|
|
tests.forEach(([screen, value, error]: any) => { |
|
|
|
it(`Screen ${screen}Min is too big regarding ${screen}`, () => { |
|
|
|
rowShouldThrow({ [screen]: value }, error); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('invalid breakpoints BP<=MAX values should raise an error', () => { |
|
|
|
const tests: Array<[string, number, string]> = [ |
|
|
|
['screenXS', 1000, 'screenXS<=screenXSMax fails : !(1000<=575)'], |
|
|
|
['screenSM', 1000, 'screenSM<=screenSMMax fails : !(1000<=767)'], |
|
|
|
['screenMD', 1000, 'screenMD<=screenMDMax fails : !(1000<=991)'], |
|
|
|
['screenLG', 2000, 'screenLG<=screenLGMax fails : !(2000<=1199)'], |
|
|
|
['screenXL', 2000, 'screenXL<=screenXLMax fails : !(2000<=1599)'], |
|
|
|
]; |
|
|
|
|
|
|
|
tests.forEach(([screen, value, error]: any) => { |
|
|
|
it(`Screen ${screen} is too big regarding ${screen}Max`, () => { |
|
|
|
rowShouldThrow({ [screen]: value }, error); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|