Skip to content

Commit

Permalink
SK-704 added encodeURI option test cases in get
Browse files Browse the repository at this point in the history
  • Loading branch information
skyflow-lipsa committed Oct 20, 2023
1 parent 0be8bf9 commit 6bf9c2e
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/vault-api/Skyflow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ describe('get method with options', () => {
vaultURL: 'https://www.vaulturl.com',
getBearerToken: () => {
return new Promise((resolve, _) => {
resolve("token")
resolve("encodeURI")
})
}
});
Expand All @@ -2007,6 +2007,39 @@ describe('get method with options', () => {
});
});

test('get method should not encode column values when encodeURI option is false', (done) => {
let reqArg;
const clientReq = jest.fn((arg) => {
reqArg = arg;
return Promise.resolve(getByIdRes);
});

const mockClient = {
config: skyflowConfig,
request: clientReq,
metadata: {},
};

clientModule.mockImplementation(() => mockClient);
skyflow = Skyflow.init({
vaultID: '<VaultID>',
vaultURL: 'https://www.vaulturl.com',
getBearerToken: () => {
return new Promise((resolve, _) => {
resolve("encodeURI")
})
}
});

const response = skyflow.get(getByIdWithValidUniqColumnOptions, { encodeURI: false });
response.then((res) => {
expect((reqArg.url).includes('tokenization=false')).toBe(false);
done();
}).catch((er) => {
done(er)
});
});

test('get method should throw error when encodeURI options is invalid type value', (done) => {

skyflow.get(getByIdWithValidUniqColumnOptions, { encodeURI: '12343' }).then((res) => {
Expand Down

0 comments on commit 6bf9c2e

Please sign in to comment.