|
|
@ -10,6 +10,23 @@ import genRadius from '../themes/shared/genRadius'; |
|
|
|
const { useToken } = theme; |
|
|
|
|
|
|
|
describe('Theme', () => { |
|
|
|
const getHookToken = (config?: ThemeConfig) => { |
|
|
|
let token: any; |
|
|
|
const Demo = () => { |
|
|
|
const { token: hookToken } = useToken(); |
|
|
|
token = hookToken; |
|
|
|
return null; |
|
|
|
}; |
|
|
|
render( |
|
|
|
<ConfigProvider theme={config}> |
|
|
|
<Demo /> |
|
|
|
</ConfigProvider>, |
|
|
|
); |
|
|
|
delete token._hashId; |
|
|
|
delete token._tokenKey; |
|
|
|
return token; |
|
|
|
}; |
|
|
|
|
|
|
|
it('useTheme', () => { |
|
|
|
const { result } = renderHook(() => useToken()); |
|
|
|
|
|
|
@ -224,23 +241,6 @@ describe('Theme', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
describe('getDesignToken', () => { |
|
|
|
const getHookToken = (config?: ThemeConfig) => { |
|
|
|
let token: any; |
|
|
|
const Demo = () => { |
|
|
|
const { token: hookToken } = useToken(); |
|
|
|
token = hookToken; |
|
|
|
return null; |
|
|
|
}; |
|
|
|
render( |
|
|
|
<ConfigProvider theme={config}> |
|
|
|
<Demo /> |
|
|
|
</ConfigProvider>, |
|
|
|
); |
|
|
|
delete token._hashId; |
|
|
|
delete token._tokenKey; |
|
|
|
return token; |
|
|
|
}; |
|
|
|
|
|
|
|
it('default', () => { |
|
|
|
const token = theme.getDesignToken(); |
|
|
|
const hookToken = getHookToken(); |
|
|
@ -276,4 +276,30 @@ describe('Theme', () => { |
|
|
|
expect(token.colorPrimary).toEqual('#1668dc'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('colorLink', () => { |
|
|
|
it('should follow colorPrimary by default', () => { |
|
|
|
const token = getHookToken(); |
|
|
|
expect(token.colorLink).toEqual(token.colorInfo); |
|
|
|
expect(token.colorLinkHover).toEqual(token.colorInfoHover); |
|
|
|
expect(token.colorLinkActive).toEqual(token.colorInfoActive); |
|
|
|
|
|
|
|
const token2 = getHookToken({ token: { colorPrimary: '#189cff' } }); |
|
|
|
expect(token2.colorLink).toEqual(token2.colorInfo); |
|
|
|
expect(token2.colorLinkHover).toEqual(token2.colorInfoHover); |
|
|
|
expect(token2.colorLinkActive).toEqual(token2.colorInfoActive); |
|
|
|
|
|
|
|
const token3 = getHookToken({ algorithm: [theme.darkAlgorithm] }); |
|
|
|
expect(token3.colorLink).toEqual(token3.colorInfo); |
|
|
|
expect(token3.colorLinkHover).toEqual(token3.colorInfoHover); |
|
|
|
expect(token3.colorLinkActive).toEqual(token3.colorInfoActive); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should be calculated correctly', () => { |
|
|
|
const token = getHookToken({ token: { colorLink: '#189cff' } }); |
|
|
|
expect(token.colorLink).toEqual('#189cff'); |
|
|
|
expect(token.colorLinkHover).toEqual('#69c8ff'); |
|
|
|
expect(token.colorLinkActive).toEqual('#0978d9'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|