|
|
@ -2,24 +2,32 @@ import { sleep } from '../../../tests/utils'; |
|
|
|
import message from '..'; |
|
|
|
|
|
|
|
describe('message.config', () => { |
|
|
|
beforeEach(() => { |
|
|
|
beforeEach(() => { |
|
|
|
jest.useFakeTimers(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
afterEach(() => { |
|
|
|
afterEach(() => { |
|
|
|
message.destroy(); |
|
|
|
jest.useRealTimers(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should be able to config top', () => { |
|
|
|
it('should be able to config top', () => { |
|
|
|
message.config({ |
|
|
|
top: 100, |
|
|
|
}); |
|
|
|
message.info('whatever'); |
|
|
|
expect(document.querySelectorAll('.ant-message')[0].style.top).toBe('100px'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should be able to config rtl', () => { |
|
|
|
message.config({ |
|
|
|
rtl: true, |
|
|
|
}); |
|
|
|
message.info('whatever'); |
|
|
|
expect(document.querySelectorAll('.ant-message-rtl').length).toBe(1); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should be able to config getContainer', () => { |
|
|
|
it('should be able to config getContainer', () => { |
|
|
|
message.config({ |
|
|
|
getContainer: () => { |
|
|
|
const div = document.createElement('div'); |
|
|
@ -30,9 +38,9 @@ it('should be able to config getContainer', () => { |
|
|
|
}); |
|
|
|
message.info('whatever'); |
|
|
|
expect(document.querySelectorAll('.custom-container').length).toBe(1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should be able to config maxCount', () => { |
|
|
|
it('should be able to config maxCount', () => { |
|
|
|
message.config({ |
|
|
|
maxCount: 5, |
|
|
|
}); |
|
|
@ -44,9 +52,9 @@ it('should be able to config maxCount', () => { |
|
|
|
expect(document.querySelectorAll('.ant-message-notice')[4].textContent).toBe('last'); |
|
|
|
jest.runAllTimers(); |
|
|
|
expect(document.querySelectorAll('.ant-message-notice').length).toBe(0); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should be able to config duration', async () => { |
|
|
|
it('should be able to config duration', async () => { |
|
|
|
jest.useRealTimers(); |
|
|
|
message.config({ |
|
|
|
duration: 0.5, |
|
|
@ -57,9 +65,9 @@ it('should be able to config duration', async () => { |
|
|
|
message.config({ |
|
|
|
duration: 3, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should be able to config prefixCls', () => { |
|
|
|
it('should be able to config prefixCls', () => { |
|
|
|
message.config({ |
|
|
|
prefixCls: 'prefix-test', |
|
|
|
}); |
|
|
@ -69,9 +77,9 @@ it('should be able to config prefixCls', () => { |
|
|
|
message.config({ |
|
|
|
prefixCls: 'ant-message', |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should be able to config transitionName', () => { |
|
|
|
it('should be able to config transitionName', () => { |
|
|
|
message.config({ |
|
|
|
transitionName: '', |
|
|
|
}); |
|
|
@ -80,5 +88,5 @@ it('should be able to config transitionName', () => { |
|
|
|
message.config({ |
|
|
|
transitionName: 'move-up', |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |