Skip to content

Commit

Permalink
Introduce iteration support to the Maps in the module
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebeach committed Oct 22, 2022
1 parent 93c9df1 commit 763f0c9
Show file tree
Hide file tree
Showing 45 changed files with 24,904 additions and 1,777 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Expand Up @@ -28,7 +28,8 @@
"plugin:jest/recommended"
],
"env": {
"mocha": true
"mocha": true,
"node": true
}
}
]
Expand Down
730 changes: 729 additions & 1 deletion __tests__/src/AXObjectElementMap-test.js

Large diffs are not rendered by default.

780 changes: 779 additions & 1 deletion __tests__/src/AXObjectRoleMap-test.js

Large diffs are not rendered by default.

2,979 changes: 1,442 additions & 1,537 deletions __tests__/src/AXObjectsMap-test.js

Large diffs are not rendered by default.

816 changes: 815 additions & 1 deletion __tests__/src/elementAXObjectMap-test.js

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions __tests__/src/util/iterationDecorator-test.js
@@ -0,0 +1,61 @@
/* eslint-env mocha */
import expect from 'expect';
import iterationDecorator from '../../../src/util/iterationDecorator';

describe('iterationDecorator', function () {
describe('should add a Symbol.iterator property to a collection', function () {
it('should return the values when iterated', function () {
// const collection = {a: 'apple', b: 'banana', c: 'cantaloupe'};
const collection = {
'a': 'apple',
'b': 'banana',
'c': 'cantaloupe',
};
const arr = ['apple', 'banana', 'cantaloupe'];
const iter = iterationDecorator(collection, Object.values(collection));
expect([...iter]).toEqual(expect.arrayContaining(arr));
});
});
describe('when Symbol is not defined in the global space', function () {
beforeEach(function () {
global.originalSymbol = global.Symbol
global.originalSymbolIterator = global.Symbol.iterator;
global.Symbol = undefined;
});
it('should not add a Symbol.iterator property to a collection', function () {
const collection = {
'a': 'apple',
'b': 'banana',
'c': 'cantaloupe',
};
const iter = iterationDecorator(collection, []);
expect(iter[global.originalSymbolIterator]).not.toBeDefined();
});
afterEach(function () {
global.Symbol = global.originalSymbol;
global.originalSymbol = undefined;
global.originalSymbolIterator = undefined;
});
});
describe('when Symbol.iterator is not defined in the global space', function () {
beforeEach(function () {
global.originalSymbol = global.Symbol
global.originalSymbolIterator = global.Symbol.iterator;
global.Symbol = function () {};
});
it('should not add a Symbol.iterator property to a collection', function () {
const collection = {
'a': 'apple',
'b': 'banana',
'c': 'cantaloupe',
};
const iter = iterationDecorator(collection, []);
expect(iter[global.originalSymbolIterator]).not.toBeDefined();
});
afterEach(function () {
global.Symbol = global.originalSymbol;
global.originalSymbol = undefined;
global.originalSymbolIterator = undefined;
});
});
});
13 changes: 13 additions & 0 deletions __tests__/src/util/iteratorProxy-test.js
@@ -0,0 +1,13 @@
/* eslint-env mocha */
import expect from 'expect';
import iteratorProxy from '../../../src/util/iteratorProxy';

describe('iteratorProxy', function () {
it('should create an iterator for the bound array', function () {
const arr = ['a', 'b', 'c'];
const iter = {
[Symbol.iterator]: iteratorProxy.bind(arr)
};
expect([...iter]).toEqual(expect.arrayContaining(arr));
});
});
97 changes: 97 additions & 0 deletions flow-typed/npm/@babel/cli_vx.x.x.js
@@ -0,0 +1,97 @@
// flow-typed signature: faee240f2d5ef277c6da759bb5a2e5ec
// flow-typed version: <<STUB>>/@babel/cli_v^7.18.10/flow_v0.185.2

/**
* This is an autogenerated libdef stub for:
*
* '@babel/cli'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module '@babel/cli' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module '@babel/cli/bin/babel-external-helpers' {
declare module.exports: any;
}

declare module '@babel/cli/bin/babel' {
declare module.exports: any;
}

declare module '@babel/cli/lib/babel-external-helpers' {
declare module.exports: any;
}

declare module '@babel/cli/lib/babel/dir' {
declare module.exports: any;
}

declare module '@babel/cli/lib/babel/file' {
declare module.exports: any;
}

declare module '@babel/cli/lib/babel' {
declare module.exports: any;
}

declare module '@babel/cli/lib/babel/options' {
declare module.exports: any;
}

declare module '@babel/cli/lib/babel/util' {
declare module.exports: any;
}

declare module '@babel/cli/lib/babel/watcher' {
declare module.exports: any;
}

// Filename aliases
declare module '@babel/cli/bin/babel-external-helpers.js' {
declare module.exports: $Exports<'@babel/cli/bin/babel-external-helpers'>;
}
declare module '@babel/cli/bin/babel.js' {
declare module.exports: $Exports<'@babel/cli/bin/babel'>;
}
declare module '@babel/cli/index' {
declare module.exports: $Exports<'@babel/cli'>;
}
declare module '@babel/cli/index.js' {
declare module.exports: $Exports<'@babel/cli'>;
}
declare module '@babel/cli/lib/babel-external-helpers.js' {
declare module.exports: $Exports<'@babel/cli/lib/babel-external-helpers'>;
}
declare module '@babel/cli/lib/babel/dir.js' {
declare module.exports: $Exports<'@babel/cli/lib/babel/dir'>;
}
declare module '@babel/cli/lib/babel/file.js' {
declare module.exports: $Exports<'@babel/cli/lib/babel/file'>;
}
declare module '@babel/cli/lib/babel/index' {
declare module.exports: $Exports<'@babel/cli/lib/babel'>;
}
declare module '@babel/cli/lib/babel/index.js' {
declare module.exports: $Exports<'@babel/cli/lib/babel'>;
}
declare module '@babel/cli/lib/babel/options.js' {
declare module.exports: $Exports<'@babel/cli/lib/babel/options'>;
}
declare module '@babel/cli/lib/babel/util.js' {
declare module.exports: $Exports<'@babel/cli/lib/babel/util'>;
}
declare module '@babel/cli/lib/babel/watcher.js' {
declare module.exports: $Exports<'@babel/cli/lib/babel/watcher'>;
}

0 comments on commit 763f0c9

Please sign in to comment.