class Browsers {
  constructor() {}

  get karma() {
    return {
      latestChrome: {
        'base': 'BrowserStack',
        'browser': 'Chrome'
      },
      latestFirefox: {
        'base': 'BrowserStack',
        'browser': 'Firefox'
      },
      latestSafari: {
        'base': 'BrowserStack',
        'browser': 'Safari'
      },
      latestIE: {
        'base': 'BrowserStack',
        'browser': 'IE'
      },
      galaxyS7: {
        'base': 'BrowserStack',
        'device': 'Samsung Galaxy S7',
        'real_mobile': 'true',
        'browser_name': 'android'
      },
      iphone6: {
        'base': 'BrowserStack',
        'browser_name': 'iPhone',
        'platform': 'MAC',
        'device': 'iPhone 6'
      },
      ie10: {
        'base': 'BrowserStack',
        'os': 'Windows',
        'os_version': 'XP',
        'browser_name': 'IE',
        'browser_version': '7.0'
      }
    };
  }

  get protractor() {
    let translate = [
      'browser_name',
      'real_mobile'
    ];
    let karmaBrowsers = this.karma;
    let protractorBrowsers = [];
    for (let browserName in karmaBrowsers) {
      let browser = karmaBrowsers[browserName];
      for (let key in browser) {
        if (browser.hasOwnProperty(key)) {
          if (translate.indexOf(key) !== -1) {
            browser[this.toCamelCase(key)] = browser[key];
            delete browser[key];
            delete browser['base'];
          }
        }
      }
      protractorBrowsers.push(browser);
    };
    
    return protractorBrowsers;
  }

  toCamelCase(input) {
    return input.replace(/[-_]([a-z])/g, (g) => { return g[1].toUpperCase(); })
  }
}

module.exports = new Browsers;