<commit_before><commit_msg>adding integration tests for read operations<commit_after>"use strict";

jest.autoMockOff();

const ShopifyAPI           = require("../../ShopifyAPI");
const { Page, Session } = ShopifyAPI;

const PageId = 67616453;

describe("Pages API", () => {
  setupIntegrationTest(Session);

  describe("getting pages", () => {
    pit("GET /admin/pages.json", () => {
      return Page.fetch().then(pages => {
        expect(pages.length).toBeGreaterThan(0);
      });
    });

    pit("GET /admin/pages.json?title=", () => {
      return Page.fetch({ title: "Frontpage" }).then(pages => {
        expect(pages.length).toBe(1);
        expect(pages[0].id).toBe(PageId);
      });
    });

    pit("GET /admin/pages/:id.json", () => {
      return Page.fetch(PageId).then(pages => {
        expect(pages).toBeDefined();
        expect(pages.length).toBe(1);
        expect(pages[0].id).toBe(PageId);
      });
    });
  });

  describe("counting pages", () => {
    pit ("GET /admin/pages/count.json", () => {
      return Page.fetchCount().then(count => {
        expect(count).toBeGreaterThan(0);
      });
    });

    pit ("GET /admin/pages/count.json?title=", () => {
      return Page.fetchCount({ title: "Frontpage" }).then(count => {
        expect(count).toBe(1);
      });
    });
  });
});

{'fraction_non_alphanumeric': 0.20956719817767655, 'fraction_numerical': 0.011389521640091117, 'mean_word_length': 2.712676056338028, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7308207', 'n_tokens_mistral': 430, 'n_tokens_neox': 417, 'n_words': 61}