paths.spec.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. import { GIT_REPO_LINK } from 'lib/constants';
  2. import * as paths from 'lib/paths';
  3. import { RouteParams } from 'lib/paths';
  4. const clusterName = 'test-cluster-name';
  5. const groupId = 'test-group-id';
  6. const schemaId = 'test-schema-id';
  7. const topicId = 'test-topic-id';
  8. const brokerId = 'test-Broker-id';
  9. const connectName = 'test-connect-name';
  10. const connectorName = 'test-connector-name';
  11. describe('Paths', () => {
  12. it('gitCommitPath', () => {
  13. expect(paths.gitCommitPath('1234567gh')).toEqual(
  14. `${GIT_REPO_LINK}/commit/1234567gh`
  15. );
  16. });
  17. it('clusterPath', () => {
  18. expect(paths.clusterPath(clusterName)).toEqual(
  19. `/ui/clusters/${clusterName}`
  20. );
  21. expect(paths.clusterPath()).toEqual(
  22. paths.clusterPath(RouteParams.clusterName)
  23. );
  24. });
  25. it('clusterBrokersPath', () => {
  26. expect(paths.clusterBrokersPath(clusterName)).toEqual(
  27. `${paths.clusterPath(clusterName)}/brokers`
  28. );
  29. expect(paths.clusterBrokersPath()).toEqual(
  30. paths.clusterBrokersPath(RouteParams.clusterName)
  31. );
  32. expect(paths.clusterBrokerPath(clusterName, brokerId)).toEqual(
  33. `${paths.clusterPath(clusterName)}/brokers/${brokerId}`
  34. );
  35. expect(paths.clusterBrokerPath()).toEqual(
  36. paths.clusterBrokerPath(RouteParams.clusterName, RouteParams.brokerId)
  37. );
  38. expect(paths.clusterBrokerMetricsPath(clusterName, brokerId)).toEqual(
  39. `${paths.clusterPath(clusterName)}/brokers/${brokerId}/metrics`
  40. );
  41. expect(paths.clusterBrokerMetricsPath()).toEqual(
  42. paths.clusterBrokerMetricsPath(
  43. RouteParams.clusterName,
  44. RouteParams.brokerId
  45. )
  46. );
  47. });
  48. it('clusterConsumerGroupsPath', () => {
  49. expect(paths.clusterConsumerGroupsPath(clusterName)).toEqual(
  50. `${paths.clusterPath(clusterName)}/consumer-groups`
  51. );
  52. expect(paths.clusterConsumerGroupsPath()).toEqual(
  53. paths.clusterConsumerGroupsPath(RouteParams.clusterName)
  54. );
  55. });
  56. it('clusterConsumerGroupDetailsPath', () => {
  57. expect(paths.clusterConsumerGroupDetailsPath(clusterName, groupId)).toEqual(
  58. `${paths.clusterConsumerGroupsPath(clusterName)}/${groupId}`
  59. );
  60. expect(paths.clusterConsumerGroupDetailsPath()).toEqual(
  61. paths.clusterConsumerGroupDetailsPath(
  62. RouteParams.clusterName,
  63. RouteParams.consumerGroupID
  64. )
  65. );
  66. });
  67. it('clusterConsumerGroupResetOffsetsPath', () => {
  68. expect(
  69. paths.clusterConsumerGroupResetOffsetsPath(clusterName, groupId)
  70. ).toEqual(
  71. `${paths.clusterConsumerGroupDetailsPath(
  72. clusterName,
  73. groupId
  74. )}/reset-offsets`
  75. );
  76. expect(paths.clusterConsumerGroupResetOffsetsPath()).toEqual(
  77. paths.clusterConsumerGroupResetOffsetsPath(
  78. RouteParams.clusterName,
  79. RouteParams.consumerGroupID
  80. )
  81. );
  82. });
  83. it('clusterSchemasPath', () => {
  84. expect(paths.clusterSchemasPath(clusterName)).toEqual(
  85. `${paths.clusterPath(clusterName)}/schemas`
  86. );
  87. expect(paths.clusterSchemasPath()).toEqual(
  88. paths.clusterSchemasPath(RouteParams.clusterName)
  89. );
  90. });
  91. it('clusterSchemaNewPath', () => {
  92. expect(paths.clusterSchemaNewPath(clusterName)).toEqual(
  93. `${paths.clusterSchemasPath(clusterName)}/create-new`
  94. );
  95. expect(paths.clusterSchemaNewPath()).toEqual(
  96. paths.clusterSchemaNewPath(RouteParams.clusterName)
  97. );
  98. });
  99. it('clusterSchemaPath', () => {
  100. expect(paths.clusterSchemaPath(clusterName, schemaId)).toEqual(
  101. `${paths.clusterSchemasPath(clusterName)}/${schemaId}`
  102. );
  103. expect(paths.clusterSchemaPath()).toEqual(
  104. paths.clusterSchemaPath(RouteParams.clusterName, RouteParams.subject)
  105. );
  106. });
  107. it('clusterSchemaEditPath', () => {
  108. expect(paths.clusterSchemaEditPath(clusterName, schemaId)).toEqual(
  109. `${paths.clusterSchemaPath(clusterName, schemaId)}/edit`
  110. );
  111. expect(paths.clusterSchemaEditPath()).toEqual(
  112. paths.clusterSchemaEditPath(RouteParams.clusterName, RouteParams.subject)
  113. );
  114. });
  115. it('clusterTopicsPath', () => {
  116. expect(paths.clusterTopicsPath(clusterName)).toEqual(
  117. `${paths.clusterPath(clusterName)}/topics`
  118. );
  119. expect(paths.clusterTopicsPath()).toEqual(
  120. paths.clusterTopicsPath(RouteParams.clusterName)
  121. );
  122. });
  123. it('clusterTopicNewPath', () => {
  124. expect(paths.clusterTopicNewPath(clusterName)).toEqual(
  125. `${paths.clusterTopicsPath(clusterName)}/create-new`
  126. );
  127. expect(paths.clusterTopicNewPath()).toEqual(
  128. paths.clusterTopicNewPath(RouteParams.clusterName)
  129. );
  130. });
  131. it('clusterTopicPath', () => {
  132. expect(paths.clusterTopicPath(clusterName, topicId)).toEqual(
  133. `${paths.clusterTopicsPath(clusterName)}/${topicId}`
  134. );
  135. expect(paths.clusterTopicPath()).toEqual(
  136. paths.clusterTopicPath(RouteParams.clusterName, RouteParams.topicName)
  137. );
  138. });
  139. it('clusterTopicSettingsPath', () => {
  140. expect(paths.clusterTopicSettingsPath(clusterName, topicId)).toEqual(
  141. `${paths.clusterTopicPath(clusterName, topicId)}/settings`
  142. );
  143. expect(paths.clusterTopicSettingsPath()).toEqual(
  144. paths.clusterTopicSettingsPath(
  145. RouteParams.clusterName,
  146. RouteParams.topicName
  147. )
  148. );
  149. });
  150. it('clusterTopicConsumerGroupsPath', () => {
  151. expect(paths.clusterTopicConsumerGroupsPath(clusterName, topicId)).toEqual(
  152. `${paths.clusterTopicPath(clusterName, topicId)}/consumer-groups`
  153. );
  154. expect(paths.clusterTopicConsumerGroupsPath()).toEqual(
  155. paths.clusterTopicConsumerGroupsPath(
  156. RouteParams.clusterName,
  157. RouteParams.topicName
  158. )
  159. );
  160. });
  161. it('clusterTopicMessagesPath', () => {
  162. expect(paths.clusterTopicMessagesPath(clusterName, topicId)).toEqual(
  163. `${paths.clusterTopicPath(clusterName, topicId)}/messages`
  164. );
  165. expect(paths.clusterTopicMessagesPath()).toEqual(
  166. paths.clusterTopicMessagesPath(
  167. RouteParams.clusterName,
  168. RouteParams.topicName
  169. )
  170. );
  171. });
  172. it('clusterTopicSendMessagePath', () => {
  173. expect(paths.clusterTopicSendMessagePath(clusterName, topicId)).toEqual(
  174. `${paths.clusterTopicPath(clusterName, topicId)}/message`
  175. );
  176. expect(paths.clusterTopicSendMessagePath()).toEqual(
  177. paths.clusterTopicSendMessagePath(
  178. RouteParams.clusterName,
  179. RouteParams.topicName
  180. )
  181. );
  182. });
  183. it('clusterTopicEditPath', () => {
  184. expect(paths.clusterTopicEditPath(clusterName, topicId)).toEqual(
  185. `${paths.clusterTopicPath(clusterName, topicId)}/edit`
  186. );
  187. expect(paths.clusterTopicEditPath()).toEqual(
  188. paths.clusterTopicEditPath(RouteParams.clusterName, RouteParams.topicName)
  189. );
  190. });
  191. it('clusterConnectsPath', () => {
  192. expect(paths.clusterConnectsPath(clusterName)).toEqual(
  193. `${paths.clusterPath(clusterName)}/connects`
  194. );
  195. expect(paths.clusterConnectsPath()).toEqual(
  196. paths.clusterConnectsPath(RouteParams.clusterName)
  197. );
  198. });
  199. it('clusterConnectorsPath', () => {
  200. expect(paths.clusterConnectorsPath(clusterName)).toEqual(
  201. `${paths.clusterPath(clusterName)}/connectors`
  202. );
  203. expect(paths.clusterConnectorsPath()).toEqual(
  204. paths.clusterConnectorsPath(RouteParams.clusterName)
  205. );
  206. });
  207. it('clusterConnectorNewPath', () => {
  208. expect(paths.clusterConnectorNewPath(clusterName)).toEqual(
  209. `${paths.clusterConnectorsPath(clusterName)}/create-new`
  210. );
  211. expect(paths.clusterConnectorNewPath()).toEqual(
  212. paths.clusterConnectorNewPath(RouteParams.clusterName)
  213. );
  214. });
  215. it('clusterConnectConnectorPath', () => {
  216. expect(
  217. paths.clusterConnectConnectorPath(clusterName, connectName, connectorName)
  218. ).toEqual(
  219. `${paths.clusterConnectsPath(
  220. clusterName
  221. )}/${connectName}/connectors/${connectorName}`
  222. );
  223. expect(paths.clusterConnectConnectorPath()).toEqual(
  224. paths.clusterConnectConnectorPath(
  225. RouteParams.clusterName,
  226. RouteParams.connectName,
  227. RouteParams.connectorName
  228. )
  229. );
  230. });
  231. it('clusterConnectConnectorsPath', () => {
  232. expect(
  233. paths.clusterConnectConnectorsPath(clusterName, connectName)
  234. ).toEqual(
  235. `${paths.clusterConnectsPath(clusterName)}/${connectName}/connectors`
  236. );
  237. expect(paths.clusterConnectConnectorsPath()).toEqual(
  238. paths.clusterConnectConnectorsPath(
  239. RouteParams.clusterName,
  240. RouteParams.connectName
  241. )
  242. );
  243. });
  244. it('clusterConnectConnectorEditPath', () => {
  245. expect(
  246. paths.clusterConnectConnectorEditPath(
  247. clusterName,
  248. connectName,
  249. connectorName
  250. )
  251. ).toEqual(
  252. `${paths.clusterConnectConnectorPath(
  253. clusterName,
  254. connectName,
  255. connectorName
  256. )}/edit`
  257. );
  258. expect(paths.clusterConnectConnectorEditPath()).toEqual(
  259. paths.clusterConnectConnectorEditPath(
  260. RouteParams.clusterName,
  261. RouteParams.connectName,
  262. RouteParams.connectorName
  263. )
  264. );
  265. });
  266. it('clusterConnectConnectorTasksPath', () => {
  267. expect(
  268. paths.clusterConnectConnectorTasksPath(
  269. clusterName,
  270. connectName,
  271. connectorName
  272. )
  273. ).toEqual(
  274. `${paths.clusterConnectConnectorPath(
  275. clusterName,
  276. connectName,
  277. connectorName
  278. )}/tasks`
  279. );
  280. expect(paths.clusterConnectConnectorTasksPath()).toEqual(
  281. paths.clusterConnectConnectorTasksPath(
  282. RouteParams.clusterName,
  283. RouteParams.connectName,
  284. RouteParams.connectorName
  285. )
  286. );
  287. });
  288. it('clusterConnectConnectorConfigPath', () => {
  289. expect(
  290. paths.clusterConnectConnectorConfigPath(
  291. clusterName,
  292. connectName,
  293. connectorName
  294. )
  295. ).toEqual(
  296. `${paths.clusterConnectConnectorPath(
  297. clusterName,
  298. connectName,
  299. connectorName
  300. )}/config`
  301. );
  302. expect(paths.clusterConnectConnectorConfigPath()).toEqual(
  303. paths.clusterConnectConnectorConfigPath(
  304. RouteParams.clusterName,
  305. RouteParams.connectName,
  306. RouteParams.connectorName
  307. )
  308. );
  309. });
  310. it('clusterKsqlDbPath', () => {
  311. expect(paths.clusterKsqlDbPath(clusterName)).toEqual(
  312. `${paths.clusterPath(clusterName)}/ksqldb`
  313. );
  314. expect(paths.clusterKsqlDbPath()).toEqual(
  315. paths.clusterKsqlDbPath(RouteParams.clusterName)
  316. );
  317. });
  318. it('clusterKsqlDbQueryPath', () => {
  319. expect(paths.clusterKsqlDbQueryPath(clusterName)).toEqual(
  320. `${paths.clusterKsqlDbPath(clusterName)}/query`
  321. );
  322. expect(paths.clusterKsqlDbQueryPath()).toEqual(
  323. paths.clusterKsqlDbQueryPath(RouteParams.clusterName)
  324. );
  325. });
  326. });