Skip to content

Commit

Permalink
fix (libpostal): use ctx instead of this
Browse files Browse the repository at this point in the history
  • Loading branch information
AlasDiablo committed Apr 9, 2024
1 parent bf78967 commit d6bc677
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/libpostal/src/expand-address.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ const expand = (input) => ({
* @private
* @param data {unknown}
* @param feed {Feed}
* @param ctx {import('../../core/src/engine').EngineScope}
*/
const expandAddress = (data, feed) => {
if (this.isLast()) {
const expandAddress = (data, feed, ctx) => {
if (ctx.isLast()) {
return feed.close();
}
if (Array.isArray(data)) {
Expand Down
12 changes: 10 additions & 2 deletions packages/libpostal/test/expand.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,24 @@ describe('expandAddress, expandAddressWith', () => {
['Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238']
];

it.skip('should expandAddress with simple array of string', async () => {
it('should expandAddress with simple array of string', async () => {
const result = await runEzs(ezs, simpleData, 'expandAddress');

expect(result[0]).not.toBeNull();
expect(result[0].value).not.toBeNull();
expect(result[0].value).toHaveLength(2);
expect(result[0].value[0]).toEqual('barboncino 781 franklin avenue crown heights brooklyn ny 11238');
expect(result[0].value[1]).toEqual('barboncino 781 franklin avenue crown heights brooklyn new york 11238');
});

it.skip('should expandAddress with simple array of array of string', async () => {
it('should expandAddress with simple array of array of string', async () => {
const result = await runEzs(ezs, simpleData2, 'expandAddress');

expect(result[0]).not.toBeNull();
expect(result[0].value).not.toBeNull();
expect(result[0].value).toHaveLength(2);
expect(result[0].value[0]).toEqual('barboncino 781 franklin avenue crown heights brooklyn ny 11238');
expect(result[0].value[1]).toEqual('barboncino 781 franklin avenue crown heights brooklyn new york 11238');
});
});

Expand Down

0 comments on commit d6bc677

Please sign in to comment.