import chai                         from 'chai';
import sinon                        from 'sinon';
import {loadDependencies}           from '../meta/TestBootstrap.js';

let should = chai.should();

describe('View', () => {
    let imports = {};

    before(() => {
        System.delete(System.normalizeSync('famous/core/Surface.js'));
        System.set(System.normalizeSync('famous/core/Surface.js'), System.newModule({ default: sinon.stub().returns({}) }));

        System.delete(System.normalizeSync('famous/surfaces/ImageSurface.js'));
        System.set(System.normalizeSync('famous/surfaces/ImageSurface.js'), System.newModule({ default: sinon.stub().returns({}) }));

        System.delete(System.normalizeSync('famous/surfaces/ContainerSurface.js'));
        System.set(System.normalizeSync('famous/surfaces/ContainerSurface.js'), System.newModule({ default: sinon.stub().returns({}) }));

        System.delete(System.normalizeSync('famous/core/ElementOutput.js'));
        System.set(System.normalizeSync('famous/core/ElementOutput.js'), System.newModule({ default: sinon.stub().returns({}) }));

        System.delete(System.normalizeSync('famous/core/Group.js'));
        System.set(System.normalizeSync('famous/core/Group.js'), System.newModule({ default: sinon.stub().returns({}) }));

        System.delete(System.normalizeSync('famous/core/Engine.js'));
        System.set(System.normalizeSync('famous/core/Engine.js'), System.newModule({ default: sinon.stub().returns({}) }));

        System.delete(System.normalizeSync('famous-flex/LayoutUtility'));
        System.set(System.normalizeSync('famous-flex/LayoutUtility.js'), System.newModule({ default: sinon.stub().returns({}) }));

        System.delete(System.normalizeSync('famous/core/View.js'));
        System.set(System.normalizeSync('famous/core/View.js'), System.newModule({ default: function(){
            this.options = {};
            this._eventInput = { on: sinon.stub() };
            this.add = sinon.stub();
        } }));

        System.delete(System.normalizeSync('famous-flex/LayoutController.js'));
        System.set(System.normalizeSync('famous-flex/LayoutController.js'), System.newModule({ default: function(){
            this.add = sinon.stub();
            this.pipe = sinon.stub();
        } }));

        System.delete(System.normalizeSync('famous-flex/FlexScrollView.js'));
        System.set(System.normalizeSync('famous-flex/FlexScrollView.js'), System.newModule({default: function () { this.options = {}; }}));

        return loadDependencies({
            View: System.normalizeSync('./src/core/View.js')
        }).then((importedObjects) => {
            imports = importedObjects;
        });
    });

    describe('#constructor', () => {
        it('constructs without exceptions', () => {
            let instance = new imports.View();
            should.exist(instance);
        });
    });
});
@@ -116,17 +116,43 @@
 ndencies
-%7D
+,%0A    mockDependency%7D      
         
@@ -296,42 +296,22 @@
     
-System.delete(System.normalizeSy
+mockDepende
 nc
+y
 ('fa
@@ -324,33 +324,32 @@
 ore/Surface.js')
-)
 ;%0A        System
@@ -346,168 +346,22 @@
     
-System.set(System.normalizeSync('famous/core/Surface.js'), System.newModule(%7B default: sinon.stub().returns(%7B%7D) %7D));%0A%0A        System.delete(System.normalizeSync
+mockDependency
 ('fa
@@ -383,33 +383,32 @@
 mageSurface.js')
-)
 ;%0A        System
@@ -405,177 +405,22 @@
     
-System.set(System.normalizeSync('famous/surfaces/ImageSurface.js'), System.newModule(%7B default: sinon.stub().returns(%7B%7D) %7D));%0A%0A        System.delete(System.normalizeSync
+mockDependency
 ('fa
@@ -420,32 +420,28 @@
 ncy('famous/
-surfaces
+core
 /ContainerSu
@@ -446,25 +446,24 @@
 Surface.js')
-)
 ;%0A        Sy
@@ -464,181 +464,22 @@
     
-System.set(System.normalizeSync('famous/surfaces/ContainerSurface.js'), System.newModule(%7B default: sinon.stub().returns(%7B%7D) %7D));%0A%0A        System.delete(System.normalizeSync
+mockDependency
 ('fa
@@ -502,25 +502,24 @@
 tOutput.js')
-)
 ;%0A        Sy
@@ -520,174 +520,22 @@
     
-System.set(System.normalizeSync('famous/core/ElementOutput.js'), System.newModule(%7B default: sinon.stub().returns(%7B%7D) %7D));%0A%0A        System.delete(System.normalizeSync
+mockDependency
 ('fa
@@ -550,25 +550,24 @@
 e/Group.js')
-)
 ;%0A        Sy
@@ -568,166 +568,22 @@
     
-System.set(System.normalizeSync('famous/core/Group.js'), System.newModule(%7B default: sinon.stub().returns(%7B%7D) %7D));%0A%0A        System.delete(System.normalizeSync
+mockDependency
 ('fa
@@ -599,25 +599,24 @@
 /Engine.js')
-)
 ;%0A        Sy
@@ -617,438 +617,78 @@
     
-System.set(System.normalizeSync('famous/core/Engine.js'), System.newModule(%7B default: sinon.stub().returns(%7B%7D) %7D));%0A%0A        System.delete(System.normalizeSync('famous-flex/LayoutUtility'));%0A        System.set(System.normalizeSync('famous-flex/LayoutUtility.js'), System.newModule(%7B default: sinon.stub().returns(%7B%7D) %7D));%0A%0A        System.delete(System.normalizeSync('famous/core/View.js'));%0A        System.set(System.normalizeSy
+mockDependency('famous-flex/LayoutUtility.js');%0A        mockDepende
 nc
+y
 ('fa
@@ -709,38 +709,9 @@
 .js'
-)
 ,
- System.newModule(%7B default:
  fun
@@ -709,32 +709,33 @@
 .js', function()
+ 
 %7B%0A            th
@@ -846,39 +846,35 @@
 );%0A        %7D
- %7D)
 );%0A
-%0A
         
 System.delet
@@ -865,119 +865,22 @@
     
-System.delete(System.normalizeSync('famous-flex/LayoutController.js'));%0A        System.set(System.normalizeSy
+mockDepende
 nc
+y
 ('fa
@@ -913,38 +913,9 @@
 .js'
-)
 ,
- System.newModule(%7B default:
  fun
@@ -921,16 +921,17 @@
 nction()
+ 
 %7B%0A      
@@ -1012,23 +1012,19 @@
    %7D
- %7D)
 );%0A
-%0A
         
 Syst
@@ -1023,117 +1023,22 @@
     
-System.delete(System.normalizeSync('famous-flex/FlexScrollView.js'));%0A        System.set(System.normalizeSy
+mockDepende
 nc
+y
 ('fa
@@ -1069,37 +1069,9 @@
 .js'
-)
 ,
- System.newModule(%7Bdefault:
  fun
@@ -1079,13 +1079,24 @@
 tion
- 
 () %7B
+%0A           
  thi
@@ -1114,12 +1114,18 @@
  %7B%7D;
+%0A       
  %7D
-%7D)
 );%0A%0A

Refactor view test to new bootstrap