<commit_before>"use strict"

/**
 * @type {Chai.Assert}
 */
var assert = require('chai').assert
var xdTesting = require('../../lib/index')
var templates = require('../../lib/templates')
var q = require('q')

describe('MultiDevice - selectById', function () {
    var test = this

    // Config
    beforeEach(() => {
        xdTesting.reset()
        test.baseUrl = "http://localhost:8090/"
    })

    // Reset config
    afterEach(xdTesting.reset)

    it('should act on the specified devices @large', function () {
        var options = {A: templates.devices.chrome(), B: templates.devices.chrome(), C: templates.devices.chrome()}

        return xdTesting.multiremote(options)
            .init()
            .url(test.baseUrl)
            .selectById(['B', 'C'], selectedDevices => selectedDevices
                .getText('#counter').then((textB, textC) => [textB, textC].forEach(text => assert.equal(text, '-')))
                .click('#button')
                .getText('#counter').then((textB, textC) => [textB, textC].forEach(text => assert.equal(text, '1')))
            )
    })

    it('should not act on other devices @large', function () {
        var options = {A: templates.devices.chrome(), B: templates.devices.chrome(), C: templates.devices.chrome()}

        return xdTesting.multiremote(options)
            .init()
            .url(test.baseUrl)
            .selectById(['B', 'C'], selectedDevices => selectedDevices
                .getText('#counter').then((textB, textC) => [textB, textC].forEach(text => assert.equal(text, '-')))
                .click('#button')
                .getText('#counter').then((textB, textC) => [textB, textC].forEach(text => assert.equal(text, '1')))
            )
            .selectById('A', device => device
                .getText('#counter').then(textA => assert.equal(textA, '-'))
            )
    })

    describe('with complementCallback', () => {
        it('should call the complementCallback on the complementary selection', () => {
            var options = {
                A: templates.devices.chrome(),
                B: templates.devices.chrome()
            }

            return xdTesting.multiremote(options)
                .selectById('A',
                    selectedDevices => selectedDevices
                        .getDeviceIds().then(ret => assert.deepEqual(ret.value, ['A'])),
                    otherDevices => otherDevices
                        .getDeviceIds().then(ret => assert.deepEqual(ret.value, ['B']))
                )
        })

        it.skip('IDEA: could return callback result to complementCallback', () => {
            var options = {
                A: templates.devices.chrome(),
                B: templates.devices.chrome()
            }

            return xdTesting.multiremote(options)
                .selectById('A',
                    selectedDevices => selectedDevices
                        .then(() => 'X'),
                    otherDevices => otherDevices<commit_msg>End browser sessions after tests<commit_after>"use strict"

/**
 * @type {Chai.Assert}
 */
var assert = require('chai').assert
var xdTesting = require('../../lib/index')
var templates = require('../../lib/templates')
var q = require('q')

describe('MultiDevice - selectById', function () {
    var test = this

    // Config
    beforeEach(() => {
        xdTesting.reset()
        test.baseUrl = "http://localhost:8090/"
    })

    // Reset config
    afterEach(xdTesting.reset)

    it('should act on the specified devices @large', function () {
        var options = {
            A: templates.devices.chrome(),
            B: templates.devices.chrome(),
            C: templates.devices.chrome()
        }

        return xdTesting.multiremote(options)
            .init()
            .url(test.baseUrl)
            .selectById(['B', 'C'], selectedDevices => selectedDevices
                .getText('#counter').then((textB, textC) => [textB, textC].forEach(text => assert.equal(text, '-')))
                .click('#button')
                .getText('#counter').then((textB, textC) => [textB, textC].forEach(text => assert.equal(text, '1')))
            )
            .end()
    })

    it('should not act on other devices @large', function () {
        var options = {
            A: templates.devices.chrome(),
            B: templates.devices.chrome(),
            C: templates.devices.chrome()
        }

        return xdTesting.multiremote(options)
            .init()
            .url(test.baseUrl)
            .selectById(['B', 'C'], selectedDevices => selectedDevices
                .getText('#counter').then((textB, textC) => [textB, textC].forEach(text => assert.equal(text, '-')))
                .click('#button')
                .getText('#counter').then((textB, textC) => [textB, textC].forEach(text => assert.equal(text, '1')))
            )
            .selectById('A', device => device
                .getText('#counter').then(textA => assert.equal(textA, '-'))
            )
            .end()
    })

    describe('with complementCallback', () => {
        it('should call the complementCallback on the complementary selection', () => {
            var options = {
                A: templates.devices.chrome(),
                B: templates.devices.chrome()
            }

            return xdTesting.multiremote(options)
                .selectById('A',
                    selectedDevices => selectedDevices
                        .getDeviceIds().then(ret => assert.deepEqual(ret.value, ['A'])),
                    otherDevices => otherDevices
                        .getDeviceIds().then(ret => assert.deepEqual(ret.value, ['B']))
                )
        })

        it.skip('IDEA: could return callback result to complementCallback', () => {
            var options = {
                A: templates.devices.chrome(),
                B: templates.devices.chrome()
            }

            return xdTesting.multiremote(options)
                .selectById('A',
                    selectedDevices => selectedDevices
                        .then(() => 'X'),
                    otherDevices => otherDevices
{'fraction_non_alphanumeric': 0.15512465373961218, 'fraction_numerical': 0.001955352778230406, 'mean_word_length': 1.8351039260969977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '338654', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1592, 'n_words': 321}