translation_statuses.spec.ts 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. require("../setup");
  2. import { expect } from "chai";
  3. import { Cassettes } from "mocha-cassettes";
  4. import { LokaliseApi } from "../../src/lokalise/lokalise_api";
  5. describe("TranslationStatuses", function () {
  6. const cassette = new Cassettes("./test/cassettes");
  7. const lokaliseApi = new LokaliseApi({ apiKey: process.env.API_KEY });
  8. const project_id = "803826145ba90b42d5d860.46800099";
  9. const new_status_id = 131;
  10. cassette
  11. .createTest("list", async () => {
  12. const statuses = await lokaliseApi.translationStatuses().list({
  13. project_id: project_id,
  14. });
  15. expect(statuses.items[0].title).to.eq("random");
  16. })
  17. .register(this);
  18. cassette
  19. .createTest("list_pagination", async () => {
  20. const statuses = await lokaliseApi.translationStatuses().list({
  21. project_id: project_id,
  22. page: 2,
  23. limit: 1,
  24. });
  25. expect(statuses.items[0].title).to.eq("tested");
  26. expect(statuses.totalResults).to.eq(2);
  27. expect(statuses.totalPages).to.eq(2);
  28. expect(statuses.resultsPerPage).to.eq(1);
  29. expect(statuses.currentPage).to.eq(2);
  30. })
  31. .register(this);
  32. cassette
  33. .createTest("get", async () => {
  34. const id = 128;
  35. const status = await lokaliseApi.translationStatuses().get(id, {
  36. project_id: project_id,
  37. });
  38. expect(status.status_id).to.eq(id);
  39. expect(status.title).to.eq("random");
  40. expect(status.color).to.eq("#0079bf");
  41. })
  42. .register(this);
  43. cassette
  44. .createTest("create", async () => {
  45. const status = await lokaliseApi
  46. .translationStatuses()
  47. .create(
  48. { title: "node", color: "#344563" },
  49. { project_id: project_id }
  50. );
  51. expect(status.status_id).to.eq(new_status_id);
  52. expect(status.title).to.eq("node");
  53. expect(status.color).to.eq("#344563");
  54. })
  55. .register(this);
  56. cassette
  57. .createTest("update", async () => {
  58. const status = await lokaliseApi
  59. .translationStatuses()
  60. .update(
  61. new_status_id,
  62. { title: "node updated" },
  63. { project_id: project_id }
  64. );
  65. expect(status.title).to.eq("node updated");
  66. })
  67. .register(this);
  68. cassette
  69. .createTest("delete", async () => {
  70. const response = await lokaliseApi
  71. .translationStatuses()
  72. .delete(new_status_id, { project_id: project_id });
  73. expect(response.project_id).to.eq(project_id);
  74. expect(response.custom_translation_status_deleted).to.be.true;
  75. })
  76. .register(this);
  77. cassette
  78. .createTest("available_colors", async () => {
  79. const colors_data = await lokaliseApi
  80. .translationStatuses()
  81. .available_colors({
  82. project_id: project_id,
  83. });
  84. expect(colors_data.colors).to.include("#f2d600");
  85. })
  86. .register(this);
  87. });