index.spec.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import Notify from '..';
  2. import { transitionStub, later } from '../../../test/utils';
  3. transitionStub();
  4. test('create a notify', async () => {
  5. // should not cause error when call clear before show notify
  6. Notify.clear();
  7. const notify = Notify('test');
  8. await later();
  9. expect(notify.$el.outerHTML).toMatchSnapshot();
  10. });
  11. test('notify disappear', async () => {
  12. const notify = Notify({
  13. message: 'test',
  14. color: 'red',
  15. background: 'blue',
  16. duration: 10
  17. });
  18. await later();
  19. expect(notify.$el.outerHTML).toMatchSnapshot();
  20. await later(20);
  21. expect(notify.$el.outerHTML).toMatchSnapshot();
  22. Notify({
  23. message: 'text2',
  24. duration: 0
  25. });
  26. await later();
  27. expect(notify.$el.outerHTML).toMatchSnapshot();
  28. Notify.clear();
  29. await later();
  30. expect(notify.$el.outerHTML).toMatchSnapshot();
  31. });
  32. test('set default options', () => {
  33. Notify.setDefaultOptions({ duration: 1000 });
  34. expect(Notify().duration).toEqual(1000);
  35. Notify.resetDefaultOptions();
  36. expect(Notify().duration).toEqual(3000);
  37. Notify.clear();
  38. });