react-native-navigation的迁移库

ContainerRegistry.test.js 791B

123456789101112131415161718192021222324252627282930
  1. describe('ComponentRegistry', () => {
  2. let uut;
  3. let AppRegistry;
  4. let MyContainer, Component;
  5. beforeEach(() => {
  6. AppRegistry = {registerComponent: jest.fn()};
  7. Component = class {
  8. //
  9. };
  10. jest.mock('react', () => ({}));
  11. jest.mock('react-native', () => ({AppRegistry, Component}));
  12. uut = require('./ContainerRegistry');
  13. MyContainer = class extends Component {
  14. //
  15. };
  16. });
  17. it('registers container component into AppRegistry', () => {
  18. expect(AppRegistry.registerComponent).not.toHaveBeenCalled();
  19. uut.registerContainer('example.MyContainer', () => MyContainer);
  20. expect(AppRegistry.registerComponent).toHaveBeenCalledTimes(1);
  21. expect(AppRegistry.registerComponent.mock.calls[0][0]).toEqual('example.MyContainer');
  22. });
  23. });