Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #13 from textury/fix-tags
Browse files Browse the repository at this point in the history
fix: fix length of undefined error
  • Loading branch information
cedriking authored Feb 16, 2022
2 parents 46649b8 + de2b23a commit 818b90c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 50 additions & 0 deletions src/__tests__/ardb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,31 @@ describe('USING ARWEAVE', () => {

expect(txs[0].id).not.toBe('5AYV-RdPCoyfjeeabHVnDGvXrFNM5azcTlkNpp7RQhE');
});

test('tags', async () => {
let txs = await ardb
.search('transactions')
.appName('SmartWeaveAction')
.tag('Type', 'ArweaveActivity')
.only('id')
.sort('HEIGHT_ASC')
.find();

let tagsTx = await ardb
.search('transactions')
.tag('Type', 'ArweaveActivity')
.tags([
{
name: 'App-Name',
values: 'SmartWeaveAction'
}
])
.only('id')
.sort('HEIGHT_ASC')
.find();

expect(txs.length).toEqual(tagsTx.length)
})
});

describe('USING BLOCKWEAVE', () => {
Expand Down Expand Up @@ -275,4 +300,29 @@ describe('USING BLOCKWEAVE', () => {

expect(txs[0].id).not.toBe('5AYV-RdPCoyfjeeabHVnDGvXrFNM5azcTlkNpp7RQhE');
});

test('tags', async () => {
let txs = await ardb
.search('transactions')
.appName('SmartWeaveAction')
.tag('Type', 'ArweaveActivity')
.only('id')
.sort('HEIGHT_ASC')
.find();

let tagsTx = await ardb
.search('transactions')
.tag('Type', 'ArweaveActivity')
.tags([
{
name: 'App-Name',
values: 'SmartWeaveAction'
}
])
.only('id')
.sort('HEIGHT_ASC')
.find();

expect(txs.length).toEqual(tagsTx.length)
})
});
2 changes: 1 addition & 1 deletion src/ardb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class ArDB {
});
}

const $oTags = this.options.tags.length ? this.options.tags : [];
const $oTags = this.options.tags && this.options.tags.length ? this.options.tags : [];
this.options.tags = [...ts, ...$oTags];
return this;
}
Expand Down

0 comments on commit 818b90c

Please sign in to comment.