Browse Source

automocking providers

Daniel Zlotin 8 years ago
parent
commit
8eefc038ed
2 changed files with 3 additions and 3 deletions
  1. 0
    3
      src/commands/Commands.test.js
  2. 3
    0
      src/providers/__mocks__/UniqueIdProvider.js

+ 0
- 3
src/commands/Commands.test.js View File

1
 describe('Commands', () => {
1
 describe('Commands', () => {
2
   let uut;
2
   let uut;
3
   let mockNativeNavigation;
3
   let mockNativeNavigation;
4
-  let mockUniqueIdProvider;
5
 
4
 
6
   beforeEach(() => {
5
   beforeEach(() => {
7
     mockNativeNavigation = {
6
     mockNativeNavigation = {
9
     };
8
     };
10
     require('react-native').NativeModules.NativeNavigation = mockNativeNavigation;
9
     require('react-native').NativeModules.NativeNavigation = mockNativeNavigation;
11
     jest.mock('../providers/UniqueIdProvider');
10
     jest.mock('../providers/UniqueIdProvider');
12
-    mockUniqueIdProvider = require('../providers/UniqueIdProvider');
13
     uut = require('./Commands');
11
     uut = require('./Commands');
14
   });
12
   });
15
 
13
 
24
     });
22
     });
25
 
23
 
26
     it('adds uniqueId to passed container', () => {
24
     it('adds uniqueId to passed container', () => {
27
-      mockUniqueIdProvider.uniqueId = jest.fn((prefix) => `${prefix}123`);
28
       uut.startApp({
25
       uut.startApp({
29
         container: {
26
         container: {
30
           key: 'com.example.MyScreen'
27
           key: 'com.example.MyScreen'

+ 3
- 0
src/providers/__mocks__/UniqueIdProvider.js View File

1
+export function uniqueId(prefix) {
2
+  return `${prefix}123`;
3
+}