translation_providers.spec.ts 2.0 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("TranslationProviders", function () {
  6. const cassette = new Cassettes("./test/cassettes");
  7. const lokaliseApi = new LokaliseApi({ apiKey: process.env.API_KEY });
  8. const team_id = 176692;
  9. cassette
  10. .createTest("list", async () => {
  11. const providers = await lokaliseApi.translationProviders().list({
  12. team_id: team_id,
  13. });
  14. expect(providers.items[0].name).to.eq("Gengo");
  15. })
  16. .register(this);
  17. cassette
  18. .createTest("list_pagination", async () => {
  19. const providers = await lokaliseApi.translationProviders().list({
  20. team_id: team_id,
  21. page: 2,
  22. limit: 1,
  23. });
  24. expect(providers.items[0].name).to.eq("Lokalise");
  25. expect(providers.totalResults).to.eq(2);
  26. expect(providers.totalPages).to.eq(2);
  27. expect(providers.resultsPerPage).to.eq(1);
  28. expect(providers.currentPage).to.eq(2);
  29. })
  30. .register(this);
  31. cassette
  32. .createTest("get", async () => {
  33. const provider = await lokaliseApi.translationProviders().get(4, {
  34. team_id: team_id,
  35. });
  36. expect(provider.provider_id).to.eq(4);
  37. expect(provider.name).to.eq("Lokalise");
  38. expect(provider.slug).to.eq("lokalise");
  39. expect(provider.price_pair_min).to.eq("10.00");
  40. expect(provider.website_url).to.eq("https://lokalise.com");
  41. expect(provider.description).to.include("Our native professional");
  42. expect(provider.tiers).to.have.lengthOf(4);
  43. expect(provider.tiers[1].tier_id).to.eq(2);
  44. expect(provider.tiers[0].title).to.eq(
  45. "Translation only by a native professional linguist"
  46. );
  47. const pair = provider.pairs[0];
  48. expect(pair.tier_id).to.eq(1);
  49. expect(pair.price_per_word).to.eq(0.1);
  50. expect(pair.from_lang_name).to.eq("Russian");
  51. expect(pair.to_lang_iso).to.eq("en");
  52. expect(pair.to_lang_name).to.eq("English");
  53. })
  54. .register(this);
  55. });