queued_processes.spec.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. require("../setup");
  2. import { expect } from "chai";
  3. import { Cassettes } from "mocha-cassettes";
  4. import { LokaliseApi } from "../../src/lokalise/lokalise_api";
  5. describe("QueuedProcesses", 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 process_id = "c23eb693ff46cd9a78310132dfbc6a42c93b0fc2";
  10. cassette
  11. .createTest("list", async () => {
  12. const processes = await lokaliseApi.queuedProcesses().list({
  13. project_id: project_id,
  14. });
  15. expect(processes.items[0].process_id).to.eq(
  16. "8a635e096e652c26c4ce6ef5f5e389e007ce31f0"
  17. );
  18. })
  19. .register(this);
  20. cassette
  21. .createTest("list_pagination", async () => {
  22. const processes = await lokaliseApi.queuedProcesses().list({
  23. project_id: project_id,
  24. limit: 1,
  25. page: 2,
  26. });
  27. expect(processes.items[0].type).to.eq("file-import");
  28. expect(processes.totalResults).to.eq(2);
  29. expect(processes.totalPages).to.eq(2);
  30. expect(processes.resultsPerPage).to.eq(1);
  31. expect(processes.currentPage).to.eq(2);
  32. })
  33. .register(this);
  34. cassette
  35. .createTest("get", async () => {
  36. const process = await lokaliseApi.queuedProcesses().get(process_id, {
  37. project_id: project_id,
  38. });
  39. expect(process.process_id).to.eq(process_id);
  40. expect(process.type).to.eq("file-import");
  41. expect(process.status).to.eq("finished");
  42. expect(process.message).to.eq("");
  43. expect(process.created_by).to.eq(20181);
  44. expect(process.created_by_email).to.eq("bodrovis@protonmail.com");
  45. expect(process.created_at).to.eq("2020-05-15 11:16:48 (Etc/UTC)");
  46. expect(process.created_at_timestamp).to.eq(1589541408);
  47. expect(process.details["files"].length).to.eq(1);
  48. const file = process.details["files"][0];
  49. expect(file.name_original).to.eq("test_async.json");
  50. expect(file.word_count_total).to.eq(3);
  51. expect(file.status).to.eq("finished");
  52. })
  53. .register(this);
  54. });