'use strict';

module.exports = function(config) {
    if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
        console.log('Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.');
        process.exit(1);
    }

    var customLaunchers = {
        sauceLabsInternetExplorer9: {
            base: 'SauceLabs',
            browserName: 'internet explorer',
            platform: 'Windows 7',
            version: '9.0'
        },
        sauceLabsInternetExplorer10: {
            base: 'SauceLabs',
            browserName: 'internet explorer',
            platform: 'Windows 7',
            version: '10.0'
        },
        sauceLabsInternetExplorer11: {
            base: 'SauceLabs',
            browserName: 'internet explorer',
            platform: 'Windows 7',
            version: '11.0'
        },
        sauceLabsChrome: {
            base: 'SauceLabs',
            browserName: 'chrome',
            platform: 'Linux',
            version: '39.0'
        },
        sauceLabsFirefox: {
            base: 'SauceLabs',
            browserName: 'firefox',
            platform: 'Linux',
            version: '34.0'
        },
        sauceLabsSafari7: {
            base: 'SauceLabs',
            browserName: 'safari',
            platform: 'Mac 10.9',
            version: '7.0'
        },
        sauceLabsSafari8: {
            base: 'SauceLabs',
            browserName: 'safari',
            platform: 'Mac 10.10',
            version: '8.0'
        },
        sauceLabsIPhoneLatest: {
            base: 'SauceLabs',
            browserName: 'iPhone'
        }
    };

    config.set({
        sauceLabs: {
            testName: 'lory Browser Tests',
            connectOptions: {
                port: 5757
            }
        },

        customLaunchers: customLaunchers,
        browsers: Object.keys(customLaunchers),
        reporters: ['dots', 'saucelabs'],

        frameworks: [
            'mocha',
            'chai',
            'fixture'
        ],

       files: [
            'dist/lory.js',
            'test/lory.test.js',
            'demo/app.css',

            {
                pattern: 'test/*.html'
            }
        ],

        plugins: [
            'karma-mocha',
            'karma-mocha-reporter',
            'karma-chai',
            'karma-fixture',
            'karma-sauce-launcher',
            'karma-html2js-preprocessor'
        ],

        preprocessors: {
            'test/*.html': ['html2js']
        },

        singleRun: true
    });
};

@@ -841,32 +841,131 @@
 1.0'%0A        %7D,%0A
+        edge: %7B%0A            base: 'SauceLabs',%0A            browserName: 'microsoftedge'%0A        %7D,%0A
         sauceLab
@@ -971,16 +971,18 @@
 bsChrome
+46
 : %7B%0A    
@@ -1100,10 +1100,342 @@
 n: '
-39
+46.0'%0A        %7D,%0A        sauceLabsChrome45: %7B%0A            base: 'SauceLabs',%0A            browserName: 'chrome',%0A            platform: 'Linux',%0A            version: '45.0'%0A        %7D,%0A        sauceLabsFirefox41: %7B%0A            base: 'SauceLabs',%0A            browserName: 'firefox',%0A            platform: 'Linux',%0A            version: '41
 .0'%0A
@@ -1469,16 +1469,18 @@
 sFirefox
+40
 : %7B%0A    
@@ -1599,10 +1599,10 @@
 n: '
-3
 4
+0
 .0'%0A
@@ -1972,81 +1972,752 @@
 hone
-Latest: %7B%0A            base: 'SauceLabs',%0A            browserName: 'iPhone
+9: %7B%0A            base: 'SauceLabs',%0A            browserName: 'iPhone',%0A            version: '9.0'%0A        %7D,%0A        sauceLabsIPhone8: %7B%0A            base: 'SauceLabs',%0A            browserName: 'iPhone',%0A            version: '8.0'%0A        %7D,%0A        sauceLabsIPhone7: %7B%0A            base: 'SauceLabs',%0A            browserName: 'iPhone',%0A            version: '7.0'%0A        %7D,%0A        sauceLabsIPad9: %7B%0A            base: 'SauceLabs',%0A            browserName: 'iPad',%0A            version: '9.0'%0A        %7D,%0A        sauceLabsIPad8: %7B%0A            base: 'SauceLabs',%0A            browserName: 'iPad',%0A            version: '8.0'%0A        %7D,%0A        sauceLabsIPad7: %7B%0A            base: 'SauceLabs',%0A            browserName: 'iPad',%0A            version: '7.0
 '%0A  

add further cross browser testing devices for saucelabs