react-native-navigation的迁移库

Navigation.test.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import _ from 'lodash';
  2. describe('Navigation', () => {
  3. let Navigation;
  4. let Commands;
  5. let ContainerRegistry;
  6. beforeEach(() => {
  7. jest.mock('./containers/ContainerRegistry');
  8. Navigation = require('./Navigation');
  9. Commands = require('./commands/Commands');
  10. ContainerRegistry = require('./containers/ContainerRegistry');
  11. });
  12. it('exposes static commands', () => {
  13. _.forEach([
  14. Navigation.registerContainer,
  15. Navigation.startApp,
  16. Navigation.push,
  17. Navigation.pop,
  18. Navigation.popToRoot,
  19. Navigation.newStack,
  20. Navigation.showModal,
  21. Navigation.dismissModal,
  22. Navigation.dismissAllModals,
  23. Navigation.showLightbox,
  24. Navigation.dismissLightbox,
  25. Navigation.showInAppNotification,
  26. Navigation.dismissInAppNotification
  27. ], (f) => expect(f).toBeInstanceOf(Function));
  28. });
  29. it('delegates register container to container registry', () => {
  30. expect(ContainerRegistry.registerContainer).not.toHaveBeenCalled();
  31. const fn = jest.fn();
  32. Navigation.registerContainer('key', fn);
  33. expect(ContainerRegistry.registerContainer).toHaveBeenCalledTimes(1);
  34. expect(ContainerRegistry.registerContainer).toHaveBeenCalledWith('key', fn);
  35. });
  36. });