|  | @@ -1,58 +1,60 @@
 | 
	
		
			
			| 1 | 1 |  import { OptionsProcessor } from './OptionsProcessor';
 | 
	
		
			
			| 2 |  | -import { Store } from '../components/Store.mock';
 | 
	
		
			
			|  | 2 | +import { Store } from '../components/Store';
 | 
	
		
			
			| 3 | 3 |  
 | 
	
		
			
			| 4 | 4 |  describe('navigation options', () => {
 | 
	
		
			
			|  | 5 | +  let uut: OptionsProcessor;
 | 
	
		
			
			| 5 | 6 |    let options;
 | 
	
		
			
			| 6 |  | -  let store;
 | 
	
		
			
			|  | 7 | +  let store: Store;
 | 
	
		
			
			| 7 | 8 |    beforeEach(() => {
 | 
	
		
			
			| 8 | 9 |      options = {};
 | 
	
		
			
			| 9 | 10 |      store = new Store();
 | 
	
		
			
			|  | 11 | +    uut = new OptionsProcessor();
 | 
	
		
			
			| 10 | 12 |    });
 | 
	
		
			
			| 11 | 13 |  
 | 
	
		
			
			| 12 | 14 |    it('processes colors into numeric AARRGGBB', () => {
 | 
	
		
			
			| 13 | 15 |      options.someKeyColor = 'red';
 | 
	
		
			
			| 14 | 16 |      options.color = 'blue';
 | 
	
		
			
			| 15 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 17 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 16 | 18 |      expect(options.someKeyColor).toEqual(0xffff0000);
 | 
	
		
			
			| 17 | 19 |      expect(options.color).toEqual(0xff0000ff);
 | 
	
		
			
			| 18 | 20 |  
 | 
	
		
			
			| 19 | 21 |      options.someKeyColor = 'yellow';
 | 
	
		
			
			| 20 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 22 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 21 | 23 |      expect(options.someKeyColor).toEqual(0xffffff00);
 | 
	
		
			
			| 22 | 24 |    });
 | 
	
		
			
			| 23 | 25 |  
 | 
	
		
			
			| 24 | 26 |    it('processes numeric colors', () => {
 | 
	
		
			
			| 25 | 27 |      options.someKeyColor = '#123456';
 | 
	
		
			
			| 26 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 28 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 27 | 29 |      expect(options.someKeyColor).toEqual(0xff123456);
 | 
	
		
			
			| 28 | 30 |  
 | 
	
		
			
			| 29 | 31 |      options.someKeyColor = 0x123456ff; // wut
 | 
	
		
			
			| 30 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 32 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 31 | 33 |      expect(options.someKeyColor).toEqual(0xff123456);
 | 
	
		
			
			| 32 | 34 |    });
 | 
	
		
			
			| 33 | 35 |  
 | 
	
		
			
			| 34 | 36 |    it('process colors with rgb functions', () => {
 | 
	
		
			
			| 35 | 37 |      options.someKeyColor = 'rgb(255, 0, 255)';
 | 
	
		
			
			| 36 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 38 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 37 | 39 |      expect(options.someKeyColor).toEqual(0xffff00ff);
 | 
	
		
			
			| 38 | 40 |    });
 | 
	
		
			
			| 39 | 41 |  
 | 
	
		
			
			| 40 | 42 |    it('process colors with special words', () => {
 | 
	
		
			
			| 41 | 43 |      options.someKeyColor = 'fuchsia';
 | 
	
		
			
			| 42 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 44 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 43 | 45 |      expect(options.someKeyColor).toEqual(0xffff00ff);
 | 
	
		
			
			| 44 | 46 |    });
 | 
	
		
			
			| 45 | 47 |  
 | 
	
		
			
			| 46 | 48 |    it('process colors with hsla functions', () => {
 | 
	
		
			
			| 47 | 49 |      options.someKeyColor = 'hsla(360, 100%, 100%, 1.0)';
 | 
	
		
			
			| 48 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 50 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 49 | 51 |  
 | 
	
		
			
			| 50 | 52 |      expect(options.someKeyColor).toEqual(0xffffffff);
 | 
	
		
			
			| 51 | 53 |    });
 | 
	
		
			
			| 52 | 54 |  
 | 
	
		
			
			| 53 | 55 |    it('unknown colors return undefined', () => {
 | 
	
		
			
			| 54 | 56 |      options.someKeyColor = 'wut';
 | 
	
		
			
			| 55 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 57 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 56 | 58 |      expect(options.someKeyColor).toEqual(undefined);
 | 
	
		
			
			| 57 | 59 |    });
 | 
	
		
			
			| 58 | 60 |  
 | 
	
	
		
			
			|  | @@ -60,7 +62,7 @@ describe('navigation options', () => {
 | 
	
		
			
			| 60 | 62 |      options.otherKeyColor = 'red';
 | 
	
		
			
			| 61 | 63 |      options.yetAnotherColor = 'blue';
 | 
	
		
			
			| 62 | 64 |      options.andAnotherColor = 'rgb(0, 255, 0)';
 | 
	
		
			
			| 63 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 65 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 64 | 66 |      expect(options.otherKeyColor).toEqual(0xffff0000);
 | 
	
		
			
			| 65 | 67 |      expect(options.yetAnotherColor).toEqual(0xff0000ff);
 | 
	
		
			
			| 66 | 68 |      expect(options.andAnotherColor).toEqual(0xff00ff00);
 | 
	
	
		
			
			|  | @@ -68,14 +70,14 @@ describe('navigation options', () => {
 | 
	
		
			
			| 68 | 70 |  
 | 
	
		
			
			| 69 | 71 |    it('keys ending with Color case sensitive', () => {
 | 
	
		
			
			| 70 | 72 |      options.otherKey_color = 'red'; // eslint-disable-line camelcase
 | 
	
		
			
			| 71 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 73 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 72 | 74 |      expect(options.otherKey_color).toEqual('red');
 | 
	
		
			
			| 73 | 75 |    });
 | 
	
		
			
			| 74 | 76 |  
 | 
	
		
			
			| 75 | 77 |    it('any nested recursive keys ending with Color', () => {
 | 
	
		
			
			| 76 | 78 |      options.topBar = { textColor: 'red' };
 | 
	
		
			
			| 77 | 79 |      options.topBar.innerMostObj = { anotherColor: 'yellow' };
 | 
	
		
			
			| 78 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 80 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 79 | 81 |      expect(options.topBar.textColor).toEqual(0xffff0000);
 | 
	
		
			
			| 80 | 82 |      expect(options.topBar.innerMostObj.anotherColor).toEqual(0xffffff00);
 | 
	
		
			
			| 81 | 83 |    });
 | 
	
	
		
			
			|  | @@ -88,7 +90,7 @@ describe('navigation options', () => {
 | 
	
		
			
			| 88 | 90 |        myIcon: 'require("https://wix.github.io/react-native-navigation/_images/logo.png");',
 | 
	
		
			
			| 89 | 91 |        myOtherValue: 'value'
 | 
	
		
			
			| 90 | 92 |      };
 | 
	
		
			
			| 91 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 93 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 92 | 94 |  
 | 
	
		
			
			| 93 | 95 |      // As we can't import external images and we don't want to add an image here
 | 
	
		
			
			| 94 | 96 |      // I assign the icons to strings (what the require would generally look like)
 | 
	
	
		
			
			|  | @@ -100,13 +102,22 @@ describe('navigation options', () => {
 | 
	
		
			
			| 100 | 102 |      expect(options.topBar.myOtherValue).toEqual('value');
 | 
	
		
			
			| 101 | 103 |    });
 | 
	
		
			
			| 102 | 104 |  
 | 
	
		
			
			| 103 |  | -  it('register props for button options', () => {
 | 
	
		
			
			|  | 105 | +  it('passProps for Buttons options', () => {
 | 
	
		
			
			| 104 | 106 |      const passProps = { prop: 'prop' };
 | 
	
		
			
			| 105 | 107 |      options.rightButtons = [{ passProps, id: '1' }];
 | 
	
		
			
			| 106 | 108 |  
 | 
	
		
			
			| 107 |  | -    OptionsProcessor.processOptions({ o: options }, store);
 | 
	
		
			
			|  | 109 | +    uut.processOptions({ o: options }, store);
 | 
	
		
			
			| 108 | 110 |  
 | 
	
		
			
			| 109 |  | -    expect(store.setPropsForId).toBeCalledWith('1', passProps);
 | 
	
		
			
			|  | 111 | +    expect(store.getPropsForId('1')).toEqual(passProps);
 | 
	
		
			
			|  | 112 | +  });
 | 
	
		
			
			|  | 113 | +
 | 
	
		
			
			|  | 114 | +  it('passProps must be with id next to it', () => {
 | 
	
		
			
			|  | 115 | +    const passProps = { prop: 'prop' };
 | 
	
		
			
			|  | 116 | +    options.rightButtons = [{ passProps }];
 | 
	
		
			
			|  | 117 | +
 | 
	
		
			
			|  | 118 | +    uut.processOptions({ o: options }, store);
 | 
	
		
			
			|  | 119 | +
 | 
	
		
			
			|  | 120 | +    expect(store.getPropsForId('1')).toEqual({});
 | 
	
		
			
			| 110 | 121 |    });
 | 
	
		
			
			| 111 | 122 |  
 | 
	
		
			
			| 112 | 123 |    it('processes Options object', () => {
 | 
	
	
		
			
			|  | @@ -114,14 +125,14 @@ describe('navigation options', () => {
 | 
	
		
			
			| 114 | 125 |      options.topBar = { textColor: 'red' };
 | 
	
		
			
			| 115 | 126 |      options.topBar.innerMostObj = { anotherColor: 'yellow' };
 | 
	
		
			
			| 116 | 127 |  
 | 
	
		
			
			| 117 |  | -    OptionsProcessor.processOptions({ o: options }, store);
 | 
	
		
			
			|  | 128 | +    uut.processOptions({ o: options }, store);
 | 
	
		
			
			| 118 | 129 |  
 | 
	
		
			
			| 119 | 130 |      expect(options.topBar.textColor).toEqual(0xffff0000);
 | 
	
		
			
			| 120 | 131 |    });
 | 
	
		
			
			| 121 | 132 |  
 | 
	
		
			
			| 122 | 133 |    it('undefined value return undefined ', () => {
 | 
	
		
			
			| 123 | 134 |      options.someImage = undefined;
 | 
	
		
			
			| 124 |  | -    OptionsProcessor.processOptions(options, store);
 | 
	
		
			
			|  | 135 | +    uut.processOptions(options, store);
 | 
	
		
			
			| 125 | 136 |  
 | 
	
		
			
			| 126 | 137 |      expect(options.someImage).toEqual(undefined);
 | 
	
		
			
			| 127 | 138 |    });
 |