notify.spec.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { mount } from '@vue/test-utils';
  2. import Notify from '../index.vue';
  3. describe('Notify', () => {
  4. test('base notify', () => {
  5. const wrapper = mount(Notify, {
  6. props: {
  7. isWrapTeleport: false
  8. }
  9. });
  10. const rate = wrapper.find('.nut-popup').find('.nut-notify');
  11. expect(rate.exists()).toBe(true);
  12. });
  13. test('base notify message', async () => {
  14. const wrapper = mount(Notify, {
  15. props: {
  16. isWrapTeleport: false,
  17. message: '测试文案'
  18. }
  19. });
  20. expect(wrapper.html()).toContain('测试文案');
  21. });
  22. test('should be displayed after setting the type', async () => {
  23. const wrapper = mount(Notify, {
  24. props: {
  25. isWrapTeleport: false,
  26. type: 'warning'
  27. }
  28. });
  29. const notify = wrapper.findAll('.nut-notify--warning');
  30. expect(notify.length).toBe(1);
  31. });
  32. test('should be displayed after setting the color and background', async () => {
  33. const wrapper = mount(Notify, {
  34. props: {
  35. isWrapTeleport: false,
  36. color: 'rgb(173, 0, 0)',
  37. background: 'rgb(255, 225, 225)'
  38. }
  39. });
  40. const notify = wrapper.find('.nut-notify').find('.nut-notify');
  41. expect((notify.element as HTMLElement).style.color).toBe('rgb(173, 0, 0)');
  42. expect((notify.element as HTMLElement).style.background).toBe('rgb(255, 225, 225)');
  43. });
  44. test('should be displayed after setting the color and class-name', () => {
  45. const wrapper = mount(Notify, { props: { isWrapTeleport: false, 'class-name': 'xxx' } });
  46. const rate = wrapper.findAll('.xxx');
  47. expect(rate.length).toBe(1);
  48. });
  49. });