<commit_before>const assert = require('assert');
const sinon = require('sinon');
const werelogs = require('werelogs');

const testEvents = [{
    action: 'getObject',
    metrics: {
        bucket: 'bucket1',
        keys: ['1.txt'],
        newByteLength: 2,
        oldByteLength: null,
        versionId: undefined,
        location: 'us-west-1',
        numberOfObjects: 1,
        byteLength: null,
        isDelete: false,
    },
    expected: {
        objectDelta: 1,
        sizeDelta: 0,
        incomingBytes: 0,
        outgoingBytes: 2,
    },
}, {
    action: 'deleteObject',
    metrics: {
        bucket: 'bucket1',
        keys: ['1.txt'],
        byteLength: 2,
        numberOfObjects: 1,
        location: 'us-west-1',
        isDelete: true,
    },
    expected: {
        objectDelta: -1,
        sizeDelta: -2,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'listBucket',
    metrics: {
        bucket: 'bucket1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putObject',
    metrics: {
        bucket: 'bucket1',
        keys: ['2.txt'],
        newByteLength: 2,
        oldByteLength: null,
        versionId: undefined,
        location: 'us-west-1',
        numberOfObjects: 1,
    },
    expected: {
        objectDelta: 1,
        sizeDelta: 2,
        incomingBytes: 2,
        outgoingBytes: 0,
    },
}, {
    action: 'listBucket',
    metrics: {
        bucket: 'bucket1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'headObject',
    metrics: {
        bucket: 'bucket1',
        keys: ['1.txt'],
        versionId: undefined,
        location: 'us-west-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'abortMultipartUpload',
    metrics: {
        bucket: 'destinationbucket815502017',
        keys: ['copycatobject'],
        byteLength: 26,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'completeMultipartUpload',
    metrics: {
        oldByteLength: null,
        bucket: 'destinationbucket815502017',
        keys: ['copycatobject'],
        versionId: undefined,
        numberOfObjects: 1,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: 1,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'createBucket',
    metrics: {
        bucket: 'deletebucketpolicy-test-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'deleteBucket',
    metrics: {
        bucket: 'deletebucketpolicy-test-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'deleteBucketCors',
    metrics: {
        bucket: 'testdeletecorsbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'deleteBucketReplication',
    metrics: {
        bucket: 'source-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'deleteBucketWebsite',
    metrics: {
        bucket: 'testdeletewebsitebucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketAcl',
    metrics: {
        bucket: 'putbucketaclfttest',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketCors',
    metrics: {
        bucket: 'testgetcorsbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketLocation',
    metrics: {
        bucket: 'testgetlocationbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketNotification',
    metrics: {
        bucket: 'notificationtestbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketObjectLock',
    metrics: {
        bucket: 'mock-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketReplication',
    metrics: {
        bucket: 'source-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketVersioning',
    metrics: {
        bucket: 'bucket-with-object-lock',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketWebsite',
    metrics: {
        bucket: 'testgetwebsitetestbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getObjectTagging',
    metrics: {
        bucket: 'completempu1615102906771',
        keys: ['keywithtags'],
        versionId: undefined,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'headObject',
    metrics: {
        bucket: 'supersourcebucket81033016532',
        keys: ['supersourceobject'],
        versionId: undefined,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'initiateMultipartUpload',
    metrics: {
        bucket: 'destinationbucket815502017',
        keys: ['copycatobject'],
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'listMultipartUploadParts',
    metrics: {
        bucket: 'ftest-mybucket-74',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'multiObjectDelete',
    metrics: {
        bucket: 'completempu1615102906771',
        keys: [undefined],
        byteLength: 3,
        numberOfObjects: 1,
        isDelete: true,
    },
    expected: {
        objectDelta: -1,
        sizeDelta: -3,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketAcl',
    metrics: {
        bucket: 'putbucketaclfttest',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketCors',
    metrics: {
        bucket: 'testcorsbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketNotification',
    metrics: {
        bucket: 'notificationtestbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketObjectLock',
    metrics: {
        bucket: 'mock-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketReplication',
    metrics: {
        bucket: 'source-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketVersioning',
    metrics: {
        bucket: 'source-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketWebsite',
    metrics: {
        bucket: 'testgetwebsitetestbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'uploadPart',
    metrics: {
        bucket: 'ftest-mybucket-74',
        keys: ['toAbort&<>"\''],
        newByteLength: 5242880,
        oldByteLength: null,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: 5242880,
        incomingBytes: 5242880,
        outgoingBytes: 0,
    },
}, {
    action: 'uploadPartCopy',
    metrics: {
        bucket: 'destinationbucket815502017',
        keys: ['copycatobject'],
        newByteLength: 26,
        oldByteLength: null,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: 26,
        incomingBytes: 26,
        outgoingBytes: 0,
    },
}];

describe('utapi v2 pushmetrics utility', () => {
    const log = new werelogs.Logger('utapi-utility');
    const { UtapiClient, utapiVersion } = require('utapi');
    let pushMetric;

    function pushMetricStub(event) {
        return event;
    }

    before(() => {
        assert.strictEqual(utapiVersion, 2);
        sinon.stub(UtapiClient.prototype, 'pushMetric')
            .callsFake(pushMetricStub);
        pushMetric = require('../../lib/utapi/utilities').pushMetric;
    });

    after(() => {
        sinon.restore();
    });

    testEvents.forEach(event => {
        it(`should compute and push metrics for ${event.action}`, () => {
            const eventPushed = pushMetric(event.action, log, event.metrics);
            assert(eventPushed);
            Object.keys(event.expected).forEach(key => {
                assert.strictEqual(eventPushed[key], event.expected[key]);
            });
        });
    });
});
<commit_msg>fix expected metrics<commit_after>const assert = require('assert');
const sinon = require('sinon');
const werelogs = require('werelogs');

const testEvents = [{
    action: 'getObject',
    metrics: {
        bucket: 'bucket1',
        keys: ['1.txt'],
        newByteLength: 2,
        oldByteLength: null,
        versionId: undefined,
        location: 'us-west-1',
        numberOfObjects: 1,
        byteLength: null,
        isDelete: false,
    },
    expected: {
        objectDelta: 1,
        sizeDelta: 0,
        incomingBytes: 0,
        outgoingBytes: 2,
    },
}, {
    action: 'deleteObject',
    metrics: {
        bucket: 'bucket1',
        keys: ['1.txt'],
        byteLength: 2,
        numberOfObjects: 1,
        location: 'us-west-1',
        isDelete: true,
    },
    expected: {
        objectDelta: -1,
        sizeDelta: -2,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'listBucket',
    metrics: {
        bucket: 'bucket1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putObject',
    metrics: {
        bucket: 'bucket1',
        keys: ['2.txt'],
        newByteLength: 2,
        oldByteLength: null,
        versionId: undefined,
        location: 'us-west-1',
        numberOfObjects: 1,
    },
    expected: {
        objectDelta: 1,
        sizeDelta: 2,
        incomingBytes: 2,
        outgoingBytes: 0,
    },
}, {
    action: 'listBucket',
    metrics: {
        bucket: 'bucket1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'headObject',
    metrics: {
        bucket: 'bucket1',
        keys: ['1.txt'],
        versionId: undefined,
        location: 'us-west-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'abortMultipartUpload',
    metrics: {
        bucket: 'destinationbucket815502017',
        keys: ['copycatobject'],
        byteLength: 26,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: -26,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'completeMultipartUpload',
    metrics: {
        oldByteLength: null,
        bucket: 'destinationbucket815502017',
        keys: ['copycatobject'],
        versionId: undefined,
        numberOfObjects: 1,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: 1,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'createBucket',
    metrics: {
        bucket: 'deletebucketpolicy-test-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'deleteBucket',
    metrics: {
        bucket: 'deletebucketpolicy-test-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'deleteBucketCors',
    metrics: {
        bucket: 'testdeletecorsbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'deleteBucketReplication',
    metrics: {
        bucket: 'source-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'deleteBucketWebsite',
    metrics: {
        bucket: 'testdeletewebsitebucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketAcl',
    metrics: {
        bucket: 'putbucketaclfttest',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketCors',
    metrics: {
        bucket: 'testgetcorsbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketLocation',
    metrics: {
        bucket: 'testgetlocationbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketNotification',
    metrics: {
        bucket: 'notificationtestbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketObjectLock',
    metrics: {
        bucket: 'mock-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketReplication',
    metrics: {
        bucket: 'source-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketVersioning',
    metrics: {
        bucket: 'bucket-with-object-lock',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getBucketWebsite',
    metrics: {
        bucket: 'testgetwebsitetestbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'getObjectTagging',
    metrics: {
        bucket: 'completempu1615102906771',
        keys: ['keywithtags'],
        versionId: undefined,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'headObject',
    metrics: {
        bucket: 'supersourcebucket81033016532',
        keys: ['supersourceobject'],
        versionId: undefined,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'initiateMultipartUpload',
    metrics: {
        bucket: 'destinationbucket815502017',
        keys: ['copycatobject'],
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'listMultipartUploadParts',
    metrics: {
        bucket: 'ftest-mybucket-74',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'multiObjectDelete',
    metrics: {
        bucket: 'completempu1615102906771',
        keys: [undefined],
        byteLength: 3,
        numberOfObjects: 1,
        isDelete: true,
    },
    expected: {
        objectDelta: -1,
        sizeDelta: -3,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketAcl',
    metrics: {
        bucket: 'putbucketaclfttest',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketCors',
    metrics: {
        bucket: 'testcorsbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketNotification',
    metrics: {
        bucket: 'notificationtestbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketObjectLock',
    metrics: {
        bucket: 'mock-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketReplication',
    metrics: {
        bucket: 'source-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketVersioning',
    metrics: {
        bucket: 'source-bucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'putBucketWebsite',
    metrics: {
        bucket: 'testgetwebsitetestbucket',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: undefined,
        incomingBytes: undefined,
        outgoingBytes: 0,
    },
}, {
    action: 'uploadPart',
    metrics: {
        bucket: 'ftest-mybucket-74',
        keys: ['toAbort&<>"\''],
        newByteLength: 5242880,
        oldByteLength: null,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: 5242880,
        incomingBytes: 5242880,
        outgoingBytes: 0,
    },
}, {
    action: 'uploadPartCopy',
    metrics: {
        bucket: 'destinationbucket815502017',
        keys: ['copycatobject'],
        newByteLength: 26,
        oldByteLength: null,
        location: 'us-east-1',
    },
    expected: {
        objectDelta: undefined,
        sizeDelta: 26,
        incomingBytes: 26,
        outgoingBytes: 0,
    },
}];

describe('utapi v2 pushmetrics utility', () => {
    const log = new werelogs.Logger('utapi-utility');
    const { UtapiClient, utapiVersion } = require('utapi');
    let pushMetric;

    function pushMetricStub(event) {
        return event;
    }

    before(() => {
        assert.strictEqual(utapiVersion, 2);
        sinon.stub(UtapiClient.prototype, 'pushMetric')
            .callsFake(pushMetricStub);
        pushMetric = require('../../lib/utapi/utilities').pushMetric;
    });

    after(() => {
        sinon.restore();
    });

    testEvents.forEach(event => {
        it(`should compute and push metrics for ${event.action}`, () => {
            const eventPushed = pushMetric(event.action, log, event.metrics);
            assert(eventPushed);
            Object.keys(event.expected).forEach(key => {
                assert.strictEqual(eventPushed[key], event.expected[key]);
            });
        });
    });
});
<|endoftext|>


<commit_before>var config = require('../config');
var logger = require('lib/logger')(module);
var startTime = Date.parse(config.get('startTime'));
var finishTime = Date.parse(config.get('finishTime'));
var Problem = require('models/problem').Problem;

module.exports = function (req, res, next) {
    Problem.count({},function(err,count){
        var lastProblemSolved = req.user.problemHistory[req.user.problemHistory.length -1].solved;
        if(count === req.user.problemHistory.length && lastProblemSolved){
            logger.info("finish: problemCount: = " + count + " historyLength = " + req.user.problemHistory.length);
            res.render('finish');
        }
        else{
 /*           logger.info(startTime);
            logger.info(Date.now());
            logger.info(finishTime);
*/
            if (Date.now() < startTime) {
                res.locals.timeStart = Date.parse(config.get('startTime'));
                res.render('start');
            }
            else {
                if (Date.now() > finishTime) {
                    res.render('finish');
                }
                else  next();
            }
        }
    });
}<commit_msg>fix finish<commit_after>var config = require('../config');
var logger = require('lib/logger')(module);
var startTime = Date.parse(config.get('startTime'));
var finishTime = Date.parse(config.get('finishTime'));
var Problem = require('models/problem').Problem;

module.exports = function (req, res, next) {
    Problem.count({},function(err,count){
        var lastProblemSolved = req.user.problemHistory[req.user.problemHistory.length -1].solved;
        if(count === req.user.problemHistory.length && lastProblemSolved){
            logger.info("finish: problemCount: = " + count + " historyLength = " + req.user.problemHistory.length);
            return res.render('finish');
        }
        else{
 /*           logger.info(startTime);
            logger.info(Date.now());
            logger.info(finishTime);
*/
            if (Date.now() < startTime) {
                res.locals.timeStart = Date.parse(config.get('startTime'));
                res.render('start');
            }
            else {
                if (Date.now() > finishTime) {
                    return res.render('finish');
                }
                else  next();
            }
        }
    });
}
<|endoftext|>


<commit_before>"use strict";

exports.__esModule = true;
exports.Login = exports.FetchChain = exports.ChainValidation = exports.TransactionHelper = exports.NumberUtils = exports.ObjectId = exports.EmitterInstance = exports.ChainTypes = exports.FetchChainObjects = exports.TransactionBuilder = exports.ChainStore = exports.ECSignature = exports.key = exports.hash = exports.brainKey = exports.Signature = exports.PublicKey = exports.PrivateKey = exports.Aes = exports.Address = exports.object_id_type = exports.string_to_name = exports.name_to_string = exports.SerializerValidation = exports.template = exports.ops = exports.types = exports.fp = exports.Serializer = undefined;

var _serializer = require("./serializer/src/serializer");

var _serializer2 = _interopRequireDefault(_serializer);

var _FastParser = require("./serializer/src/FastParser");

var _FastParser2 = _interopRequireDefault(_FastParser);

var _types = require("./serializer/src/types");

var _types2 = _interopRequireDefault(_types);

var _operations = require("./serializer/src/operations");

var ops = _interopRequireWildcard(_operations);

var _template = require("./serializer/src/template");

var _template2 = _interopRequireDefault(_template);

var _SerializerValidation = require("./serializer/src/SerializerValidation");

var _SerializerValidation2 = _interopRequireDefault(_SerializerValidation);

var _address = require("./ecc/src/address");

var _address2 = _interopRequireDefault(_address);

var _aes = require("./ecc/src/aes");

var _aes2 = _interopRequireDefault(_aes);

var _PrivateKey = require("./ecc/src/PrivateKey");

var _PrivateKey2 = _interopRequireDefault(_PrivateKey);

var _PublicKey = require("./ecc/src/PublicKey");

var _PublicKey2 = _interopRequireDefault(_PublicKey);

var _signature = require("./ecc/src/signature");

var _signature2 = _interopRequireDefault(_signature);

var _ecsignature = require("./ecc/src/ecsignature");

var _ecsignature2 = _interopRequireDefault(_ecsignature);

var _BrainKey = require("./ecc/src/BrainKey");

var _BrainKey2 = _interopRequireDefault(_BrainKey);

var _hash = require("./ecc/src/hash");

var hash = _interopRequireWildcard(_hash);

var _KeyUtils = require("./ecc/src/KeyUtils");

var _KeyUtils2 = _interopRequireDefault(_KeyUtils);

var _ChainStore = require("./chain/src/ChainStore");

var _ChainStore2 = _interopRequireDefault(_ChainStore);

var _TransactionBuilder = require("./chain/src/TransactionBuilder");

var _TransactionBuilder2 = _interopRequireDefault(_TransactionBuilder);

var _ChainTypes = require("./chain/src/ChainTypes");

var _ChainTypes2 = _interopRequireDefault(_ChainTypes);

var _ObjectId = require("./chain/src/ObjectId");

var _ObjectId2 = _interopRequireDefault(_ObjectId);

var _NumberUtils = require("./chain/src/NumberUtils");

var _NumberUtils2 = _interopRequireDefault(_NumberUtils);

var _TransactionHelper = require("./chain/src/TransactionHelper");

var _TransactionHelper2 = _interopRequireDefault(_TransactionHelper);

var _ChainValidation = require("./chain/src/ChainValidation");

var _ChainValidation2 = _interopRequireDefault(_ChainValidation);

var _EmitterInstance = require("./chain/src/EmitterInstance");

var _EmitterInstance2 = _interopRequireDefault(_EmitterInstance);

var _AccountLogin = require("./chain/src/AccountLogin");

var _AccountLogin2 = _interopRequireDefault(_AccountLogin);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/* ECC */
/* Serializer */
exports.Serializer = _serializer2.default;
exports.fp = _FastParser2.default;
exports.types = _types2.default;
exports.ops = ops;
exports.template = _template2.default;
exports.SerializerValidation = _SerializerValidation2.default;
exports.name_to_string = _types.name_to_string;
exports.string_to_name = _types.string_to_name;
exports.object_id_type = _types.object_id_type;
/* Chain */

exports.Address = _address2.default;
exports.Aes = _aes2.default;
exports.PrivateKey = _PrivateKey2.default;
exports.PublicKey = _PublicKey2.default;
exports.Signature = _signature2.default;
exports.brainKey = _BrainKey2.default;
exports.hash = hash;
exports.key = _KeyUtils2.default;
exports.ECSignature = _ecsignature2.default;

// const {FetchChainObjects, FetchChain} = ChainStore;

exports.ChainStore = _ChainStore2.default;
exports.TransactionBuilder = _TransactionBuilder2.default;
exports.FetchChainObjects = FetchChainObjects;
exports.ChainTypes = _ChainTypes2.default;
exports.EmitterInstance = _EmitterInstance2.default;
exports.ObjectId = _ObjectId2.default;
exports.NumberUtils = _NumberUtils2.default;
exports.TransactionHelper = _TransactionHelper2.default;
exports.ChainValidation = _ChainValidation2.default;
exports.FetchChain = FetchChain;
exports.Login = _AccountLogin2.default;<commit_msg>chore: update dist<commit_after>"use strict";

exports.__esModule = true;
exports.Login = exports.FetchChain = exports.ChainValidation = exports.TransactionHelper = exports.NumberUtils = exports.ObjectId = exports.EmitterInstance = exports.ChainTypes = exports.FetchChainObjects = exports.TransactionBuilder = exports.ChainStore = exports.ECSignature = exports.key = exports.hash = exports.brainKey = exports.Signature = exports.PublicKey = exports.PrivateKey = exports.Aes = exports.Address = exports.object_id_type = exports.string_to_name = exports.name_to_string = exports.SerializerValidation = exports.template = exports.ops = exports.types = exports.fp = exports.Serializer = undefined;

var _serializer = require("./serializer/src/serializer");

var _serializer2 = _interopRequireDefault(_serializer);

var _FastParser = require("./serializer/src/FastParser");

var _FastParser2 = _interopRequireDefault(_FastParser);

var _types = require("./serializer/src/types");

var _types2 = _interopRequireDefault(_types);

var _operations = require("./serializer/src/operations");

var ops = _interopRequireWildcard(_operations);

var _template = require("./serializer/src/template");

var _template2 = _interopRequireDefault(_template);

var _SerializerValidation = require("./serializer/src/SerializerValidation");

var _SerializerValidation2 = _interopRequireDefault(_SerializerValidation);

var _address = require("./ecc/src/address");

var _address2 = _interopRequireDefault(_address);

var _aes = require("./ecc/src/aes");

var _aes2 = _interopRequireDefault(_aes);

var _PrivateKey = require("./ecc/src/PrivateKey");

var _PrivateKey2 = _interopRequireDefault(_PrivateKey);

var _PublicKey = require("./ecc/src/PublicKey");

var _PublicKey2 = _interopRequireDefault(_PublicKey);

var _signature = require("./ecc/src/signature");

var _signature2 = _interopRequireDefault(_signature);

var _ecsignature = require("./ecc/src/ecsignature");

var _ecsignature2 = _interopRequireDefault(_ecsignature);

var _BrainKey = require("./ecc/src/BrainKey");

var _BrainKey2 = _interopRequireDefault(_BrainKey);

var _hash = require("./ecc/src/hash");

var hash = _interopRequireWildcard(_hash);

var _KeyUtils = require("./ecc/src/KeyUtils");

var _KeyUtils2 = _interopRequireDefault(_KeyUtils);

var _ChainStore = require("./chain/src/ChainStore");

var _ChainStore2 = _interopRequireDefault(_ChainStore);

var _TransactionBuilder = require("./chain/src/TransactionBuilder");

var _TransactionBuilder2 = _interopRequireDefault(_TransactionBuilder);

var _ChainTypes = require("./chain/src/ChainTypes");

var _ChainTypes2 = _interopRequireDefault(_ChainTypes);

var _ObjectId = require("./chain/src/ObjectId");

var _ObjectId2 = _interopRequireDefault(_ObjectId);

var _NumberUtils = require("./chain/src/NumberUtils");

var _NumberUtils2 = _interopRequireDefault(_NumberUtils);

var _TransactionHelper = require("./chain/src/TransactionHelper");

var _TransactionHelper2 = _interopRequireDefault(_TransactionHelper);

var _ChainValidation = require("./chain/src/ChainValidation");

var _ChainValidation2 = _interopRequireDefault(_ChainValidation);

var _EmitterInstance = require("./chain/src/EmitterInstance");

var _EmitterInstance2 = _interopRequireDefault(_EmitterInstance);

var _AccountLogin = require("./chain/src/AccountLogin");

var _AccountLogin2 = _interopRequireDefault(_AccountLogin);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/* ECC */
/* Serializer */
exports.Serializer = _serializer2.default;
exports.fp = _FastParser2.default;
exports.types = _types2.default;
exports.ops = ops;
exports.template = _template2.default;
exports.SerializerValidation = _SerializerValidation2.default;
exports.name_to_string = _types.name_to_string;
exports.string_to_name = _types.string_to_name;
exports.object_id_type = _types.object_id_type;
/* Chain */

exports.Address = _address2.default;
exports.Aes = _aes2.default;
exports.PrivateKey = _PrivateKey2.default;
exports.PublicKey = _PublicKey2.default;
exports.Signature = _signature2.default;
exports.brainKey = _BrainKey2.default;
exports.hash = hash;
exports.key = _KeyUtils2.default;
exports.ECSignature = _ecsignature2.default;

// in order to use webpack tree shaking to reduce bundle size
// const {FetchChainObjects, FetchChain} = ChainStore;

exports.ChainStore = _ChainStore2.default;
exports.TransactionBuilder = _TransactionBuilder2.default;
exports.FetchChainObjects = FetchChainObjects;
exports.ChainTypes = _ChainTypes2.default;
exports.EmitterInstance = _EmitterInstance2.default;
exports.ObjectId = _ObjectId2.default;
exports.NumberUtils = _NumberUtils2.default;
exports.TransactionHelper = _TransactionHelper2.default;
exports.ChainValidation = _ChainValidation2.default;
exports.FetchChain = FetchChain;
exports.Login = _AccountLogin2.default;<|endoftext|>


<commit_before>/* Player
 *
 */

var Player = (function(window, document, hyperaudio, Popcorn) {

	function Player(options) {

		this.options = hyperaudio.extend({}, this.options, {

			entity: 'PLAYER', // Not really an option... More like a manifest

			target: '#transcript-video', // The selector of element where the video is generated

			media: {
				youtube: '', // The URL of the Youtube video.
				mp4: '', // The URL of the mp4 video.
				webm:'' // The URL of the webm video.
			},

			// Types valid in a video element
			mediaType: {
				mp4: 'video/mp4', // The mp4 mime type.
				webm:'video/webm' // The webm mime type.
			},

			guiNative: false, // TMP during dev. Either we have a gui or we are chomeless.

			gui: false, // True to add a gui, or Object to pass GUI options.
			cssClass: 'hyperaudio-player', // Class added to the target for the GUI CSS. (passed to GUI and Projector)
			solutionClass: 'solution', // Class added to the solution that is active.
			async: true // When true, some operations are delayed by a timeout.
		}, options);

		// Properties
		this.target = typeof this.options.target === 'string' ? document.querySelector(this.options.target) : this.options.target;
		this.videoElem = null;
		this.timeout = {};
		this.commandsIgnored = /ipad|iphone|ipod|android/i.test(window.navigator.userAgent);

		// List of the media types, used to check for changes in media.
		this.mediaTypes = "youtube mp4 webm";

		this.youtube = false; // A flag to indicate if the YT player being used.

		// Until the YouTube wrapper is fixed, we need to recreate it and the listeners when the YT media changes.
		this.ytFix = [];

		if(this.options.DEBUG) {
			this._debug();
		}

		if(this.target) {
			this.create();
		}
	}

	Player.prototype = {
		create: function() {
			var self = this;

			if(this.target) {

				this.wrapper = {
					html: document.createElement('div'),
					youtube: document.createElement('div')
				};
				hyperaudio.addClass(this.wrapper.html, this.options.cssClass + '-video-wrapper');
				hyperaudio.addClass(this.wrapper.youtube, this.options.cssClass + '-youtube-wrapper');

				this.solution = {
					html: document.createElement('video'),
					youtube: Popcorn.HTMLYouTubeVideoElement(this.wrapper.youtube)
				};

				// Default to a video element to start with
				this.videoElem = this.solution.html;
				this.youtube = false;
				this.updateSolution();

				this.solution.html.controls = this.options.guiNative; // TMP during dev. Either we have a gui or we are chomeless.

				// Add listeners to the video element
				this.solution.html.addEventListener('progress', function(e) {
					if(this.readyState > 0) {
						this.commandsIgnored = false;
					}
				}, false);

				// Clear the target element and add the video
				this.empty(this.target);
				this.wrapper.html.appendChild(this.solution.html);
				// this.wrapper.youtube.appendChild(this.solution.youtube);
				this.target.appendChild(this.wrapper.html);
				this.target.appendChild(this.wrapper.youtube);

				if(this.options.gui) {

					var guiOptions = {
						player: this,

						navigation: false,		// next/prev buttons
						fullscreen: false,		// fullscreen button

						cssClass: this.options.cssClass // Pass in the option, so only have to define it in this class
					};

					if(typeof this.options.gui === 'object') {
						hyperaudio.extend(guiOptions, this.options.gui);
					}

					this.GUI = new hyperaudio.PlayerGUI(guiOptions);

					var handler = function(event) {
						var video = self.videoElem;
						self.GUI.setStatus({
							paused: video.paused,
							currentTime: video.currentTime,
							duration: video.duration
						});
					};

					this.addEventListener('progress', handler); // Important for YT player GUI to update on set/change
					this.addEventListener('timeupdate', handler);
					this.addEventListener('play', handler);
					this.addEventListener('pause', handler);
					this.addEventListener('ended', handler);
				}

				if(this.options.media.youtube || this.options.media.mp4) { // Assumes we have the webm
					this.load();
				}
			} else {
				this._error('Target not found : ' + this.options.target);
			}
		},

		mediaDiff: function(media) {
			var self = this,
				diff = false;
			if(media) {
				hyperaudio.each(this.mediaTypes.split(/\s+/g), function() {
					if(self.options.media[this] !== media[this]) {
						diff = true;
						return false; // exit each
					}
				});
			} else {
				diff = true;
			}
			return diff;
		},

		updateSolution: function() {
			var wrapper = this.wrapper,
				cssClass = this.options.solutionClass;

			if(this.youtube) {
				hyperaudio.removeClass(wrapper.html, cssClass);
				hyperaudio.addClass(wrapper.youtube, cssClass);
			} else {
				hyperaudio.removeClass(wrapper.youtube, cssClass);
				hyperaudio.addClass(wrapper.html, cssClass);
			}
		},

		show: function() {
			this.updateSolution();
		},
		hide: function() {
			var wrapper = this.wrapper,
				cssClass = this.options.solutionClass;

			hyperaudio.removeClass(wrapper.html, cssClass);
			hyperaudio.removeClass(wrapper.youtube, cssClass);
		},

		load: function(media) {
			var self = this,
				newMedia = this.mediaDiff(media);

			if(media) {
				this.options.media = media;
			}

			if(this.target) {

				if(newMedia) {

					this.pause(); // Pause the player, otherwise switching solution may leave 1 playing while hidden.

					this.killPopcorn();

					// console.log('media: %o', this.options.media);

					if(this.options.media.youtube) {
						// The YT element needs to be recreated while bugs in wrapper.
						this.empty(this.wrapper.youtube);
						this.solution.youtube = Popcorn.HTMLYouTubeVideoElement(this.wrapper.youtube);
						this.solution.youtube.src = this.options.media.youtube + '&html5=1';
						this.videoElem = this.solution.youtube;
						this.youtube = true;
						this.updateSolution();

						// Until the YouTube wrapper is fixed, we need to recreate it and the listeners when the YT media changes.
						this._ytFixListeners();
					} else {

						this.empty(this.solution.html);

						// Setup to work with mp4 and webm property names. See options.
						hyperaudio.each(this.options.media, function(format, url) {
							// Only create known formats, so we can add other info to the media object.
							if(self.options.mediaType[format]) {
								var source = document.createElement('source');
								source.setAttribute('type', self.options.mediaType[format]);
								source.setAttribute('src', url); // Could use 'this' but less easy to read.
								self.solution.html.appendChild(source);
							}
						});

						this.solution.html.load();
						this.videoElem = this.solution.html;
						this.youtube = false;
						this.updateSolution();
					}

					this.initPopcorn();
				}
			} else {
				this._error('Video player not created : ' + this.options.target);
			}
		},
		initPopcorn: function() {
			this.killPopcorn();
			this.popcorn = Popcorn(this.videoElem);
		},
		killPopcorn: function() {
			if(this.popcorn) {
				this.popcorn.destroy();
				delete this.popcorn;
			}
		},
		empty: function(el) {
			// Empties the element... Possibly better than el.innerHTML = '';
			while(el && el.firstChild) {
				el.removeChild(el.firstChild);
			}
		},
		play: function(time) {
			if(this.youtube) {
				this.popcorn.play(time);
			} else {
				this.currentTime(time, true);
			}
		},
		pause: function(time) {
			if(this.youtube) {
				this.popcorn.pause(time);
			} else {
				this.videoElem.pause();
				this.currentTime(time);
			}
		},
		currentTime: function(time, play) {
			var self = this,
				media = this.videoElem;

			clearTimeout(this.timeout.currentTime);

			if(this.youtube) {
				this.popcorn.currentTime(time);
				return;
			}

			if(typeof time === 'number' && !isNaN(time)) {

				// Attempt to play it, since iOS has been ignoring commands
				if(play && this.commandsIgnored) {
					media.play();
				}

				try {
					// !media.seekable is for old HTML5 browsers, like Firefox 3.6.
					// Checking seekable.length is important for iOS6 to work with currentTime changes immediately after changing media
					if(!media.seekable || typeof media.seekable === "object" && media.seekable.length > 0) {
						media.currentTime = time;
						if(play) {
							media.play();
						}
					} else {
						throw 1;
					}
				} catch(err) {
					this.timeout.currentTime = setTimeout(function() {
						self.currentTime(time, play);
					}, 250);
				}
			} else {
				if(play) {
					media.play();
				}
			}
		},
		addEventListener: function(type, handler) {
			var self = this,
				handlers;

			if(this.solution && typeof type === 'string' && typeof handler === 'function') {
				handlers = {
					html: function(event) {
						if(!self.youtube) {
							handler.call(this, event);
						}
					},
					youtube: function(event) {
						if(self.youtube) {
							// Bugged YT wrapper context.
							// Reported https://bugzilla.mozilla.org/show_bug.cgi?id=946293
							// handler.call(this, event); // Bugged
							// this and event.target point at the document
							// event.detail.target points at the youtube target element
							handler.call(self.solution.youtube, event);
						}
					}
				};
				this.solution.html.addEventListener(type, handlers.html, false);
				this.solution.youtube.addEventListener(type, handlers.youtube, false);

				// Until the YouTube wrapper is fixed, we need to recreate it and the listeners when the YT media changes.
				this.ytFix.push({
					type: type,
					handler: handlers.youtube
				});
			}

			return handlers;
		},
		removeEventListener: function(type, handlers) {
			if(this.solution && typeof type === 'string' && typeof handlers === 'object') {
				this.solution.html.removeEventListener(type, handlers.html, false);
				this.solution.youtube.removeEventListener(type, handlers.youtube, false);

				// Until the YouTube wrapper is fixed, we need to recreate it and the listeners when the YT media changes.
				for(var i=0, l=this.ytFix.length; i<l; i++) {
					if(this.ytFix[i].type === type && this.ytFix[i].handler === handlers.youtube) {
						this.ytFix.splice(i, 1);
					}
				}
			}
		},
		_ytFixListeners: function() {
			// Until the YouTube wrapper is fixed, we need to recreate it and the listeners when the YT media changes.
			for(var i=0, l=this.ytFix.length; i<l; i++) {
				this.solution.youtube.addEventListener(this.ytFix[i].type, this.ytFix[i].handler, false);
			}
		}
	};

	return Player;
}(window, document, hyperaudio, Popcorn));
<commit_msg>Fixed flag for mobile devices ignoring commands<commit_after>/* Player
 *
 */

var Player = (function(window, document, hyperaudio, Popcorn) {

	function Player(options) {

		this.options = hyperaudio.extend({}, this.options, {

			entity: 'PLAYER', // Not really an option... More like a manifest

			target: '#transcript-video', // The selector of element where the video is generated

			media: {
				youtube: '', // The URL of the Youtube video.
				mp4: '', // The URL of the mp4 video.
				webm:'' // The URL of the webm video.
			},

			// Types valid in a video element
			mediaType: {
				mp4: 'video/mp4', // The mp4 mime type.
				webm:'video/webm' // The webm mime type.
			},

			guiNative: false, // TMP during dev. Either we have a gui or we are chomeless.

			gui: false, // True to add a gui, or Object to pass GUI options.
			cssClass: 'hyperaudio-player', // Class added to the target for the GUI CSS. (passed to GUI and Projector)
			solutionClass: 'solution', // Class added to the solution that is active.
			async: true // When true, some operations are delayed by a timeout.
		}, options);

		// Properties
		this.target = typeof this.options.target === 'string' ? document.querySelector(this.options.target) : this.options.target;
		this.videoElem = null;
		this.timeout = {};
		this.commandsIgnored = /ipad|iphone|ipod|android/i.test(window.navigator.userAgent);

		// List of the media types, used to check for changes in media.
		this.mediaTypes = "youtube mp4 webm";

		this.youtube = false; // A flag to indicate if the YT player being used.

		// Until the YouTube wrapper is fixed, we need to recreate it and the listeners when the YT media changes.
		this.ytFix = [];

		if(this.options.DEBUG) {
			this._debug();
		}

		if(this.target) {
			this.create();
		}
	}

	Player.prototype = {
		create: function() {
			var self = this;

			if(this.target) {

				this.wrapper = {
					html: document.createElement('div'),
					youtube: document.createElement('div')
				};
				hyperaudio.addClass(this.wrapper.html, this.options.cssClass + '-video-wrapper');
				hyperaudio.addClass(this.wrapper.youtube, this.options.cssClass + '-youtube-wrapper');

				this.solution = {
					html: document.createElement('video'),
					youtube: Popcorn.HTMLYouTubeVideoElement(this.wrapper.youtube)
				};

				// Default to a video element to start with
				this.videoElem = this.solution.html;
				this.youtube = false;
				this.updateSolution();

				this.solution.html.controls = this.options.guiNative; // TMP during dev. Either we have a gui or we are chomeless.

				// Add listeners to the video element
				this.solution.html.addEventListener('progress', function(e) {
					if(this.readyState > 0) {
						self.commandsIgnored = false;
					}
				}, false);

				// Clear the target element and add the video
				this.empty(this.target);
				this.wrapper.html.appendChild(this.solution.html);
				// this.wrapper.youtube.appendChild(this.solution.youtube);
				this.target.appendChild(this.wrapper.html);
				this.target.appendChild(this.wrapper.youtube);

				if(this.options.gui) {

					var guiOptions = {
						player: this,

						navigation: false,		// next/prev buttons
						fullscreen: false,		// fullscreen button

						cssClass: this.options.cssClass // Pass in the option, so only have to define it in this class
					};

					if(typeof this.options.gui === 'object') {
						hyperaudio.extend(guiOptions, this.options.gui);
					}

					this.GUI = new hyperaudio.PlayerGUI(guiOptions);

					var handler = function(event) {
						var video = self.videoElem;
						self.GUI.setStatus({
							paused: video.paused,
							currentTime: video.currentTime,
							duration: video.duration
						});
					};

					this.addEventListener('progress', handler); // Important for YT player GUI to update on set/change
					this.addEventListener('timeupdate', handler);
					this.addEventListener('play', handler);
					this.addEventListener('pause', handler);
					this.addEventListener('ended', handler);
				}

				if(this.options.media.youtube || this.options.media.mp4) { // Assumes we have the webm
					this.load();
				}
			} else {
				this._error('Target not found : ' + this.options.target);
			}
		},

		mediaDiff: function(media) {
			var self = this,
				diff = false;
			if(media) {
				hyperaudio.each(this.mediaTypes.split(/\s+/g), function() {
					if(self.options.media[this] !== media[this]) {
						diff = true;
						return false; // exit each
					}
				});
			} else {
				diff = true;
			}
			return diff;
		},

		updateSolution: function() {
			var wrapper = this.wrapper,
				cssClass = this.options.solutionClass;

			if(this.youtube) {
				hyperaudio.removeClass(wrapper.html, cssClass);
				hyperaudio.addClass(wrapper.youtube, cssClass);
			} else {
				hyperaudio.removeClass(wrapper.youtube, cssClass);
				hyperaudio.addClass(wrapper.html, cssClass);
			}
		},

		show: function() {
			this.updateSolution();
		},
		hide: function() {
			var wrapper = this.wrapper,
				cssClass = this.options.solutionClass;

			hyperaudio.removeClass(wrapper.html, cssClass);
			hyperaudio.removeClass(wrapper.youtube, cssClass);
		},

		load: function(media) {
			var self = this,
				newMedia = this.mediaDiff(media);

			if(media) {
				this.options.media = media;
			}

			if(this.target) {

				if(newMedia) {

					this.pause(); // Pause the player, otherwise switching solution may leave 1 playing while hidden.

					this.killPopcorn();

					// console.log('media: %o', this.options.media);

					if(this.options.media.youtube) {
						// The YT element needs to be recreated while bugs in wrapper.
						this.empty(this.wrapper.youtube);
						this.solution.youtube = Popcorn.HTMLYouTubeVideoElement(this.wrapper.youtube);
						this.solution.youtube.src = this.options.media.youtube + '&html5=1';
						this.videoElem = this.solution.youtube;
						this.youtube = true;
						this.updateSolution();

						// Until the YouTube wrapper is fixed, we need to recreate it and the listeners when the YT media changes.
						this._ytFixListeners();
					} else {

						this.empty(this.solution.html);

						// Setup to work with mp4 and webm property names. See options.
						hyperaudio.each(this.options.media, function(format, url) {
							// Only create known formats, so we can add other info to the media object.
							if(self.options.mediaType[format]) {
								var source = document.createElement('source');
								source.setAttribute('type', self.options.mediaType[format]);
								source.setAttribute('src', url); // Could use 'this' but less easy to read.
								self.solution.html.appendChild(source);
							}
						});

						this.solution.html.load();
						this.videoElem = this.solution.html;
						this.youtube = false;
						this.updateSolution();
					}

					this.initPopcorn();
				}
			} else {
				this._error('Video player not created : ' + this.options.target);
			}
		},
		initPopcorn: function() {
			this.killPopcorn();
			this.popcorn = Popcorn(this.videoElem);
		},
		killPopcorn: function() {
			if(this.popcorn) {
				this.popcorn.destroy();
				delete this.popcorn;
			}
		},
		empty: function(el) {
			// Empties the element... Possibly better than el.innerHTML = '';
			while(el && el.firstChild) {
				el.removeChild(el.firstChild);
			}
		},
		play: function(time) {
			if(this.youtube) {
				this.popcorn.play(time);
			} else {
				this.currentTime(time, true);
			}
		},
		pause: function(time) {
			if(this.youtube) {
				this.popcorn.pause(time);
			} else {
				this.videoElem.pause();
				this.currentTime(time);
			}
		},
		currentTime: function(time, play) {
			var self = this,
				media = this.videoElem;

			clearTimeout(this.timeout.currentTime);

			if(this.youtube) {
				this.popcorn.currentTime(time);
				return;
			}

			if(typeof time === 'number' && !isNaN(time)) {

				// Attempt to play it, since iOS has been ignoring commands
				if(play && this.commandsIgnored) {
					media.play();
				}

				try {
					// !media.seekable is for old HTML5 browsers, like Firefox 3.6.
					// Checking seekable.length is important for iOS6 to work with currentTime changes immediately after changing media
					if(!media.seekable || typeof media.seekable === "object" && media.seekable.length > 0) {
						media.currentTime = time;
						if(play) {
							media.play();
						}
					} else {
						throw 1;
					}
				} catch(err) {
					this.timeout.currentTime = setTimeout(function() {
						self.currentTime(time, play);
					}, 250);
				}
			} else {
				if(play) {
					media.play();
				}
			}
		},
		addEventListener: function(type, handler) {
			var self = this,
				handlers;

			if(this.solution && typeof type === 'string' && typeof handler === 'function') {
				handlers = {
					html: function(event) {
						if(!self.youtube) {
							handler.call(this, event);
						}
					},
					youtube: function(event) {
						if(self.youtube) {
							// Bugged YT wrapper context.
							// Reported https://bugzilla.mozilla.org/show_bug.cgi?id=946293
							// handler.call(this, event); // Bugged
							// this and event.target point at the document
							// event.detail.target points at the youtube target element
							handler.call(self.solution.youtube, event);
						}
					}
				};
				this.solution.html.addEventListener(type, handlers.html, false);
				this.solution.youtube.addEventListener(type, handlers.youtube, false);

				// Until the YouTube wrapper is fixed, we need to recreate it and the listeners when the YT media changes.
				this.ytFix.push({
					type: type,
					handler: handlers.youtube
				});
			}

			return handlers;
		},
		removeEventListener: function(type, handlers) {
			if(this.solution && typeof type === 'string' && typeof handlers === 'object') {
				this.solution.html.removeEventListener(type, handlers.html, false);
				this.solution.youtube.removeEventListener(type, handlers.youtube, false);

				// Until the YouTube wrapper is fixed, we need to recreate it and the listeners when the YT media changes.
				for(var i=0, l=this.ytFix.length; i<l; i++) {
					if(this.ytFix[i].type === type && this.ytFix[i].handler === handlers.youtube) {
						this.ytFix.splice(i, 1);
					}
				}
			}
		},
		_ytFixListeners: function() {
			// Until the YouTube wrapper is fixed, we need to recreate it and the listeners when the YT media changes.
			for(var i=0, l=this.ytFix.length; i<l; i++) {
				this.solution.youtube.addEventListener(this.ytFix[i].type, this.ytFix[i].handler, false);
			}
		}
	};

	return Player;
}(window, document, hyperaudio, Popcorn));
<|endoftext|>


<commit_before>/*
 * Copyright (C) 2013 salesforce.com, inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
({

    /**
     * Most cases are covered by xUnit, AuraLocalizationServiceTest.js
     * These tests are working as integration tests, since we have polyfill time zone data
     * of Intl API for IE11.
     */

    /*
     * Verify UTCToWallTime conversion for the time during the Daylight Saving Time change.
     * This is an edge case but important. Since date object includes browser's timezone offset,
     * the test is verify DST is applied for given timezone vs for browser's timezone.
     *
     * In the case, for zone "America/New_York", 2:00:00 am clocks were turned backward 1 hour to
     * 1:00:00 am on Nov 3, 2013.
     */
    testUTCToWallTimeWithTimeDuringDSTChange: {
        test: function() {
            var dateInDST = $A.localizationService.parseDateTimeISO8601("2013-11-03T05:01:00.000Z");
            var dateOutOfDST = $A.localizationService.parseDateTimeISO8601("2013-11-03T06:01:00.000Z");
            var format = "MMM d, yyyy h:mm:ss a";
            var expected = "Nov 3, 2013 1:01:00 AM";

            $A.localizationService.UTCToWallTime(dateInDST, "America/New_York", function(walltime) {
                var actual = $A.localizationService.formatDateTimeUTC(walltime, format);
                $A.test.assertEquals(expected, actual,
                        "Incorrect time from UTCToWallTime when given time is right before DST ends");
            });

            $A.localizationService.UTCToWallTime(dateOutOfDST, "America/New_York", function(walltime) {
                var actual = $A.localizationService.formatDateTimeUTC(walltime, format);
                $A.test.assertEquals(expected, actual,
                        "Incorrect time from UTCToWallTime when given time is right after DST ends");
            });
        }
    },

    /*
     * Verify WallTimeToUTC conversion for the time during the Daylight Saving Time change.
     * This is an edge case but important. Since date object includes browser's timezone offset,
     * the test is verify DST is applied for given timezone vs for browser's timezone.
     *
     * In the case, for zone "Europe/Berlin", 3:00:00 am clocks were turned backward 1 hour to
     * 2:00:00 am am on Oct 27, 2013.
     */
    testWallTimeToUTCWithTimeDuringDSTChange: {
        test: function() {
            var format = "MMM d, yyyy h:mm:ss a";
            var date = $A.localizationService.parseDateTime("Oct 27, 2013 02:30:00 AM", format);
            var expected = "Oct 27, 2013 1:30:00 AM";

            $A.localizationService.WallTimeToUTC(date, "Europe/Berlin", function(utc) {
                var actual = $A.localizationService.formatDateTime(utc, format);
                $A.test.assertEquals(expected, actual,
                        "Incorrect time from WallTimeToUTC when given time is during DST ends");
            });
        }
    }

})
<commit_msg>Automation test to exercise all supported time zones (#2637)<commit_after>/*
 * Copyright (C) 2013 salesforce.com, inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
({

    /**
     * Most cases are covered by xUnit, AuraLocalizationServiceTest.js
     * These tests are working as integration tests, since we have polyfill time zone data
     * of Intl API for IE11.
     */

    /*
     * Verify UTCToWallTime conversion for the time during the Daylight Saving Time change.
     * This is an edge case but important. Since date object includes browser's timezone offset,
     * the test is verify DST is applied for given timezone vs for browser's timezone.
     *
     * In the case, for zone "America/New_York", 2:00:00 am clocks were turned backward 1 hour to
     * 1:00:00 am on Nov 3, 2013.
     */
    testUTCToWallTimeWithTimeDuringDSTChange: {
        test: function() {
            var dateInDST = $A.localizationService.parseDateTimeISO8601("2013-11-03T05:01:00.000Z");
            var dateOutOfDST = $A.localizationService.parseDateTimeISO8601("2013-11-03T06:01:00.000Z");
            var format = "MMM d, yyyy h:mm:ss a";
            var expected = "Nov 3, 2013 1:01:00 AM";

            $A.localizationService.UTCToWallTime(dateInDST, "America/New_York", function(walltime) {
                var actual = $A.localizationService.formatDateTimeUTC(walltime, format);
                $A.test.assertEquals(expected, actual,
                        "Incorrect time from UTCToWallTime when given time is right before DST ends");
            });

            $A.localizationService.UTCToWallTime(dateOutOfDST, "America/New_York", function(walltime) {
                var actual = $A.localizationService.formatDateTimeUTC(walltime, format);
                $A.test.assertEquals(expected, actual,
                        "Incorrect time from UTCToWallTime when given time is right after DST ends");
            });
        }
    },

    /*
     * Verify WallTimeToUTC conversion for the time during the Daylight Saving Time change.
     * This is an edge case but important. Since date object includes browser's timezone offset,
     * the test is verify DST is applied for given timezone vs for browser's timezone.
     *
     * In the case, for zone "Europe/Berlin", 3:00:00 am clocks were turned backward 1 hour to
     * 2:00:00 am am on Oct 27, 2013.
     */
    testWallTimeToUTCWithTimeDuringDSTChange: {
        test: function() {
            var format = "MMM d, yyyy h:mm:ss a";
            var date = $A.localizationService.parseDateTime("Oct 27, 2013 02:30:00 AM", format);
            var expected = "Oct 27, 2013 1:30:00 AM";

            $A.localizationService.WallTimeToUTC(date, "Europe/Berlin", function(utc) {
                var actual = $A.localizationService.formatDateTime(utc, format);
                $A.test.assertEquals(expected, actual,
                        "Incorrect time from WallTimeToUTC when given time is during DST ends");
            });
        }
    },

    testSupportedTimeZone: {
        // Intl API throws error if it doesn't support the time zone. In localization service, we catch the error and warn.
        failOnWarning: true,
        test: function() {
            // https://help.salesforce.com/articleView?id=admin_supported_timezone.htm&type=5
            var timeZones = [
                "Africa/Algiers", "Africa/Cairo", "Africa/Casablanca", "Africa/Johannesburg", "Africa/Nairobi",
                "America/Adak", "America/Anchorage", "America/Argentina/Buenos_Aires", "America/Bogota", "America/Caracas",
                "America/Chicago", "America/Denver", "America/El_Salvador", "America/Halifax", "America/Indiana/Indianapolis",
                "America/Lima", "America/Los_Angeles", "America/Mazatlan", "America/Mexico_City", "America/New_York",
                "America/Panama", "America/Phoenix", "America/Puerto_Rico", "America/Santiago", "America/Sao_Paulo",
                "America/Scoresbysund", "America/St_Johns", "America/Tijuana", "Asia/Baghdad", "Asia/Baku", "Asia/Bangkok",
                "Asia/Beirut", "Asia/Colombo", "Asia/Dhaka", "Asia/Dubai", "Asia/Ho_Chi_Minh", "Asia/Hong_Kong", "Asia/Jakarta",
                "Asia/Jerusalem", "Asia/Kabul", "Asia/Kamchatka", "Asia/Karachi", "Asia/Kathmandu", "Asia/Kolkata",
                "Asia/Kuala_Lumpur", "Asia/Kuwait", "Asia/Manila", "Asia/Rangoon", "Asia/Riyadh", "Asia/Seoul", "Asia/Shanghai",
                "Asia/Singapore", "Asia/Taipei", "Asia/Tashkent", "Asia/Tbilisi", "Asia/Tehran", "Asia/Tokyo", "Asia/Yekaterinburg",
                "Asia/Yerevan", "Atlantic/Azores", "Atlantic/Bermuda", "Atlantic/Cape_Verde", "Atlantic/South_Georgia",
                "Australia/Adelaide", "Australia/Brisbane", "Australia/Darwin", "Australia/Lord_Howe", "Australia/Perth",
                "Australia/Sydney", "Europe/Amsterdam", "Europe/Athens", "Europe/Berlin", "Europe/Brussels", "Europe/Bucharest",
                "Europe/Dublin", "Europe/Helsinki", "Europe/Istanbul", "Europe/Lisbon", "Europe/London", "Europe/Minsk", "Europe/Moscow",
                "Europe/Paris", "Europe/Prague", "Europe/Rome", "GMT", "Pacific/Auckland", "Pacific/Chatham", "Pacific/Enderbury",
                "Pacific/Fiji", "Pacific/Gambier", "Pacific/Guadalcanal", "Pacific/Honolulu", "Pacific/Kiritimati", "Pacific/Marquesas",
                "Pacific/Niue", "Pacific/Norfolk", "Pacific/Pago_Pago", "Pacific/Pitcairn", "Pacific/Tongatapu"
            ];

            timeZones.forEach(function(timeZone) {
                // WallTimeToUTC is currently sync method
                $A.localizationService.WallTimeToUTC(new Date(), timeZone, function(utc) {
                    $A.test.assertFalse(isNaN(utc.getTime()), "Failed to convert datetime for time zone: " + timeZone);
                });
            });
        }
    }

})
<|endoftext|>


<commit_before>/*
  @author Gilles Gerlinger
  Copyright Nokia 2017. All rights reserved.
*/

class B {
  back = false;
  set(component) {
    this.component = component;
    this.history = component.props.history;
    this.pathname = component.props.location.pathname;
  }
}

const b = new B();

export default b;<commit_msg>minor update<commit_after>/*
  @author Gilles Gerlinger
  Copyright Nokia 2017. All rights reserved.
*/

class B {
  back = false;
  set(component) {
    this.component = component;
    this.history = component.props.history;
    this.pathname = component.props.location.pathname;
  }
}

export default new B();<|endoftext|>


<commit_before>/*global describe, beforeEach, it*/
'use strict';

var path = require('path');
var assert = require('yeoman-assert');
var helpers = require('yeoman-test');
var fse = require('fs-extra');

const expectedFiles = {
    dockercompose : [
        'docker-compose.yml',
        'jhipster-registry.yml',
        'central-server-config/application.yml'
    ],
    elk : [
        'elk.yml',
        'log-monitoring/log-config/logstash.conf'
    ]
};

describe('JHipster Docker Compose Sub Generator', function () {

    describe('only gateway', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway'
                    ],
                    clusteredDbApps: [],
                    elk: false
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
    });

    describe('only one microservice', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    elk: false
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
    });

    describe('gateway and one microservice', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    elk: false
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
    });

    describe('gateway and one microservice, with elk', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    elk: true
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', function () {
            assert.file(expectedFiles.elk);
        });
    });

    describe('gateway and multi microservices, with elk', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '02-mysql',
                        '03-psql',
                        '04-mongo'
                    ],
                    clusteredDbApps: [
                        '04-mongo'
                    ],
                    elk: true
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', function () {
            assert.file(expectedFiles.elk);
        });
    });

    describe('gateway and multi microservices, with 1 mongodb cluster', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '02-mysql',
                        '03-psql',
                        '04-mongo'
                    ],
                    clusteredDbApps: [
                        '04-mongo'
                    ],
                    elk: true
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', function () {
            assert.file(expectedFiles.elk);
        });
    });

    describe('gateway and 1 microservice, with cassandra cluster', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '05-cassandra'
                    ],
                    clusteredDbApps: [],
                    elk: true
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', function () {
            assert.file(expectedFiles.elk);
        });
    });
});
<commit_msg>add docker compose test case for uaa<commit_after>/*global describe, beforeEach, it*/
'use strict';

var path = require('path');
var assert = require('yeoman-assert');
var helpers = require('yeoman-test');
var fse = require('fs-extra');

const expectedFiles = {
    dockercompose : [
        'docker-compose.yml',
        'jhipster-registry.yml',
        'central-server-config/application.yml'
    ],
    elk : [
        'elk.yml',
        'log-monitoring/log-config/logstash.conf'
    ]
};

describe('JHipster Docker Compose Sub Generator', function () {

    describe('only gateway', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway'
                    ],
                    clusteredDbApps: [],
                    elk: false
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
    });

    describe('only one microservice', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    elk: false
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
    });

    describe('gateway and one microservice', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    elk: false
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
    });

    describe('gateway and one microservice, with elk', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    elk: true
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', function () {
            assert.file(expectedFiles.elk);
        });
    });

    describe('gateway, uaa server and one microservice, with elk', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '02-mysql',
                        '06-uaa'
                    ],
                    clusteredDbApps: [],
                    elk: true
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', function () {
            assert.file(expectedFiles.elk);
        });
    });

    describe('gateway and multi microservices, with elk', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '02-mysql',
                        '03-psql',
                        '04-mongo'
                    ],
                    clusteredDbApps: [],
                    elk: true
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', function () {
            assert.file(expectedFiles.elk);
        });
    });

    describe('gateway and multi microservices, with 1 mongodb cluster', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '02-mysql',
                        '03-psql',
                        '04-mongo'
                    ],
                    clusteredDbApps: [
                        '04-mongo'
                    ],
                    elk: true
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', function () {
            assert.file(expectedFiles.elk);
        });
    });

    describe('gateway and 1 microservice, with cassandra cluster', function () {
        beforeEach(function (done) {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir(function (dir) {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    directoryPath: './',
                    'chosenApps': [
                        '01-gateway',
                        '05-cassandra'
                    ],
                    clusteredDbApps: [],
                    elk: true
                })
                .on('end', done);
        });
        it('creates expected default files', function () {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', function () {
            assert.file(expectedFiles.elk);
        });
    });
});
<|endoftext|>