Skip to content

Commit

Permalink
chore(test): add e2e test for resolver routes
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Sep 13, 2024
1 parent 91aff62 commit 9e1ccb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/routes/arns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ arnsRouter.get('/ar-io/resolver/:name', async (req, res) => {

const { resolvedId, ttl, processId, resolvedAt } = resolved;

// check if they are undefined
if (
resolvedId === undefined ||
ttl === undefined ||
Expand Down
22 changes: 6 additions & 16 deletions test/end-to-end/arns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,8 @@ describe('ArNS', function () {

// verify the /ar-io/resolver/:name endpoint
it('Verifying that /ar-io/resolver/:name returns 200 and resolution data', async function () {
const txId = 'TB2wJyKrPnkAW79DAwlJYwpgdHKpijEJWQfcwX715Co';
const res = await axios.get(
'http://localhost:4000/ar-io/resolver/ardrive',
{
headers: { Host: 'ardrive.ar-io.localhost' },
},
);
const txId = '7czHwMqgYHC3eJrPagyFA03UT4YXIN1um__tpHUXAHE';
const res = await axios.get('http://localhost:4000/ar-io/resolver/ardrive');

assert.strictEqual(res.status, 200);
assert.strictEqual(res.data.txId, txId);
Expand All @@ -129,15 +124,10 @@ describe('ArNS', function () {

// verify the headers are set correctly on the response
it('Verifying that /ar-io/resolver/:name returns 200 and sets the correct headers', async function () {
const txId = 'TB2wJyKrPnkAW79DAwlJYwpgdHKpijEJWQfcwX715Co';
const res = await axios.get(
'http://localhost:4000/ar-io/resolver/ardrive',
{
headers: { Host: 'ardrive.ar-io.localhost' },
},
);
const txId = '7czHwMqgYHC3eJrPagyFA03UT4YXIN1um__tpHUXAHE';
const res = await axios.get('http://localhost:4000/ar-io/resolver/ardrive');

assert.strictEqual(typeof res.headers['x-arns-resolved-id'], txId);
assert.strictEqual(res.headers['x-arns-resolved-id'], txId);
assert.strictEqual(typeof res.headers['x-arns-ttl-seconds'], 'string');
assert.strictEqual(typeof res.headers['x-arns-process-id'], 'string');
});
Expand All @@ -146,7 +136,7 @@ describe('ArNS', function () {
const res = await axios.get(
'http://localhost:4000/ar-io/resolver/nonexistent',
{
headers: { Host: 'ardrive.ar-io.localhost' },
validateStatus: (status) => status === 404, // only accept 404 status
},
);

Expand Down

0 comments on commit 9e1ccb1

Please sign in to comment.