Skip to content

Commit 826ecae

Browse files
committed
test: add generated tests for tokenizationDictionary endpoints
1 parent 66fd031 commit 826ecae

File tree

1 file changed

+226
-0
lines changed

1 file changed

+226
-0
lines changed

test/unit/discovery.v1.test.js

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,84 @@ describe('createExpansions', () => {
14911491

14921492
});
14931493
});
1494+
describe('createTokenizationDictionary', () => {
1495+
describe('positive tests', () => {
1496+
beforeAll(() => {
1497+
missingParamsMock.mockReturnValue(missingParamsSuccess);
1498+
});
1499+
test('should pass the right params to createRequest', () => {
1500+
// parameters
1501+
const environment_id = 'fake_environment_id';
1502+
const collection_id = 'fake_collection_id';
1503+
const tokenization_rules = 'fake_tokenization_rules';
1504+
const params = {
1505+
environment_id,
1506+
collection_id,
1507+
tokenization_rules,
1508+
};
1509+
1510+
// invoke method
1511+
discovery.createTokenizationDictionary(params);
1512+
1513+
// assert that create request was called
1514+
expect(createRequestMock).toHaveBeenCalledTimes(1);
1515+
1516+
const options = getOptions(createRequestMock);
1517+
1518+
checkUrlAndMethod(options, '/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary', 'POST');
1519+
checkCallback(createRequestMock);
1520+
const expectedAccept = 'application/json';
1521+
const expectedContentType = 'application/json';
1522+
checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType);
1523+
expect(options.body['tokenization_rules']).toEqual(tokenization_rules);
1524+
expect(options.json).toEqual(true);
1525+
expect(options.path['environment_id']).toEqual(environment_id);
1526+
expect(options.path['collection_id']).toEqual(collection_id);
1527+
});
1528+
1529+
test('should prioritize user-given headers', () => {
1530+
// parameters
1531+
const environment_id = 'fake_environment_id';
1532+
const collection_id = 'fake_collection_id';
1533+
const accept = 'fake/header';
1534+
const contentType = 'fake/header';
1535+
const params = {
1536+
environment_id,
1537+
collection_id,
1538+
headers: {
1539+
Accept: accept,
1540+
'Content-Type': contentType,
1541+
},
1542+
};
1543+
1544+
discovery.createTokenizationDictionary(params);
1545+
checkMediaHeaders(createRequestMock, accept, contentType);
1546+
});
1547+
});
1548+
describe('negative tests', () => {
1549+
beforeAll(() => {
1550+
missingParamsMock.mockReturnValue(missingParamsError);
1551+
});
1552+
1553+
test('should convert a `null` value for `params` to an empty object', done => {
1554+
discovery.createTokenizationDictionary(null, () => {
1555+
checkForEmptyObject(missingParamsMock);
1556+
done();
1557+
});
1558+
});
1559+
1560+
test('should enforce required parameters', done => {
1561+
// required parameters for this method
1562+
const requiredParams = ['environment_id', 'collection_id'];
1563+
1564+
discovery.createTokenizationDictionary({}, err => {
1565+
checkRequiredParamsHandling(requiredParams, err, missingParamsMock, createRequestMock);
1566+
done();
1567+
});
1568+
});
1569+
1570+
});
1571+
});
14941572
describe('deleteExpansions', () => {
14951573
describe('positive tests', () => {
14961574
beforeAll(() => {
@@ -1565,6 +1643,154 @@ describe('deleteExpansions', () => {
15651643

15661644
});
15671645
});
1646+
describe('deleteTokenizationDictionary', () => {
1647+
describe('positive tests', () => {
1648+
beforeAll(() => {
1649+
missingParamsMock.mockReturnValue(missingParamsSuccess);
1650+
});
1651+
test('should pass the right params to createRequest', () => {
1652+
// parameters
1653+
const environment_id = 'fake_environment_id';
1654+
const collection_id = 'fake_collection_id';
1655+
const params = {
1656+
environment_id,
1657+
collection_id,
1658+
};
1659+
1660+
// invoke method
1661+
discovery.deleteTokenizationDictionary(params);
1662+
1663+
// assert that create request was called
1664+
expect(createRequestMock).toHaveBeenCalledTimes(1);
1665+
1666+
const options = getOptions(createRequestMock);
1667+
1668+
checkUrlAndMethod(options, '/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary', 'DELETE');
1669+
checkCallback(createRequestMock);
1670+
const expectedAccept = 'application/json';
1671+
const expectedContentType = 'application/json';
1672+
checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType);
1673+
expect(options.path['environment_id']).toEqual(environment_id);
1674+
expect(options.path['collection_id']).toEqual(collection_id);
1675+
});
1676+
1677+
test('should prioritize user-given headers', () => {
1678+
// parameters
1679+
const environment_id = 'fake_environment_id';
1680+
const collection_id = 'fake_collection_id';
1681+
const accept = 'fake/header';
1682+
const contentType = 'fake/header';
1683+
const params = {
1684+
environment_id,
1685+
collection_id,
1686+
headers: {
1687+
Accept: accept,
1688+
'Content-Type': contentType,
1689+
},
1690+
};
1691+
1692+
discovery.deleteTokenizationDictionary(params);
1693+
checkMediaHeaders(createRequestMock, accept, contentType);
1694+
});
1695+
});
1696+
describe('negative tests', () => {
1697+
beforeAll(() => {
1698+
missingParamsMock.mockReturnValue(missingParamsError);
1699+
});
1700+
1701+
test('should convert a `null` value for `params` to an empty object', done => {
1702+
discovery.deleteTokenizationDictionary(null, () => {
1703+
checkForEmptyObject(missingParamsMock);
1704+
done();
1705+
});
1706+
});
1707+
1708+
test('should enforce required parameters', done => {
1709+
// required parameters for this method
1710+
const requiredParams = ['environment_id', 'collection_id'];
1711+
1712+
discovery.deleteTokenizationDictionary({}, err => {
1713+
checkRequiredParamsHandling(requiredParams, err, missingParamsMock, createRequestMock);
1714+
done();
1715+
});
1716+
});
1717+
1718+
});
1719+
});
1720+
describe('getTokenizationDictionaryStatus', () => {
1721+
describe('positive tests', () => {
1722+
beforeAll(() => {
1723+
missingParamsMock.mockReturnValue(missingParamsSuccess);
1724+
});
1725+
test('should pass the right params to createRequest', () => {
1726+
// parameters
1727+
const environment_id = 'fake_environment_id';
1728+
const collection_id = 'fake_collection_id';
1729+
const params = {
1730+
environment_id,
1731+
collection_id,
1732+
};
1733+
1734+
// invoke method
1735+
discovery.getTokenizationDictionaryStatus(params);
1736+
1737+
// assert that create request was called
1738+
expect(createRequestMock).toHaveBeenCalledTimes(1);
1739+
1740+
const options = getOptions(createRequestMock);
1741+
1742+
checkUrlAndMethod(options, '/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary', 'GET');
1743+
checkCallback(createRequestMock);
1744+
const expectedAccept = 'application/json';
1745+
const expectedContentType = 'application/json';
1746+
checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType);
1747+
expect(options.path['environment_id']).toEqual(environment_id);
1748+
expect(options.path['collection_id']).toEqual(collection_id);
1749+
});
1750+
1751+
test('should prioritize user-given headers', () => {
1752+
// parameters
1753+
const environment_id = 'fake_environment_id';
1754+
const collection_id = 'fake_collection_id';
1755+
const accept = 'fake/header';
1756+
const contentType = 'fake/header';
1757+
const params = {
1758+
environment_id,
1759+
collection_id,
1760+
headers: {
1761+
Accept: accept,
1762+
'Content-Type': contentType,
1763+
},
1764+
};
1765+
1766+
discovery.getTokenizationDictionaryStatus(params);
1767+
checkMediaHeaders(createRequestMock, accept, contentType);
1768+
});
1769+
});
1770+
describe('negative tests', () => {
1771+
beforeAll(() => {
1772+
missingParamsMock.mockReturnValue(missingParamsError);
1773+
});
1774+
1775+
test('should convert a `null` value for `params` to an empty object', done => {
1776+
discovery.getTokenizationDictionaryStatus(null, () => {
1777+
checkForEmptyObject(missingParamsMock);
1778+
done();
1779+
});
1780+
});
1781+
1782+
test('should enforce required parameters', done => {
1783+
// required parameters for this method
1784+
const requiredParams = ['environment_id', 'collection_id'];
1785+
1786+
discovery.getTokenizationDictionaryStatus({}, err => {
1787+
checkRequiredParamsHandling(requiredParams, err, missingParamsMock, createRequestMock);
1788+
done();
1789+
});
1790+
});
1791+
1792+
});
1793+
});
15681794
describe('listExpansions', () => {
15691795
describe('positive tests', () => {
15701796
beforeAll(() => {

0 commit comments

Comments
 (0)