tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

descriptor-get-same-object.js (1425B)


      1 'use strict';
      2 const test_desc = 'Calls to FUNCTION_NAME should return the same object.';
      3 let characteristic;
      4 
      5 bluetooth_bidi_test(
      6    () => getMeasurementIntervalCharacteristic()
      7              .then(_ => ({characteristic} = _))
      8              .then(() => Promise.all([
      9                characteristic.CALLS(
     10                    [getDescriptor(user_description.alias) |
     11                     getDescriptors(user_description.alias)]),
     12                characteristic.FUNCTION_NAME(user_description.name),
     13                characteristic.FUNCTION_NAME(user_description.uuid)
     14              ]))
     15              .then(descriptors_arrays => {
     16                assert_true(descriptors_arrays.length > 0)
     17 
     18                // Convert to arrays if necessary.
     19                for (let i = 0; i < descriptors_arrays.length; i++) {
     20                  descriptors_arrays[i] = [].concat(descriptors_arrays[i]);
     21                }
     22 
     23                for (let i = 1; i < descriptors_arrays.length; i++) {
     24                  assert_equals(
     25                      descriptors_arrays[0].length,
     26                      descriptors_arrays[i].length);
     27                }
     28 
     29                let base_set = new Set(descriptors_arrays[0]);
     30                for (let descriptors of descriptors_arrays) {
     31                  descriptors.forEach(
     32                      descriptor => assert_true(base_set.has(descriptor)));
     33                }
     34              }),
     35    test_desc);