<commit_before>// Karma configuration
// Generated on Wed Jul 15 2015 09:44:02 GMT+0200 (Romance Daylight Time)
'use strict';

var argv = require('yargs').argv;

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: './',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'node_modules/zone.js/dist/zone.js',
      'node_modules/zone.js/dist/long-stack-trace-zone.js',
      'node_modules/zone.js/dist/jasmine-patch.js',
      'node_modules/es6-module-loader/dist/es6-module-loader.js',
      'node_modules/traceur/bin/traceur-runtime.js', // Required by PhantomJS2, otherwise it shouts ReferenceError: Can't find variable: require
      'node_modules/traceur/bin/traceur.js',
      'node_modules/systemjs/dist/system.src.js',
      'node_modules/reflect-metadata/Reflect.js',
      // beta.7 IE 11 polyfills from https://github.com/angular/angular/issues/7144
      'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',

      { pattern: 'node_modules/angular2/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
      { pattern: 'dist/dev/**/*.js', included: false, watched: true },
      { pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false }, // PhantomJS2 (and possibly others) might require it

      // suppress annoying 404 warnings for resources, images, etc.
      { pattern: 'dist/dev/assets/**/*', watched: false, included: false, served: true },

      'test-main.js'
    ],

    // must go along with above, suppress annoying 404 warnings.
    proxies: {
      '/assets/': '/base/dist/dev/assets/'
    },

    // list of files to exclude
    exclude: [
      'node_modules/angular2/**/*spec.js'
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'dist/**/!(*spec).js': ['coverage']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['mocha', 'coverage'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: [
      'PhantomJS',
      'Chrome'
    ],

    customLaunchers: {
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },

    coverageReporter: {
      dir: 'coverage/',
      reporters: [
        { type: 'text-summary' },
        { type: 'json', subdir: '.', file: 'coverage-final.json' },
        { type: 'html' }
      ]
    },

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Passing command line arguments to tests
    client: {
      files: argv.files
    }
  });

  if (process.env.APPVEYOR) {
    config.browsers = ['IE'];
    config.singleRun = true;
    config.browserNoActivityTimeout = 90000; // Note: default value (10000) is not enough
  }

  if (process.env.TRAVIS || process.env.CIRCLECI) {
    config.browsers = ['Chrome_travis_ci'];
    config.singleRun = true;
  }
};
<commit_msg>Fixed issue #8 - html/css karma serving<commit_after>// Karma configuration
// Generated on Wed Jul 15 2015 09:44:02 GMT+0200 (Romance Daylight Time)
'use strict';

var argv = require('yargs').argv;

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: './',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'node_modules/zone.js/dist/zone.js',
      'node_modules/zone.js/dist/long-stack-trace-zone.js',
      'node_modules/zone.js/dist/jasmine-patch.js',
      'node_modules/es6-module-loader/dist/es6-module-loader.js',
      'node_modules/traceur/bin/traceur-runtime.js', // Required by PhantomJS2, otherwise it shouts ReferenceError: Can't find variable: require
      'node_modules/traceur/bin/traceur.js',
      'node_modules/systemjs/dist/system.src.js',
      'node_modules/reflect-metadata/Reflect.js',
      // beta.7 IE 11 polyfills from https://github.com/angular/angular/issues/7144
      'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',

      { pattern: 'node_modules/angular2/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
      { pattern: 'dist/dev/**/*.js', included: false, watched: true },
      { pattern: 'dist/dev/**/*.html', included: false, watched: true, served: true },
      { pattern: 'dist/dev/**/*.css', included: false, watched: true, served: true },
      { pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false }, // PhantomJS2 (and possibly others) might require it

      // suppress annoying 404 warnings for resources, images, etc.
      { pattern: 'dist/dev/assets/**/*', watched: false, included: false, served: true },

      'test-main.js'
    ],

    // must go along with above, suppress annoying 404 warnings.
    proxies: {
      '/assets/': '/base/dist/dev/assets/'
    },

    // list of files to exclude
    exclude: [
      'node_modules/angular2/**/*spec.js'
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'dist/**/!(*spec).js': ['coverage']
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['mocha', 'coverage'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: [
      'PhantomJS',
      'Chrome'
    ],

    customLaunchers: {
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },

    coverageReporter: {
      dir: 'coverage/',
      reporters: [
        { type: 'text-summary' },
        { type: 'json', subdir: '.', file: 'coverage-final.json' },
        { type: 'html' }
      ]
    },

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Passing command line arguments to tests
    client: {
      files: argv.files
    }
  });

  if (process.env.APPVEYOR) {
    config.browsers = ['IE'];
    config.singleRun = true;
    config.browserNoActivityTimeout = 90000; // Note: default value (10000) is not enough
  }

  if (process.env.TRAVIS || process.env.CIRCLECI) {
    config.browsers = ['Chrome_travis_ci'];
    config.singleRun = true;
  }
};
<|endoftext|>


<commit_before>var clientIncludes = require('./test/include.conf.js');
var testFiles = require('./test/tests.conf.js');

module.exports = function(config) {
    config.set({

        //base path used to resolve files and excludes
        basePath: './',

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

        //preload .js files
        files: [
            //from base.html
            'goldstone/client/js/lib/jquery.js',
            'goldstone/client/js/lib/underscore.js',
            'goldstone/client/js/lib/backbone.js',
            'goldstone/client/js/lib/bootstrap.js',
            'goldstone/client/js/lib/jquery.dataTables.js',
            'goldstone/client/js/lib/dataTables.bootstrap.js',
            'goldstone/client/js/lib/jquery.datetimepicker.js',
            'goldstone/client/js/lib/colorbrewer.js',
            'goldstone/client/js/lib/d3.js',
            'goldstone/client/js/lib/d3-tip.js',
            'goldstone/client/js/lib/d3-legend.js',
            'goldstone/client/js/lib/crossfilter.js',
            'goldstone/client/js/lib/dc.js',
            'goldstone/client/js/lib/moment-with-locales.js',
            'goldstone/client/js/lib/moment-timezone-with-data-2010-2020.js'
        ].concat(clientIncludes, testFiles),

        exclude: [
            'karma.conf.js'
        ],

        // progress reporter: lists each test run and whether they pass/fail
        // coverage reporter: creates coverage reports for every tested browser
        reporters: ['progress', 'coverage'],

        // web server port
        port: 9988,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,

        // test with:
        browsers: ['Chrome'],

        // Source files you want to generate coverage reports for
        // This should not include tests or libraries
        // These files will be instrumented by Istanbul
        preprocessors: {

            'goldstone/client/js/*.js': ['coverage'],
            'goldstone/client/js/models/*.js': ['coverage'],
            'goldstone/client/js/collections/*.js': ['coverage'],
            'goldstone/client/js/views/*.js': ['coverage']

        },

        // coverage config
        coverageReporter: {
            type: 'html',
            dir: 'test/results/coverage'
        },

        // If browser does not capture in given timeout [ms], kill it
        captureTimeout: 10000,

        // Auto run tests on start (when browsers are captured) and exit
        singleRun: false,

        // report which specs fall below this ms count:
        reportSlowerThan: 500,

        // additional plugins needed for testing
        plugins: [
            'karma-coverage',
            'karma-mocha',
            'karma-chai',
            'karma-sinon',
            'karma-chrome-launcher'
        ]
    });
};
<commit_msg>Updates karma testing config file to include all base.html js files.<commit_after>var clientIncludes = require('./test/include.conf.js');
var testFiles = require('./test/tests.conf.js');

module.exports = function(config) {
    config.set({

        //base path used to resolve files and excludes
        basePath: './',

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

        //preload .js files
        files: [
            //from base.html
            'goldstone/client/js/lib/jquery.js',
            'goldstone/client/js/lib/bootstrap.js',
            'goldstone/client/js/lib/jquery.dataTables.js',
            'goldstone/client/js/lib/dataTables.bootstrap.js',
            'goldstone/client/js/lib/jquery.datetimepicker.js',
            'goldstone/client/js/lib/colorbrewer.js',
            'goldstone/client/js/lib/d3.js',
            'goldstone/client/js/lib/d3-tip.js',
            'goldstone/client/js/lib/d3-legend.js',
            'goldstone/client/js/lib/crossfilter.js',
            'goldstone/client/js/lib/dc.js',
            'goldstone/client/js/lib/underscore.js',
            'goldstone/client/js/lib/backbone.js',
            'goldstone/client/js/lib/moment-with-locales.js',
            'goldstone/client/js/lib/moment-timezone-with-data-2010-2020.js',
            'goldstone/client/js/models/goldstoneColors.js',
            'goldstone/client/js/models/infoButtonText.js',
            'goldstone/client/js/views/chartHeaderView.js',
            'goldstone/client/js/base.js',
            'goldstone/client/js/views/goldstoneBaseView.js'

        ].concat(clientIncludes, testFiles),

        exclude: [
            'karma.conf.js'
        ],

        // progress reporter: lists each test run and whether they pass/fail
        // coverage reporter: creates coverage reports for every tested browser
        reporters: ['progress', 'coverage'],

        // web server port
        port: 9988,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,

        // test with:
        browsers: ['Chrome'],

        // Source files you want to generate coverage reports for
        // This should not include tests or libraries
        // These files will be instrumented by Istanbul
        preprocessors: {

            'goldstone/client/js/*.js': ['coverage'],
            'goldstone/client/js/models/*.js': ['coverage'],
            'goldstone/client/js/collections/*.js': ['coverage'],
            'goldstone/client/js/views/*.js': ['coverage']

        },

        // coverage config
        coverageReporter: {
            type: 'html',
            dir: 'test/results/coverage'
        },

        // If browser does not capture in given timeout [ms], kill it
        captureTimeout: 10000,

        // Auto run tests on start (when browsers are captured) and exit
        singleRun: false,

        // report which specs fall below this ms count:
        reportSlowerThan: 500,

        // additional plugins needed for testing
        plugins: [
            'karma-coverage',
            'karma-mocha',
            'karma-chai',
            'karma-sinon',
            'karma-chrome-launcher'
        ]
    });
};
<|endoftext|>


<commit_before>/* eslint require-jsdoc: 0 */
module.exports = function(config) {
  const configuration = {
    basePath: '',
    frameworks: ['mocha', 'chai-spies', 'chai'],
    files: [
      'node_modules/@webcomponents/webcomponentsjs/webcomponents-sd-ce.js',
      'node_modules/simulant/dist/simulant.umd.js',
      'dist/x-slider-test.js',
      'test/helpers/testing-helper.js',
      'test/swipe.js',
    ],
    preprocessors: {},
    reporters: ['progress', 'coverage', 'coveralls'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    singleRun: true,
    browsers: ['FirefoxHeadless'],
    concurrency: Infinity,
    // to avoid DISCONNECTED messages
    browserDisconnectTimeout: 10 * 1000, // default 2000
    browserDisconnectTolerance: 1, // default 0
    browserNoActivityTimeout: 4 * 60 * 1000, // default 10000
    captureTimeout: 4 * 60 * 1000, // default 60000,
    processKillTimeout: 10 * 1000, // default 2000

    customLaunchers: {
      FirefoxHeadless: {
        base: 'Firefox',
        flags: [
          '-headless',
        ],
      },
    },

    // Code coverage options
    preprocessors: {
      'dist/x-slider-test.js': [
        'coverage',
      ],
    },
    coverageReporter: {
      type: 'lcov', // lcov or lcovonly are required for generating lcov.info files
      dir: 'coverage/',
    },
  };

  config.set(configuration);
};
<commit_msg>GH-37 feat(tests): back to karma defaults<commit_after>/* eslint require-jsdoc: 0 */
module.exports = function(config) {
  const configuration = {
    basePath: '',
    frameworks: ['mocha', 'chai-spies', 'chai'],
    files: [
      'node_modules/@webcomponents/webcomponentsjs/webcomponents-sd-ce.js',
      'node_modules/simulant/dist/simulant.umd.js',
      'dist/x-slider-test.js',
      'test/helpers/testing-helper.js',
      'test/*.js',
    ],
    preprocessors: {},
    reporters: ['progress', 'coverage', 'coveralls'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    singleRun: true,
    browsers: ['ChromeHeadless', 'FirefoxHeadless', 'Safari'],
    concurrency: Infinity,

    // to avoid DISCONNECTED messages
    browserDisconnectTimeout: 10 * 1000, // default 2000
    browserDisconnectTolerance: 1, // default 0
    browserNoActivityTimeout: 4 * 60 * 1000, // default 10000
    captureTimeout: 4 * 60 * 1000, // default 60000,
    processKillTimeout: 10 * 1000, // default 2000

    customLaunchers: {
      FirefoxHeadless: {
        base: 'Firefox',
        flags: [
          '-headless',
        ],
      },
    },

    // Code coverage options
    preprocessors: {
      'dist/x-slider-test.js': [
        'coverage',
      ],
    },
    coverageReporter: {
      type: 'lcov', // lcov or lcovonly are required for generating lcov.info files
      dir: 'coverage/',
    },
  };

  config.set(configuration);
};
<|endoftext|>


<commit_before>// Karma configuration

module.exports = function(config) {
    config.set({

        // base path, that will be used to resolve files and exclude
        basePath: './',

        // frameworks to use
        frameworks: ['jasmine', 'systemjs'],

        // list of files / patterns to load in the browser
        files: [],

        systemjs: {

            configFile: 'system.config.js',

            // File patterns for your application code, dependencies, and test suites
            files: [
                'bower_components/**/*',
                './*.js'
            ],

            config: {
                baseURL: '/',
                transpiler: null
            }
        },

        // list of files to exclude
        exclude: [
            'bower_components/**/*.spec.js'
        ],

        // test results reporter to use
        // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
        reporters: ['mocha'],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,

        // Start these browsers, currently available:
        // - Chrome
        // - ChromeCanary
        // - Firefox
        // - Opera
        // - Safari (only Mac)
        // - PhantomJS
        // - IE (only Windows)
        browsers: ['PhantomJS'],

        // If browser does not capture in given timeout [ms], kill it
        captureTimeout: 60000,

        // Continuous Integration mode
        // if true, it capture browsers, run tests and exit
        singleRun: true
    });
};
<commit_msg>fix coverage report<commit_after>// Karma configuration

module.exports = function(config) {
    config.set({

        // base path, that will be used to resolve files and exclude
        basePath: './',

        // frameworks to use
        frameworks: ['jasmine', 'systemjs'],

        // list of files / patterns to load in the browser
        files: [],

        systemjs: {

            configFile: 'system.config.js',

            // File patterns for your application code, dependencies, and test suites
            files: [
                'bower_components/**/*',
                './*.js'
            ],

            config: {
                baseURL: '/',
                transpiler: null
            }
        },

        // list of files to exclude
        exclude: [
            'bower_components/**/*.spec.js'
        ],

        preprocessors: {
            // source files, that you wanna generate coverage for
            // do not include tests or libraries
            // (these files will be instrumented by Istanbul)
            'block.js': ['coverage']
        },

        coverageReporter: {
            type : 'lcovonly',
            dir : 'reporters',
            subdir : '.'
        },

        junitReporter: {
            outputFile: 'reporters/junit.xml'
        },

        // test results reporter to use
        // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
        reporters: ['mocha'],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,

        // Start these browsers, currently available:
        // - Chrome
        // - ChromeCanary
        // - Firefox
        // - Opera
        // - Safari (only Mac)
        // - PhantomJS
        // - IE (only Windows)
        browsers: ['PhantomJS'],

        // If browser does not capture in given timeout [ms], kill it
        captureTimeout: 60000,

        // Continuous Integration mode
        // if true, it capture browsers, run tests and exit
        singleRun: true
    });
};
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Fri Jul 05 2013 01:57:57 GMT-0400 (EDT)

module.exports = function(config) {
  config.set({

    // base path, that will be used to resolve files and exclude
    basePath: 'tmp/public/test',

    // list of files / patterns to load in the browser
    files: [
      'vendor/loader.js',
      'vendor/sinon.js',
      'vendor/jquery.js',
      'vendor/rsvp.amd.js',
      'lib/*.js',
      'tests/tests.amd.js',
      'test_loader.js'
    ],

    frameworks: ['qunit'],

    plugins: [
      'karma-qunit',
      'karma-coverage',
      'karma-phantomjs-launcher',
      'karma-chrome-launcher'
    ],

    preprocessors: {
      'lib/*.js': 'coverage'
    },

    // list of files to exclude
    exclude: [],

    // test results reporter to use
    // possible values: 'dots', 'progress', 'junit'
    reporters: 'coverage',

    coverageReporter: {
      type : ['html'],
      dir : 'coverage/'
    },

    // web server port
    port: 9876,

    // cli runner port
    runnerPort: 9100,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: ['Chrome'],

    // If browser does not capture in given timeout [ms], kill it
    captureTimeout: 60000,

    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false
  });
};
<commit_msg>Remove karma.conf.js<commit_after><|endoftext|>


<commit_before>// Karma configuration
// Generated on Sun Apr 10 2016 12:06:14 GMT+0200 (Central European Daylight Time)

module.exports = function (config) {
    if (process.env.TRAVIS && (!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 = new CustomLaunchers();

    customLaunchers
        .addChrome('35', '36', '44', '45')('Windows 8')
        .addEdge('13.10586')('Windows 10')
        .addOpera('12.12')('Windows 7')
        .addSafari('7.0')('OS X 10.9')
        .addSafari('8.0')('OS X 10.10')
        .addSafari('9.0')('OS X 10.11')
        .addFirefox('6.0', '33', '34')('Windows 8')
        .addFirefox('6.0', '33', '34')();

    config.set({

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '',

        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['systemjs', 'jasmine'],

        // list of files / patterns to load in the browser
        files: [
            'tests/*-spec.ts',
            'tests/*-specs.ts'
        ],

        // list of files to exclude
        exclude: [],

        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {},

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: process.env.TRAVIS ? ['progress', 'saucelabs'] : ['progress'],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: true,

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: process.env.TRAVIS ? Object.keys(customLaunchers) :['Chrome'],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: process.env.TRAVIS ? true : false,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: 4,

        systemjs: {
            configFile: 'config.js',
            config: {
                paths: {
                    "typescript": "node_modules/typescript/lib/typescript.js",
                    "systemjs": "node_modules/systemjs/dist/system.js",
                    'system-polyfills': 'node_modules/systemjs/dist/system-polyfills.js',
                    'es6-module-loader': 'node_modules/es6-module-loader/dist/es6-module-loader.js'
                },
                packages: {
                    'tests': {
                        defaultExtension: 'ts'
                    },
                    'src': {
                        defaultExtension: 'ts'
                    }
                },
                transpiler: 'typescript'
            },
            serveFiles: [
                'src/**/*.ts',
                'tests/**/*.ts',
                'jspm_packages/**/*'
            ]
        },

        customLaunchers: customLaunchers,

        sauceLabs: {
            testName: 'Web App Unit Tests'
        }
    })
};

function CustomLaunchers() {
    var self = this;

    this.addChrome = addBrowser('chrome');
    this.addEdge = addBrowser('MicrosoftEdge');
    this.addOpera = addBrowser('opera');
    this.addSafari = addBrowser('safari');
    this.addFirefox = addBrowser('firefox');

    function addBrowser(browser) {
        return function () {
            var versions = Array.from(arguments);
            return function (system) {
                versions.forEach(function (version) {
                    var browserName = browser + '_' + version + '_' + (system || 'linux').replace(' ', '_');

                    self[browserName] = {
                        base: 'SauceLabs',
                        browserName: browser,
                        version: version
                    };

                    if (system) {
                        self[browserName].platform = system;
                    }
                });

                return self;
            };
        };
    }
}
<commit_msg>exclude non-browsers<commit_after>// Karma configuration
// Generated on Sun Apr 10 2016 12:06:14 GMT+0200 (Central European Daylight Time)

module.exports = function (config) {
    if (process.env.TRAVIS && (!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 = new CustomLaunchers();

    customLaunchers
        .addChrome('35', '36', '44', '45')('Windows 8')
        .addEdge('13.10586')('Windows 10')
        .addOpera('12.12')('Windows 7')
        .addSafari('7.0')('OS X 10.9')
        .addSafari('8.0')('OS X 10.10')
        .addSafari('9.0')('OS X 10.11')
        .addFirefox('6.0', '33', '34')('Windows 8')
        .addFirefox('6.0', '33', '34')();

    config.set({

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '',

        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['systemjs', 'jasmine'],

        // list of files / patterns to load in the browser
        files: [
            'tests/*-spec.ts',
            'tests/*-specs.ts'
        ],

        // list of files to exclude
        exclude: [],

        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {},

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: process.env.TRAVIS ? ['progress', 'saucelabs'] : ['progress'],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: true,

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: process.env.TRAVIS
            ? Object.keys(customLaunchers).filter(function(key) { return !key.startsWith('add'); })
            :['Chrome'],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: process.env.TRAVIS ? true : false,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: 4,

        systemjs: {
            configFile: 'config.js',
            config: {
                paths: {
                    "typescript": "node_modules/typescript/lib/typescript.js",
                    "systemjs": "node_modules/systemjs/dist/system.js",
                    'system-polyfills': 'node_modules/systemjs/dist/system-polyfills.js',
                    'es6-module-loader': 'node_modules/es6-module-loader/dist/es6-module-loader.js'
                },
                packages: {
                    'tests': {
                        defaultExtension: 'ts'
                    },
                    'src': {
                        defaultExtension: 'ts'
                    }
                },
                transpiler: 'typescript'
            },
            serveFiles: [
                'src/**/*.ts',
                'tests/**/*.ts',
                'jspm_packages/**/*'
            ]
        },

        customLaunchers: customLaunchers,

        sauceLabs: {
            testName: 'Web App Unit Tests'
        }
    })
};

function CustomLaunchers() {
    var self = this;

    this.addChrome = addBrowser('chrome');
    this.addEdge = addBrowser('MicrosoftEdge');
    this.addOpera = addBrowser('opera');
    this.addSafari = addBrowser('safari');
    this.addFirefox = addBrowser('firefox');

    function addBrowser(browser) {
        return function () {
            var versions = Array.from(arguments);
            return function (system) {
                versions.forEach(function (version) {
                    var browserName = browser + '_' + version + '_' + (system || 'linux').replace(' ', '_');

                    self[browserName] = {
                        base: 'SauceLabs',
                        browserName: browser,
                        version: version
                    };

                    if (system) {
                        self[browserName].platform = system;
                    }
                });

                return self;
            };
        };
    }
}
<|endoftext|>


<commit_before>var webpackConfig = require('./webpack/webpack.config.js');

module.exports = function (config) {
  var configObject = {
    frameworks: ['jasmine'],
    basePath: '',
    files: [
      'node_modules/polyfill-function-prototype-bind/bind.js',
      'node_modules/es6-promise/dist/es6-promise.js',
      'src/modules/grid-spec-helper/matchers.js',
      'webpack/test-entry.js',
    ],
    preprocessors: {
      'webpack/test-entry.js': ['webpack', 'sourcemap'],
      'src/modules/grid-spec-helper/matchers.js': ['webpack', 'sourcemap'],
    },
    webpackMiddleware: {
      noInfo: true,
    },
    autoWatch: true,
    reporters: ['progress'],
    browsers: ['ChromeHeadlessNoSandbox'],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        flags: '--no-sandbox',
      },
    },
    junitReporter: {
      outputFile: 'test_out/unit.xml',
      suite: 'unit',
    },
    notifyReporter: {
      reportSuccess: false,
    },
    browserNoActivityTimeout: 3000000,
    reportSlowerThan: 250,
    webpack: require('./webpack/webpack.test'),
  };
  config.set(configObject);
};
<commit_msg>fix(build): specify base browser<commit_after>var webpackConfig = require('./webpack/webpack.config.js');

module.exports = function (config) {
  var configObject = {
    frameworks: ['jasmine'],
    basePath: '',
    files: [
      'node_modules/polyfill-function-prototype-bind/bind.js',
      'node_modules/es6-promise/dist/es6-promise.js',
      'src/modules/grid-spec-helper/matchers.js',
      'webpack/test-entry.js',
    ],
    preprocessors: {
      'webpack/test-entry.js': ['webpack', 'sourcemap'],
      'src/modules/grid-spec-helper/matchers.js': ['webpack', 'sourcemap'],
    },
    webpackMiddleware: {
      noInfo: true,
    },
    autoWatch: true,
    reporters: ['progress'],
    browsers: ['ChromeHeadlessNoSandbox'],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: '--no-sandbox',
      },
    },
    junitReporter: {
      outputFile: 'test_out/unit.xml',
      suite: 'unit',
    },
    notifyReporter: {
      reportSuccess: false,
    },
    browserNoActivityTimeout: 3000000,
    reportSlowerThan: 250,
    webpack: require('./webpack/webpack.test'),
  };
  config.set(configObject);
};
<|endoftext|>


<commit_before>module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine', 'browserify'],

    // list of files / patterns to load in the browser
    files: [
      'test/**/*.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'test/**/*.js': ['browserify']
    },

    browserify: {
      debug: true,
      transform: [ 'babelify' ]
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true
  })
}
<commit_msg>chore(karma.conf): changes files glob to include only .spec.js's<commit_after>module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine', 'browserify'],

    // list of files / patterns to load in the browser
    files: [
      'test/**/*.spec.js'
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'test/**/*.js': ['browserify']
    },

    browserify: {
      debug: true,
      transform: [ 'babelify' ]
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true
  })
}
<|endoftext|>


<commit_before>module.exports = function (config) {

  var libBase = 'src/lib/';       // transpiled app JS and map files

  config.set({
    basePath: '',
    frameworks: ['jasmine'],

    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-junit-reporter'),
      require('karma-jasmine-html-reporter')
    ],

    client: {
      builtPaths: [libBase], // add more spec base paths as needed
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },

    customLaunchers: {
      // From the CLI. Not used here but interesting
      // chrome setup for travis CI using chromium
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },

    files: [
      // System.js for module loading
      'node_modules/systemjs/dist/system.src.js',

      // Polyfills
      'node_modules/core-js/client/shim.js',

      // zone.js
      'node_modules/zone.js/dist/zone.js',
      'node_modules/zone.js/dist/long-stack-trace-zone.js',
      'node_modules/zone.js/dist/proxy.js',
      'node_modules/zone.js/dist/sync-test.js',
      'node_modules/zone.js/dist/jasmine-patch.js',
      'node_modules/zone.js/dist/async-test.js',
      'node_modules/zone.js/dist/fake-async-test.js',

      // RxJs
      {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false},
      {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false},

      // Paths loaded via module imports:
      // Angular itself
      {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
      {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},

      {pattern: 'src/demo/systemjs-angular-loader.js', included: false, watched: false},

      'karma-test-shim.js', // optionally extend SystemJS mapping e.g., with barrels

      // transpiled application & spec code paths loaded via module imports
      {pattern: libBase + '**/*.js', included: false, watched: true},

      // Asset (HTML & CSS) paths loaded via Angular's component compiler
      // (these paths need to be rewritten, see proxies section)
      {pattern: libBase + '**/*.html', included: false, watched: true},
      {pattern: libBase + '**/*.css', included: false, watched: true},

      // Paths for debugging with source maps in dev tools
      {pattern: libBase + '**/*.ts', included: false, watched: false},
      {pattern: libBase + '**/*.js.map', included: false, watched: false}
    ],

    // Proxied base paths for loading assets
    proxies: {
      // required for modules fetched by SystemJS
      '/base/src/lib/node_modules/': '/base/node_modules/',
      '/base/src/lib/demo/': '/base/src/demo/'
    },

    exclude: [],
    preprocessors: {},
    reporters: process.env.CI ? ['junit','dots'] : ['progress', 'kjhtml'],

    junitReporter: {
      outputDir: process.env['$CIRCLE_TEST_REPORTS'].concat('/junit/`),
      outputFile: 'test-results.xml',
      useBrowserName: false
    },

    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  })
}
<commit_msg>fixed junit path for circleci!<commit_after>module.exports = function (config) {

  var libBase = 'src/lib/';       // transpiled app JS and map files

  config.set({
    basePath: '',
    frameworks: ['jasmine'],

    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-junit-reporter'),
      require('karma-jasmine-html-reporter')
    ],

    client: {
      builtPaths: [libBase], // add more spec base paths as needed
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },

    customLaunchers: {
      // From the CLI. Not used here but interesting
      // chrome setup for travis CI using chromium
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },

    files: [
      // System.js for module loading
      'node_modules/systemjs/dist/system.src.js',

      // Polyfills
      'node_modules/core-js/client/shim.js',

      // zone.js
      'node_modules/zone.js/dist/zone.js',
      'node_modules/zone.js/dist/long-stack-trace-zone.js',
      'node_modules/zone.js/dist/proxy.js',
      'node_modules/zone.js/dist/sync-test.js',
      'node_modules/zone.js/dist/jasmine-patch.js',
      'node_modules/zone.js/dist/async-test.js',
      'node_modules/zone.js/dist/fake-async-test.js',

      // RxJs
      {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false},
      {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false},

      // Paths loaded via module imports:
      // Angular itself
      {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
      {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},

      {pattern: 'src/demo/systemjs-angular-loader.js', included: false, watched: false},

      'karma-test-shim.js', // optionally extend SystemJS mapping e.g., with barrels

      // transpiled application & spec code paths loaded via module imports
      {pattern: libBase + '**/*.js', included: false, watched: true},

      // Asset (HTML & CSS) paths loaded via Angular's component compiler
      // (these paths need to be rewritten, see proxies section)
      {pattern: libBase + '**/*.html', included: false, watched: true},
      {pattern: libBase + '**/*.css', included: false, watched: true},

      // Paths for debugging with source maps in dev tools
      {pattern: libBase + '**/*.ts', included: false, watched: false},
      {pattern: libBase + '**/*.js.map', included: false, watched: false}
    ],

    // Proxied base paths for loading assets
    proxies: {
      // required for modules fetched by SystemJS
      '/base/src/lib/node_modules/': '/base/node_modules/',
      '/base/src/lib/demo/': '/base/src/demo/'
    },

    exclude: [],
    preprocessors: {},
    reporters: process.env.CI ? ['junit','dots'] : ['progress', 'kjhtml'],

    junitReporter: {
      outputDir: `${process.env.$CIRCLE_TEST_REPORTS}/junit/`,
      outputFile: 'test-results.xml',
      useBrowserName: false
    },

    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  })
}
<|endoftext|>


<commit_before>process.env.CHROME_BIN = require('puppeteer').executablePath();

module.exports = function (config) {

    config.set({
        basePath: '',
        frameworks: ['mocha', 'browserify'],
        exclude: [],
        files: [{
            pattern: 'test/!(wampy-crossbar)-test.js',
            watched: false
        }],
        preprocessors: {
            'test/*-test.js': ['browserify']
        },

        browserify: {
            transform: [['babelify', { 'presets': ['env'] }]]
        },
        coverageReporter: {
            dir: 'coverage/',
            reporters: [
                {type: 'text-summary'},
                {type: 'json'},
                {type: 'html'}
            ]
        },
        webpackServer: {noInfo: true},
        reporters: ['mocha', 'coverage'],
        port: 9876,
        colors: true,
        browserNoActivityTimeout: 60000,
        logLevel: config.LOG_INFO,
        autoWatch: false,
        browsers: ['HeadlessChrome'],
        customLaunchers:{
            HeadlessChrome:{
                base: 'ChromeHeadless',
                flags: [
                    '--no-sandbox',
                    '--disable-web-security',
                    '--disable-gpu'
                ]
            }
        },
        singleRun: true
    });
};
<commit_msg>Updated karma conf<commit_after>process.env.CHROME_BIN = require('puppeteer').executablePath();

module.exports = function (config) {

    config.set({
        basePath: '',
        frameworks: ['mocha', 'browserify'],
        exclude: [],
        files: [{
            pattern: 'test/!(wampy-crossbar)-test.js',
            watched: false
        }],
        preprocessors: {
            'test/*-test.js': ['browserify']
        },

        browserify: {
            transform: [['babelify', { 'presets': ['@babel/preset-env'] }]]
        },
        coverageReporter: {
            dir: 'coverage/',
            reporters: [
                {type: 'text-summary'},
                {type: 'json'},
                {type: 'html'}
            ]
        },
        webpackServer: {noInfo: true},
        reporters: ['mocha', 'coverage'],
        port: 9876,
        colors: true,
        browserNoActivityTimeout: 60000,
        logLevel: config.LOG_INFO,
        autoWatch: false,
        browsers: ['HeadlessChrome'],
        customLaunchers:{
            HeadlessChrome:{
                base: 'ChromeHeadless',
                flags: [
                    '--no-sandbox',
                    '--disable-web-security',
                    '--disable-gpu'
                ]
            }
        },
        singleRun: true
    });
};
<|endoftext|>


<commit_before>// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
    config.set({
        basePath: '',
        // browserNoActivityTimeout: 4000000,
        frameworks: ['jasmine', '@angular/cli'],
        plugins: [
            require('karma-jasmine'),
            require('karma-chrome-launcher'),
            require('karma-jasmine-html-reporter'),
            require('karma-coverage-istanbul-reporter'),
            require('@angular/cli/plugins/karma')
        ],
        client:{
            clearContext: false // leave Jasmine Spec Runner output visible in browser
        },
        coverageIstanbulReporter: {
            reports: [ 'html', 'lcovonly' ],
            fixWebpackSourcePaths: true
        },
        angularCli: {
            environment: 'dev'
        },
        reporters: ['progress', 'kjhtml'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['Chrome'],
        singleRun: false
    });
};
<commit_msg>OF-75 try unit test on Travis CI using ChromeHeadLess<commit_after>// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
    config.set({
        basePath: '',
        // browserNoActivityTimeout: 4000000,
        frameworks: ['jasmine', '@angular/cli'],
        plugins: [
            require('karma-jasmine'),
            require('karma-chrome-launcher'),
            require('karma-jasmine-html-reporter'),
            require('karma-coverage-istanbul-reporter'),
            require('@angular/cli/plugins/karma')
        ],
        client:{
            clearContext: false // leave Jasmine Spec Runner output visible in browser
        },
        coverageIstanbulReporter: {
            reports: [ 'html', 'lcovonly' ],
            fixWebpackSourcePaths: true
        },
        angularCli: {
            environment: 'dev'
        },
        preprocessors: {
            './src/test.ts': ['@angular/cli']
        },
        reporters: ['progress', 'kjhtml'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['ChromeHeadless'],
        singleRun: false
    });
};
<|endoftext|>


<commit_before>'use strict'

/**
 * Dependencies
 * @ignore
 */
const asn = require('asn1.js')
const base64url = require('base64url')

/**
 * Converter
 *
 * @class Converter
 *
 * @description
 * Utility class to convert between different data representations
 */
class Converter {

  /**
   * convert
   *
   * @description
   * Convert between data types. Available data types: raw, uint8_array, hex, base64, base64url and (bn | bignum)
   *
   * @throws
   * If fromType is not one of: raw, uint8_array, hex, base64, base64url or (bn | bignum)
   *
   * @throws
   * If toType is not one of: raw, uint8_array, hex, base64, base64url or (bn | bignum)
   *
   * @param  {(String|Array|Buffer|BigNumber)} data
   * @param  {String} fromType
   * @param  {String} toType
   * @return {String|BigNumber}
   */
  static convert(data, fromType, toType) {
    if (fromType === toType) {
      return data
    }

    let buffer

    if (fromType === 'raw' || data instanceof Buffer) {
      buffer = data

    } else if (fromType === 'uint8_array' || Array.isArray(data)) {
      buffer = Buffer.from(data)

    } else if (fromType === 'hex') {
      buffer = Buffer.from(data, 'hex')

    } else if (fromType === 'base64') {
      buffer = Buffer.from(data, 'base64')

    } else if (fromType === 'base64url') {
      buffer = base64url.toBuffer(data)

    } else if (fromType === 'bn' || fromType === 'bignum') {
      buffer = Buffer.from(this.pad(data.toString(16)), 'hex')

    } else {
      throw new Error('Invalid fromType')
    }

    if (toType === 'raw') {
      return buffer

    } else if (toType === 'uint8_array') {
      return Array.from(buffer)

    } else if (toType === 'hex') {
      return buffer.toString('hex')

    } else if (toType === 'base64') {
      return buffer.toString('base64')

    } else if (toType === 'base64url') {
      return base64url.fromBase64(buffer.toString('base64'))

    } else if (toType === 'bn' || toType === 'bignum') {
      return new asn.bignum(buffer)

    } else {
      throw new Error('Invalid toType')
    }
  }

  /**
   * convertObject
   *
   * @description
   * Execute the same conversion operation over all fields in an object.
   *
   * @param  {Object} data
   * @param  {String} fromType
   * @param  {String} toType
   * @return {Object}
   */
  static convertObject(data, fromType, toType) {
    return Object.keys(data).reduce((state, field) => {
      try {
        state[field] = Converter.convert(data[field], fromType, toType)
      } catch (e) { }
      return state
    }, {})
  }

  /**
   * pad
   *
   * @description
   * Pad a hex string for octet parsing
   *
   * @param  {String} hex
   * @return {String}
   */
  static pad (hex) {
    return hex.length % 2 === 1 ? `0${hex}` : hex
  }

}

/**
 * Export
 * @ignore
 */
module.exports = Converter
<commit_msg>fix(Converter): return undefined if no data<commit_after>'use strict'

/**
 * Dependencies
 * @ignore
 */
const asn = require('asn1.js')
const base64url = require('base64url')

/**
 * Converter
 *
 * @class Converter
 *
 * @description
 * Utility class to convert between different data representations
 */
class Converter {

  /**
   * convert
   *
   * @description
   * Convert between data types. Available data types: raw, uint8_array, hex, base64, base64url and (bn | bignum)
   *
   * @throws
   * If fromType is not one of: raw, uint8_array, hex, base64, base64url or (bn | bignum)
   *
   * @throws
   * If toType is not one of: raw, uint8_array, hex, base64, base64url or (bn | bignum)
   *
   * @param  {(String|Array|Buffer|BigNumber)} data
   * @param  {String} fromType
   * @param  {String} toType
   * @return {String|BigNumber}
   */
  static convert(data, fromType, toType) {
    if (!data) {
      return undefined
    }

    if (fromType === toType) {
      return data
    }

    let buffer

    if (fromType === 'raw' || data instanceof Buffer) {
      buffer = data

    } else if (fromType === 'uint8_array' || Array.isArray(data)) {
      buffer = Buffer.from(data)

    } else if (fromType === 'hex') {
      buffer = Buffer.from(data, 'hex')

    } else if (fromType === 'base64') {
      buffer = Buffer.from(data, 'base64')

    } else if (fromType === 'base64url') {
      buffer = base64url.toBuffer(data)

    } else if (fromType === 'bn' || fromType === 'bignum') {
      buffer = Buffer.from(this.pad(data.toString(16)), 'hex')

    } else {
      throw new Error('Invalid fromType')
    }

    if (toType === 'raw') {
      return buffer

    } else if (toType === 'uint8_array') {
      return Array.from(buffer)

    } else if (toType === 'hex') {
      return buffer.toString('hex')

    } else if (toType === 'base64') {
      return buffer.toString('base64')

    } else if (toType === 'base64url') {
      return base64url.fromBase64(buffer.toString('base64'))

    } else if (toType === 'bn' || toType === 'bignum') {
      return new asn.bignum(buffer)

    } else {
      throw new Error('Invalid toType')
    }
  }

  /**
   * convertObject
   *
   * @description
   * Execute the same conversion operation over all fields in an object.
   *
   * @param  {Object} data
   * @param  {String} fromType
   * @param  {String} toType
   * @return {Object}
   */
  static convertObject(data, fromType, toType) {
    return Object.keys(data).reduce((state, field) => {
      try {
        state[field] = Converter.convert(data[field], fromType, toType)
      } catch (e) { }
      return state
    }, {})
  }

  /**
   * pad
   *
   * @description
   * Pad a hex string for octet parsing
   *
   * @param  {String} hex
   * @return {String}
   */
  static pad (hex) {
    return hex.length % 2 === 1 ? `0${hex}` : hex
  }

}

/**
 * Export
 * @ignore
 */
module.exports = Converter
<|endoftext|>


<commit_before>/**
 * Mocha's Karma config.
 *
 * IMPORTANT:
 * - Karma must _always_ be run with `NODE_PATH=.` where `.` is the project
 *   root; this allows `karma-mocha` to use our built version of Mocha
 * - You must build Mocha's browser bundle before running Karma. This is
 *   typically done automatically in `package-scripts.js`.
 *
 * There are actually several different configurations here depending on the
 * values of various environment variables (e.g., `MOCHA_TEST`, `CI`, etc.),
 * which is why it's so hairy.
 *
 * This code avoids mutating the configuration object (the `cfg` variable)
 * directly; instead, we create new objects/arrays. This makes it a little more
 * obvious what's happening, even though it's verbose.
 *
 * The main export is a function which Karma calls with a config object; the
 * final line of this function should be `config.set(cfg)` which registers the
 * configuration we've built.
 */

'use strict';
const fs = require('fs');
const path = require('path');
const os = require('os');
const rollupPlugin = require('./scripts/karma-rollup-plugin');
const BASE_BUNDLE_DIR_PATH = path.join(__dirname, '.karma');
const env = process.env;
const hostname = os.hostname();

if (fs.existsSync('./mocha.js') && fs.existsSync('./mocha-es5.js')) {
  fs.renameSync('./mocha.js', './mocha-es2018.js');
  fs.renameSync('./mocha-es5.js', './mocha.js');
}

const SAUCE_BROWSER_PLATFORM_MAP = {
  'chrome@latest': 'Windows 10',
  'MicrosoftEdge@latest': 'Windows 10',
  'internet explorer@latest': 'Windows 10',
  'firefox@latest': 'Windows 10',
  'safari@latest': 'macOS 10.13'
};

const baseConfig = {
  frameworks: ['rollup', 'mocha'],
  files: [
    // we use the BDD interface for all of the tests that
    // aren't interface-specific.
    'test/unit/*.spec.js'
  ],
  plugins: [
    'karma-mocha',
    'karma-mocha-reporter',
    'karma-sauce-launcher',
    'karma-chrome-launcher',
    rollupPlugin
  ],
  rollup: {
    configFile: 'rollup.config.js',
    include: ['test/**']
  },
  reporters: ['mocha'],
  colors: true,
  browsers: ['ChromeHeadless'],
  client: {
    mocha: {
      // this helps debug
      reporter: 'html'
    }
  },
  mochaReporter: {
    showDiff: true
  },
  customLaunchers: {
    ChromeDebug: {
      base: 'Chrome',
      flags: ['--remote-debugging-port=9333']
    }
  }
};

module.exports = config => {
  let bundleDirPath = path.join(BASE_BUNDLE_DIR_PATH, hostname);
  let cfg = {...baseConfig};

  // TO RUN AGAINST SAUCELABS LOCALLY, execute:
  // `CI=1 SAUCE_USERNAME=<user> SAUCE_ACCESS_KEY=<key> npm start test.browser`
  let sauceConfig;

  // configuration for CI mode
  if (env.CI) {
    console.error('CI mode enabled');
    if (env.GITHUB_RUN_ID) {
      console.error('Github Actions detected');
      const buildId = `github-${env.GITHUB_RUN_ID}_${env.GITHUB_RUN_NUMBER}`;
      bundleDirPath = path.join(BASE_BUNDLE_DIR_PATH, buildId);
      sauceConfig = {
        build: buildId
      };
    } else {
      console.error(`Local environment (${hostname}) detected`);
      // don't need to run sauce from Windows CI b/c travis does it.
      if (env.SAUCE_USERNAME || env.SAUCE_ACCESS_KEY) {
        const id = `${hostname} (${Date.now()})`;
        sauceConfig = {
          build: id,
          tunnelIdentifier: id
        };
        console.error('Configured SauceLabs');
      } else {
        console.error(
          'No SauceLabs credentials present; set SAUCE_USERNAME and SAUCE_ACCESS_KEY env vars'
        );
      }
    }
  }

  cfg = createBundleDir(cfg, bundleDirPath);
  cfg = addSauceTests(cfg, sauceConfig);
  cfg = chooseTestSuite(cfg, env.MOCHA_TEST);

  // include sourcemap
  cfg = {
    ...cfg,
    files: [...cfg.files, {pattern: './mocha.js.map', included: false}]
  };

  config.set(cfg);
};

/**
 * Creates dir `bundleDirPath` if it does not exist; returns new Karma config
 * containing `bundleDirPath` for rollup plugin.
 *
 * If this fails, the rollup plugin will use a temp dir.
 * @param {object} cfg - Karma config.
 * @param {string} [bundleDirPath] - Path where the output bundle should live
 * @returns {object} - New Karma config
 */
const createBundleDir = (cfg, bundleDirPath) => {
  if (bundleDirPath) {
    try {
      fs.mkdirSync(bundleDirPath, {recursive: true});
      cfg = {
        ...cfg,
        rollup: {
          ...cfg.rollup,
          bundleDirPath
        }
      };
    } catch (ignored) {
      console.error(
        `Failed to create ${bundleDirPath}; using temp directory instead`
      );
    }
  }
  return {...cfg};
};

/**
 * Adds Saucelabs-specific config to a Karma config object.
 *
 * If `sauceLabs` parameter is falsy, just return a clone of the `cfg` parameter.
 *
 * @see https://github.com/karma-runner/karma-sauce-launcher
 * @see https://github.com/bermi/sauce-connect-launcher#advanced-usage
 * @param {object} cfg - Karma config
 * @param {object} [sauceLabs] - SauceLabs config
 * @returns {object} Karma config
 */
const addSauceTests = (cfg, sauceLabs) => {
  if (sauceLabs) {
    const sauceBrowsers = Object.keys(SAUCE_BROWSER_PLATFORM_MAP);

    // creates Karma `customLauncher` configs from `SAUCE_BROWSER_PLATFORM_MAP`
    const customLaunchers = sauceBrowsers.reduce((acc, sauceBrowser) => {
      const platformName = SAUCE_BROWSER_PLATFORM_MAP[sauceBrowser];
      const [browserName, browserVersion] = sauceBrowser.split('@');
      return {
        ...acc,
        [sauceBrowser]: {
          base: 'SauceLabs',
          browserName,
          browserVersion,
          platformName,
          'sauce:options': sauceLabs
        }
      };
    }, {});

    return {
      ...cfg,
      reporters: [...cfg.reporters, 'saucelabs'],
      browsers: [...cfg.browsers, ...sauceBrowsers],
      customLaunchers: {
        ...cfg.customLaunchers,
        ...customLaunchers
      },
      sauceLabs,
      concurrency: Infinity,
      retryLimit: 1,
      captureTimeout: 120000,
      browserNoActivityTimeout: 20000
    };
  }
  return {...cfg};
};

/**
 * Returns a new Karma config containing standard dependencies for our tests.
 *
 * Most suites use this.
 * @param {object} cfg - Karma config
 * @returns {object} New Karma config
 */
const addStandardDependencies = cfg => ({
  ...cfg,
  files: [
    require.resolve('sinon/pkg/sinon.js'),
    require.resolve('unexpected/unexpected'),
    {
      pattern: require.resolve('unexpected/unexpected.js.map'),
      included: false
    },
    require.resolve('unexpected-sinon'),
    require.resolve('unexpected-eventemitter/dist/unexpected-eventemitter.js'),
    require.resolve('./test/browser-specific/setup'),
    ...cfg.files
  ],
  rollup: {
    ...cfg.rollup,
    external: [
      'sinon',
      'unexpected',
      'unexpected-eventemitter',
      'unexpected-sinon'
    ],
    globals: {
      sinon: 'sinon',
      unexpected: 'weknowhow.expect',
      'unexpected-sinon': 'weknowhow.unexpectedSinon',
      'unexpected-eventemitter': 'unexpectedEventEmitter'
    }
  }
});

/**
 * Adds a name for the tests, reflected in SauceLabs' UI. Returns new Karma
 * config.
 *
 * Does not add a test name if the `sauceLabs` prop of `cfg` is falsy (which
 * would imply that we're not running tests on SauceLabs).
 *
 * @param {string} testName - SauceLabs test name
 * @param {object} cfg - Karma config.
 * @returns {object} New Karma config
 */
const addSauceLabsTestName = (testName, cfg) =>
  cfg.sauceLabs
    ? {
        ...cfg,
        sauceLabs: {
          ...cfg.sauceLabs,
          testName
        }
      }
    : {...cfg};

/**
 * Returns a new Karma config to run with specific configuration (which cannot
 * be run with other configurations) as specified by `value`. Known values:
 *
 * - `bdd` - `bdd`-specific tests
 * - `tdd` - `tdd`-specific tests
 * - `qunit` - `qunit`-specific tests
 * - `esm` - ESM-specific tests
 * - `requirejs` - RequireJS-specific tests
 *
 * Since we can't change Mocha's interface on-the-fly, tests for specific interfaces
 * must be run in isolation.
 * @param {object} cfg - Karma config
 * @param {string} [value] - Configuration identifier, if any
 * @returns {object} New Karma config
 */
const chooseTestSuite = (cfg, value) => {
  switch (value) {
    case 'bdd':
    case 'tdd':
    case 'qunit':
      return addStandardDependencies({
        ...cfg,
        ...addSauceLabsTestName(`Interface "${value}" Integration Tests`, cfg),
        files: [`test/interfaces/${value}.spec.js`],
        client: {
          ...cfg.client,
          mocha: {
            ...cfg.client.mocha,
            ui: value
          }
        }
      });
    case 'esm':
      return addStandardDependencies({
        ...addSauceLabsTestName('ESM Integration Tests', cfg),
        // just run against ChromeHeadless, since other browsers may not
        // support ESM.
        // XXX: remove following line when dropping IE11
        browsers: ['ChromeHeadless'],
        files: [
          {
            pattern: 'test/browser-specific/fixtures/esm.fixture.mjs',
            type: 'module'
          },
          {
            pattern: 'test/browser-specific/esm.spec.mjs',
            type: 'module'
          }
        ]
      });
    case 'requirejs':
      // no standard deps because I'm too lazy to figure out how to make
      // them work with RequireJS. not important anyway
      return {
        ...addSauceLabsTestName('RequireJS Tests', cfg),
        plugins: [...cfg.plugins, 'karma-requirejs'],
        frameworks: ['requirejs', ...cfg.frameworks],
        files: [
          {
            pattern: 'test/browser-specific/fixtures/requirejs/*.fixture.js',
            included: false
          },
          'test/browser-specific/requirejs-setup.js'
        ],
        // this skips bundling the above tests & fixtures
        rollup: {
          ...cfg.rollup,
          include: []
        }
      };
    default:
      return addStandardDependencies({
        ...addSauceLabsTestName('Unit Tests', cfg)
      });
  }
};
<commit_msg>Set CSP on karma to prevent 'evalError' regression (#4706)<commit_after>/**
 * Mocha's Karma config.
 *
 * IMPORTANT:
 * - Karma must _always_ be run with `NODE_PATH=.` where `.` is the project
 *   root; this allows `karma-mocha` to use our built version of Mocha
 * - You must build Mocha's browser bundle before running Karma. This is
 *   typically done automatically in `package-scripts.js`.
 *
 * There are actually several different configurations here depending on the
 * values of various environment variables (e.g., `MOCHA_TEST`, `CI`, etc.),
 * which is why it's so hairy.
 *
 * This code avoids mutating the configuration object (the `cfg` variable)
 * directly; instead, we create new objects/arrays. This makes it a little more
 * obvious what's happening, even though it's verbose.
 *
 * The main export is a function which Karma calls with a config object; the
 * final line of this function should be `config.set(cfg)` which registers the
 * configuration we've built.
 */

'use strict';
const fs = require('fs');
const path = require('path');
const os = require('os');
const rollupPlugin = require('./scripts/karma-rollup-plugin');
const BASE_BUNDLE_DIR_PATH = path.join(__dirname, '.karma');
const env = process.env;
const hostname = os.hostname();

if (fs.existsSync('./mocha.js') && fs.existsSync('./mocha-es5.js')) {
  fs.renameSync('./mocha.js', './mocha-es2018.js');
  fs.renameSync('./mocha-es5.js', './mocha.js');
}

const SAUCE_BROWSER_PLATFORM_MAP = {
  'chrome@latest': 'Windows 10',
  'MicrosoftEdge@latest': 'Windows 10',
  'internet explorer@latest': 'Windows 10',
  'firefox@latest': 'Windows 10',
  'safari@latest': 'macOS 10.13'
};

const baseConfig = {
  frameworks: ['rollup', 'mocha'],
  files: [
    // we use the BDD interface for all of the tests that
    // aren't interface-specific.
    'test/unit/*.spec.js'
  ],
  plugins: [
    'karma-mocha',
    'karma-mocha-reporter',
    'karma-sauce-launcher',
    'karma-chrome-launcher',
    rollupPlugin
  ],
  rollup: {
    configFile: 'rollup.config.js',
    include: ['test/**']
  },
  reporters: ['mocha'],
  colors: true,
  browsers: ['ChromeHeadless'],
  client: {
    mocha: {
      // this helps debug
      reporter: 'html'
    }
  },
  mochaReporter: {
    showDiff: true
  },
  customHeaders: [
    {
      match: '.*.html',
      name: 'Content-Security-Policy',
      value: "script-src https: 'self' 'unsafe-inline'"
    }
  ],
  customLaunchers: {
    ChromeDebug: {
      base: 'Chrome',
      flags: ['--remote-debugging-port=9333']
    }
  }
};

module.exports = config => {
  let bundleDirPath = path.join(BASE_BUNDLE_DIR_PATH, hostname);
  let cfg = {...baseConfig};

  // TO RUN AGAINST SAUCELABS LOCALLY, execute:
  // `CI=1 SAUCE_USERNAME=<user> SAUCE_ACCESS_KEY=<key> npm start test.browser`
  let sauceConfig;

  // configuration for CI mode
  if (env.CI) {
    console.error('CI mode enabled');
    if (env.GITHUB_RUN_ID) {
      console.error('Github Actions detected');
      const buildId = `github-${env.GITHUB_RUN_ID}_${env.GITHUB_RUN_NUMBER}`;
      bundleDirPath = path.join(BASE_BUNDLE_DIR_PATH, buildId);
      sauceConfig = {
        build: buildId
      };
    } else {
      console.error(`Local environment (${hostname}) detected`);
      // don't need to run sauce from Windows CI b/c travis does it.
      if (env.SAUCE_USERNAME || env.SAUCE_ACCESS_KEY) {
        const id = `${hostname} (${Date.now()})`;
        sauceConfig = {
          build: id,
          tunnelIdentifier: id
        };
        console.error('Configured SauceLabs');
      } else {
        console.error(
          'No SauceLabs credentials present; set SAUCE_USERNAME and SAUCE_ACCESS_KEY env vars'
        );
      }
    }
  }

  cfg = createBundleDir(cfg, bundleDirPath);
  cfg = addSauceTests(cfg, sauceConfig);
  cfg = chooseTestSuite(cfg, env.MOCHA_TEST);

  // include sourcemap
  cfg = {
    ...cfg,
    files: [...cfg.files, {pattern: './mocha.js.map', included: false}]
  };

  config.set(cfg);
};

/**
 * Creates dir `bundleDirPath` if it does not exist; returns new Karma config
 * containing `bundleDirPath` for rollup plugin.
 *
 * If this fails, the rollup plugin will use a temp dir.
 * @param {object} cfg - Karma config.
 * @param {string} [bundleDirPath] - Path where the output bundle should live
 * @returns {object} - New Karma config
 */
const createBundleDir = (cfg, bundleDirPath) => {
  if (bundleDirPath) {
    try {
      fs.mkdirSync(bundleDirPath, {recursive: true});
      cfg = {
        ...cfg,
        rollup: {
          ...cfg.rollup,
          bundleDirPath
        }
      };
    } catch (ignored) {
      console.error(
        `Failed to create ${bundleDirPath}; using temp directory instead`
      );
    }
  }
  return {...cfg};
};

/**
 * Adds Saucelabs-specific config to a Karma config object.
 *
 * If `sauceLabs` parameter is falsy, just return a clone of the `cfg` parameter.
 *
 * @see https://github.com/karma-runner/karma-sauce-launcher
 * @see https://github.com/bermi/sauce-connect-launcher#advanced-usage
 * @param {object} cfg - Karma config
 * @param {object} [sauceLabs] - SauceLabs config
 * @returns {object} Karma config
 */
const addSauceTests = (cfg, sauceLabs) => {
  if (sauceLabs) {
    const sauceBrowsers = Object.keys(SAUCE_BROWSER_PLATFORM_MAP);

    // creates Karma `customLauncher` configs from `SAUCE_BROWSER_PLATFORM_MAP`
    const customLaunchers = sauceBrowsers.reduce((acc, sauceBrowser) => {
      const platformName = SAUCE_BROWSER_PLATFORM_MAP[sauceBrowser];
      const [browserName, browserVersion] = sauceBrowser.split('@');
      return {
        ...acc,
        [sauceBrowser]: {
          base: 'SauceLabs',
          browserName,
          browserVersion,
          platformName,
          'sauce:options': sauceLabs
        }
      };
    }, {});

    return {
      ...cfg,
      reporters: [...cfg.reporters, 'saucelabs'],
      browsers: [...cfg.browsers, ...sauceBrowsers],
      customLaunchers: {
        ...cfg.customLaunchers,
        ...customLaunchers
      },
      sauceLabs,
      concurrency: Infinity,
      retryLimit: 1,
      captureTimeout: 120000,
      browserNoActivityTimeout: 20000
    };
  }
  return {...cfg};
};

/**
 * Returns a new Karma config containing standard dependencies for our tests.
 *
 * Most suites use this.
 * @param {object} cfg - Karma config
 * @returns {object} New Karma config
 */
const addStandardDependencies = cfg => ({
  ...cfg,
  files: [
    require.resolve('sinon/pkg/sinon.js'),
    require.resolve('unexpected/unexpected'),
    {
      pattern: require.resolve('unexpected/unexpected.js.map'),
      included: false
    },
    require.resolve('unexpected-sinon'),
    require.resolve('unexpected-eventemitter/dist/unexpected-eventemitter.js'),
    require.resolve('./test/browser-specific/setup'),
    ...cfg.files
  ],
  rollup: {
    ...cfg.rollup,
    external: [
      'sinon',
      'unexpected',
      'unexpected-eventemitter',
      'unexpected-sinon'
    ],
    globals: {
      sinon: 'sinon',
      unexpected: 'weknowhow.expect',
      'unexpected-sinon': 'weknowhow.unexpectedSinon',
      'unexpected-eventemitter': 'unexpectedEventEmitter'
    }
  }
});

/**
 * Adds a name for the tests, reflected in SauceLabs' UI. Returns new Karma
 * config.
 *
 * Does not add a test name if the `sauceLabs` prop of `cfg` is falsy (which
 * would imply that we're not running tests on SauceLabs).
 *
 * @param {string} testName - SauceLabs test name
 * @param {object} cfg - Karma config.
 * @returns {object} New Karma config
 */
const addSauceLabsTestName = (testName, cfg) =>
  cfg.sauceLabs
    ? {
        ...cfg,
        sauceLabs: {
          ...cfg.sauceLabs,
          testName
        }
      }
    : {...cfg};

/**
 * Returns a new Karma config to run with specific configuration (which cannot
 * be run with other configurations) as specified by `value`. Known values:
 *
 * - `bdd` - `bdd`-specific tests
 * - `tdd` - `tdd`-specific tests
 * - `qunit` - `qunit`-specific tests
 * - `esm` - ESM-specific tests
 * - `requirejs` - RequireJS-specific tests
 *
 * Since we can't change Mocha's interface on-the-fly, tests for specific interfaces
 * must be run in isolation.
 * @param {object} cfg - Karma config
 * @param {string} [value] - Configuration identifier, if any
 * @returns {object} New Karma config
 */
const chooseTestSuite = (cfg, value) => {
  switch (value) {
    case 'bdd':
    case 'tdd':
    case 'qunit':
      return addStandardDependencies({
        ...cfg,
        ...addSauceLabsTestName(`Interface "${value}" Integration Tests`, cfg),
        files: [`test/interfaces/${value}.spec.js`],
        client: {
          ...cfg.client,
          mocha: {
            ...cfg.client.mocha,
            ui: value
          }
        }
      });
    case 'esm':
      return addStandardDependencies({
        ...addSauceLabsTestName('ESM Integration Tests', cfg),
        // just run against ChromeHeadless, since other browsers may not
        // support ESM.
        // XXX: remove following line when dropping IE11
        browsers: ['ChromeHeadless'],
        files: [
          {
            pattern: 'test/browser-specific/fixtures/esm.fixture.mjs',
            type: 'module'
          },
          {
            pattern: 'test/browser-specific/esm.spec.mjs',
            type: 'module'
          }
        ]
      });
    case 'requirejs':
      // no standard deps because I'm too lazy to figure out how to make
      // them work with RequireJS. not important anyway
      return {
        ...addSauceLabsTestName('RequireJS Tests', cfg),
        plugins: [...cfg.plugins, 'karma-requirejs'],
        frameworks: ['requirejs', ...cfg.frameworks],
        files: [
          {
            pattern: 'test/browser-specific/fixtures/requirejs/*.fixture.js',
            included: false
          },
          'test/browser-specific/requirejs-setup.js'
        ],
        // this skips bundling the above tests & fixtures
        rollup: {
          ...cfg.rollup,
          include: []
        }
      };
    default:
      return addStandardDependencies({
        ...addSauceLabsTestName('Unit Tests', cfg)
      });
  }
};
<|endoftext|>


<commit_before>var utils  = require('../utils');

/**
 * session
 *
 * Takes a list of files and creates a set of file names that occur in subject
 * directories. Then generates a warning if a given subject is missing any
 * files from the set.
 */
var session = function missingSessionFiles(fileList) {
    var subjects = [];
    var issues = [];
    for (var key in fileList) {
        var file = fileList[key];
        var filename;

        if (!file || !file.webkitRelativePath) {
            continue;
        }

        var path = utils.files.relativePath(file);
        var subject;
        //match the subject identifier up to the '/' in the full path to a file.
        var match = path.match(/sub-(.*?)(?=\/)/);
        if (match === null) {
            continue;
        } else {
            subject = match[0];
        }
        // initialize an empty array if we haven't seen this subject before
        if (typeof(subjects[subject]) === 'undefined') {
            subjects[subject] = [];
        }
        // files are prepended with subject name, the following two commands
        // remove the subject from the file name to allow filenames to be more
        // easily compared
        filename = path.substring(path.match(subject).index + subject.length);
        filename = filename.replace(subject, '<sub>');
        subjects[subject].push(filename);
    }

    var subject_files = [];
    for (var subject in subjects) {
        subject_files = subject_files.concat(subjects[subject])
    }
    // Converting to a Set removes all duplicates
    all_files = new Set(subject_files);

    // Converting it back to an array for easy iteration
    all_files = Array.from(all_files);
    for (var subject in subjects) {
        for (var set_file in all_files) {
            if (subjects[subject].indexOf(all_files[set_file]) === -1) {
                filename = all_files[set_file].replace('<sub>', subject);
                file.relativePath = '/' + subject + filename;
                issues.push(new utils.Issue({
                    file: file,
                    evidence: "Subject: " + subject + "; Missing file: " + filename,
                    code: 38
                }));
            }
        }
    }
    return issues;
};

module.exports = session;
<commit_msg>added check to session validator similar to relativePath function to test if in browser or now<commit_after>var utils  = require('../utils');

/**
 * session
 *
 * Takes a list of files and creates a set of file names that occur in subject
 * directories. Then generates a warning if a given subject is missing any
 * files from the set.
 */
var session = function missingSessionFiles(fileList) {
    var subjects = [];
    var issues = [];
    for (var key in fileList) {
        var file = fileList[key];
        var filename;

        if (!file || (typeof window != 'undefined' && !file.webkitRelativePath)) {
            continue;
        }

        var path = utils.files.relativePath(file);
        var subject;
        //match the subject identifier up to the '/' in the full path to a file.
        var match = path.match(/sub-(.*?)(?=\/)/);
        if (match === null) {
            continue;
        } else {
            subject = match[0];
        }
        // initialize an empty array if we haven't seen this subject before
        if (typeof(subjects[subject]) === 'undefined') {
            subjects[subject] = [];
        }
        // files are prepended with subject name, the following two commands
        // remove the subject from the file name to allow filenames to be more
        // easily compared
        filename = path.substring(path.match(subject).index + subject.length);
        filename = filename.replace(subject, '<sub>');
        subjects[subject].push(filename);
    }

    var subject_files = [];
    for (var subject in subjects) {
        subject_files = subject_files.concat(subjects[subject])
    }
    // Converting to a Set removes all duplicates
    all_files = new Set(subject_files);

    // Converting it back to an array for easy iteration
    all_files = Array.from(all_files);
    for (var subject in subjects) {
        for (var set_file in all_files) {
            if (subjects[subject].indexOf(all_files[set_file]) === -1) {
                filename = all_files[set_file].replace('<sub>', subject);
                file.relativePath = '/' + subject + filename;
                issues.push(new utils.Issue({
                    file: file,
                    evidence: "Subject: " + subject + "; Missing file: " + filename,
                    code: 38
                }));
            }
        }
    }
    return issues;
};

module.exports = session;
<|endoftext|>


<commit_before>// Karma configuration
// Generated on Fri Mar 21 2014 17:52:41 GMT-0300 (ART)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['mocha'],

    // list of files / patterns to load in the browser
    files: [
      //Configs
      'config.js',

      'lib/angular/angular.min.js',
      'lib/angular-mocks/angular-mocks.js',
      'lib/moment/moment.js',
      'lib/angular-moment/angular-moment.js',
      'lib/qrcode-generator/js/qrcode.js',
      'lib/angular-qrcode/qrcode.js',
      'lib/angular-route/angular-route.min.js',
      'lib/angular-foundation/mm-foundation.min.js',
      'lib/angular-foundation/mm-foundation-tpls.min.js',
      'lib/peer.js',
      'lib/bitcore/browser/bundle.js',
      'lib/crypto-js/rollups/sha256.js',
      'lib/crypto-js/rollups/pbkdf2.js',
      'lib/crypto-js/rollups/aes.js',
      'lib/file-saver/FileSaver.js',
      'lib/socket.io.js',
      'lib/sjcl.js',
      'lib/ios-imagefile-megapixel/megapix-image.js',
      'lib/qrcode-decoder-js/lib/qrcode-decoder.min.js',
      'js/copayBundle.js',

      //Test-Specific Code
      'lib/chai/chai.js',
      'test/lib/chai-should.js',
      'test/lib/chai-expect.js',

      //Mocha stuff
      'test/mocha.conf.js',

      //test files
      'test/unit/**/*.js',

      //App-specific Code
      'js/app.js',
      'js/routes.js',
      'js/directives.js',
      'js/filters.js',
      'js/services/socket.js',
      'js/services/video.js',
      'js/services/walletFactory.js',
      'js/services/controllerUtils.js',
      'js/services/passphrase.js',
      'js/services/notifications.js',
      'js/controllers/header.js',
      'js/controllers/footer.js',
      'js/controllers/addresses.js',
      'js/controllers/transactions.js',
      'js/controllers/send.js',
      'js/controllers/backup.js',
      'js/controllers/signin.js',
      'js/controllers/setup.js',
      'js/controllers/import.js',
      'js/controllers/settings.js',
      'js/init.js'
    ],

    // list of files to exclude
    exclude: [],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {

    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // if browser doesn't capture output in given timeout (ms), kill it
    captureTimeout: 60000
  });
};
<commit_msg>Improve karma config<commit_after>// Karma configuration
// Generated on Fri Mar 21 2014 17:52:41 GMT-0300 (ART)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['mocha'],

    // list of files / patterns to load in the browser
    files: [
      //Configs
      'config.js',

      'lib/angular/angular.min.js',
      'lib/angular-mocks/angular-mocks.js',
      'lib/moment/moment.js',
      'lib/angular-moment/angular-moment.js',
      'lib/qrcode-generator/js/qrcode.js',
      'lib/angular-qrcode/qrcode.js',
      'lib/angular-route/angular-route.min.js',
      'lib/angular-foundation/mm-foundation.min.js',
      'lib/angular-foundation/mm-foundation-tpls.min.js',
      'lib/peer.js',
      'lib/bitcore/browser/bundle.js',
      'lib/crypto-js/rollups/sha256.js',
      'lib/crypto-js/rollups/pbkdf2.js',
      'lib/crypto-js/rollups/aes.js',
      'lib/file-saver/FileSaver.js',
      'lib/socket.io.js',
      'lib/sjcl.js',
      'lib/ios-imagefile-megapixel/megapix-image.js',
      'lib/qrcode-decoder-js/lib/qrcode-decoder.min.js',
      'js/copayBundle.js',

      //Test-Specific Code
      'lib/chai/chai.js',
      'test/lib/chai-should.js',
      'test/lib/chai-expect.js',

      //Mocha stuff
      'test/mocha.conf.js',

      //test files
      'test/unit/**/*.js',

      //App-specific Code
      'js/app.js',
      'js/routes.js',
      'js/directives.js',
      'js/filters.js',
      'js/services/*.js',
      'js/controllers/*.js',
      'js/init.js'
    ],

    // list of files to exclude
    exclude: [],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {

    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // if browser doesn't capture output in given timeout (ms), kill it
    captureTimeout: 60000
  });
};
<|endoftext|>


<commit_before>/***************************************************************************
 * This is the pubsub driver that should tell caspa about the melted status
 *
 * this code is more than slightly coupled with caspa's section that deals
 * with the messages. It should probably be refactored a little, things like
 * creating constants in and handling db collections in mbc-common
 ***************************************************************************/
var events = require('events');
var util = require('util');
var _ = require('underscore');
var mbc = require('mbc-common');

defaults = { // copied from caspa/models.App.Status
    _id: 2,
    piece: {
        previous: {name: ''},
        current:  {name: '', progress: '0%'},
        next:     {name: ''},
    },
    show: {
        previous: {_id: -1},
        current:  {_id: -1},
        next:     {_id: -1},
    },
    source: null,
    on_air: false,
};

function MostoMessage(value, description, message) {
    this.value = value;
    this.description = description;
    this.message = message;
}

function CaspaDriver() {
    events.EventEmitter.call(this);
    var self = this;
    this.status = _.clone(defaults);
    this.db = mbc.db();
    this.publisher = mbc.pubsub();
}
util.inherits(CaspaDriver, events.EventEmitter);

CaspaDriver.prototype.setupAll = function() {
    var self = this;
    var setups = [
        this.setupStatus.bind(this),
        this.setupMessages.bind(this),
    ];
    var sendReady = _.after(setups.length, function() {
        self.emit('ready');
    });
    setups.forEach(function(setup){
        setup(sendReady);
    });
};

CaspaDriver.prototype.setupStatus = function(callback) {
    var self = this;
    var col = this.db.collection('status');
    col.findOne({_id: 2}, function(err, res) {
        if( err )
            // err.. do something?
            return;
        if( !res ) {
            // the status doesn't exist, create it
            col.save(self.status, function(err, itm) {
                callback();
            });
        } else {
            // res existed, just signal as ready
            callback();
        }
    });
};

CaspaDriver.prototype.setupMessages = function(callback) {
    // I think we should assume at init there's no sticky errors?
    this.db.collection('mostomessages').remove(callback);
};

CaspaDriver.prototype.setStatus = function(meltedStatus) {
    // this overrides this.status with the values passed by status
    function makePiece(clip) {
        if (clip===undefined) return { name: '', _id: '' };
        return {
            name: clip.name,
            _id: clip.id
        }
    }

    var clips = meltedStatus.clips;
    var status = {
        piece: {
            previous: makePiece(meltedStatus.clip.previous),
            current:  makePiece(meltedStatus.clip.current),
            next:     makePiece(meltedStatus.clip.next),
        },
        show: {
            previous: { _id: meltedStatus.show.previous },
            current: { _id: meltedStatus.show.current },
            next: { _id: meltedStatus.show.next },
        },
        on_air: true,
    };
    status.piece.current.progress = meltedStatus.position * 100 + "%";

    this.status = _.extend(this.status, status);
    // except next. If that's undefined, I just don't know!
    this.status.show.next = status.show.next;
    this.publishStatus(status);
};

CaspaDriver.prototype.setStatusClip = function(statusClip) {}

CaspaDriver.prototype.publishStatus = function(status) {
    this.publisher.publishJSON("mostoStatus", status)
};

CaspaDriver.prototype.publishMessage = function(code, description, message, sticky) {
    message = new MostoMessage(code, description, message);
    var method = 'emit';
    if( sticky ) {
        // I create an id with the timestamp to be able to cancel the error afterwards
        message.stickId = (new moment()).valueOf();
        method = 'create';
    }
    this.publisher.publishJSON(["mostoMessage", method].join('.'),
                               { model: message });
    return message;
};

CaspaDriver.prototype.dropMessage = function(message) {
    this.publisher.publish("mostoMessage.delete", { model: message });
};

exports = module.exports = function() {
    var driver = new CaspaDriver();
    driver.setupAll();

    return driver;
};
<commit_msg>change publishing method<commit_after>/***************************************************************************
 * This is the pubsub driver that should tell caspa about the melted status
 *
 * this code is more than slightly coupled with caspa's section that deals
 * with the messages. It should probably be refactored a little, things like
 * creating constants in and handling db collections in mbc-common
 ***************************************************************************/
var events = require('events');
var util = require('util');
var _ = require('underscore');
var mbc = require('mbc-common');

defaults = { // copied from caspa/models.App.Status
    _id: 2,
    piece: {
        previous: {name: ''},
        current:  {name: '', progress: '0%'},
        next:     {name: ''},
    },
    show: {
        previous: {_id: -1},
        current:  {_id: -1},
        next:     {_id: -1},
    },
    source: null,
    on_air: false,
};

function MostoMessage(value, description, message) {
    this.value = value;
    this.description = description;
    this.message = message;
}

function CaspaDriver() {
    events.EventEmitter.call(this);
    var self = this;
    this.status = _.clone(defaults);
    this.db = mbc.db();
    this.publisher = mbc.pubsub();
}
util.inherits(CaspaDriver, events.EventEmitter);

CaspaDriver.prototype.setupAll = function() {
    var self = this;
    var setups = [
        this.setupStatus.bind(this),
        this.setupMessages.bind(this),
    ];
    var sendReady = _.after(setups.length, function() {
        self.emit('ready');
    });
    setups.forEach(function(setup){
        setup(sendReady);
    });
};

CaspaDriver.prototype.setupStatus = function(callback) {
    var self = this;
    var col = this.db.collection('status');
    col.findOne({_id: 2}, function(err, res) {
        if( err )
            // err.. do something?
            return;
        if( !res ) {
            // the status doesn't exist, create it
            col.save(self.status, function(err, itm) {
                callback();
            });
        } else {
            // res existed, just signal as ready
            callback();
        }
    });
};

CaspaDriver.prototype.setupMessages = function(callback) {
    // I think we should assume at init there's no sticky errors?
    this.db.collection('mostomessages').remove(callback);
};

CaspaDriver.prototype.setStatus = function(meltedStatus) {
    // this overrides this.status with the values passed by status
    function makePiece(clip) {
        if (clip===undefined) return { name: '', _id: '' };
        return {
            name: clip.name,
            _id: clip.id
        }
    }

    var clips = meltedStatus.clips;
    var status = {
        piece: {
            previous: makePiece(meltedStatus.clip.previous),
            current:  makePiece(meltedStatus.clip.current),
            next:     makePiece(meltedStatus.clip.next),
        },
        show: {
            previous: { _id: meltedStatus.show.previous },
            current: { _id: meltedStatus.show.current },
            next: { _id: meltedStatus.show.next },
        },
        on_air: true,
    };
    status.piece.current.progress = meltedStatus.position * 100 + "%";

    this.status = _.extend(this.status, status);
    // except next. If that's undefined, I just don't know!
    this.status.show.next = status.show.next;
    this.publish("mostoStatus", status);
};

CaspaDriver.prototype.setStatusClip = function(statusClip) {}

CaspaDriver.prototype.publish = function(channel, status) {
    this.publisher.publishJSON(channel, status);
};

CaspaDriver.prototype.publishMessage = function(code, description, message, sticky) {
    message = new MostoMessage(code, description, message);
    var method = 'emit';
    if( sticky ) {
        // I create an id with the timestamp to be able to cancel the error afterwards
        message.stickId = (new moment()).valueOf();
        method = 'create';
    }
    this.publisher.publishJSON(["mostoMessage", method].join('.'),
                               { model: message });
    return message;
};

CaspaDriver.prototype.dropMessage = function(message) {
    this.publisher.publish("mostoMessage.delete", { model: message });
};

exports = module.exports = function() {
    var driver = new CaspaDriver();
    driver.setupAll();

    return driver;
};
<|endoftext|>


<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import { App } from './App';

it('renders without crashing', () => {
  const div = document.createElement('div');
  ReactDOM.render(<App />, div);
});
<commit_msg>update sanity check App test to work with Redux<commit_after>import React from 'react';
import ReactDOM from 'react-dom';

import { Provider } from 'react-redux';
import { createStore } from 'redux';

import reducers from '../redux/reducers';
import { App } from './App';

// mock APIs
function getFoodlist(){
  return [];
}
function getDataSources(){
  return [];
}
const store = createStore(reducers);

it('renders without crashing', () => {
  const div = document.createElement('div');
  ReactDOM.render(<Provider store={store}><App getFoodlist={getFoodlist} getDataSources={getDataSources} /></Provider>, div);
});
<|endoftext|>