Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aliyss committed Jul 19, 2024
1 parent 120a76e commit a70d9fb
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 63 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ main();
async function main() {
// Search for products matching a certain string.
const guestInfo = await MigrosAPI.account.oauth2.getGuestToken();
const responseProductSearch = await MigrosAPI.products.productSearch.searchProduct({
const responseProductSearch = await MigrosAPI.products.productSearch.searchProduct({
query: "cooking salt",
},
{ leshopch: guestInfo.token })
Expand All @@ -40,9 +40,9 @@ async function main() {
hl: "",
TS012f1684: ""
}
// Get security options of your MigrosAPI Account
const securityOptions = await MigrosAPI.account.security.getOptions(loginCookies)
console.log(securityOptions)
// Get security options of your MigrosAPI Account
const securityOptions = await MigrosAPI.account.security.getOptions(loginCookies)
console.log(securityOptions)
}
```

Expand Down
30 changes: 21 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
],
"main": "dist/index.js",
"typings": "./dist/index.d.ts",
"files": ["/dist", "/src"],
"files": [
"/dist",
"/src"
],
"scripts": {
"test": "jest",
"lint": "eslint . --ext .ts",
Expand Down Expand Up @@ -46,6 +49,7 @@
},
"dependencies": {
"cheerio": "^1.0.0-rc.12",
"dotenv": "^16.4.5",
"pino": "^8.6.1",
"pino-pretty": "^9.1.1"
}
Expand Down
56 changes: 31 additions & 25 deletions tests/cumulus-receipt.test.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { describe, test } from "@jest/globals";
// import { MigrosAPI } from "../src";
import { describe, test, expect } from "@jest/globals";
import { MigrosAPI } from "../src";
import * as dotenv from "dotenv";
import path from "path";

describe("Check for Migros Cumulus Receipt", () => {
test("Retrieve Cumulus Receipt", async () => {
// const responseReceipts = await MigrosAPI.account.cumulus.getCumulusReceipts(
// {
// from: new Date("01.12.2023"),
// to: new Date(),
// },
// {
// ["cookie-banner-acceptance-state"]: "true",
// JSESSIONID: responseSession["set-cookie"]["JSESSIONID"],
// INGRESSCOOKIE: ".",
// },
// );
// console.log(responseReceipts);
// const response = await MigrosAPI.account.cumulus.getCumulusReceipt(
// {
// receiptId: responseReceipts[0].id,
// },
// {
// JSESSIONID: responseSession["set-cookie"]["JSESSIONID"],
// INGRESSCOOKIE: ".",
// },
// );
// expect(response).toBe({});
dotenv.config({ path: path.join(__dirname, "../.env") });
if (!process.env.CUMULUS_JSESSIONID || !process.env.CUMULUS_INGRESSCOOKIE) {
console.log("Please provide JSESSIONID and INGRESSCOOKIE in .env");
return;
}
const responseReceipts = await MigrosAPI.account.cumulus.getCumulusReceipts(
{
from: new Date("01.12.2023"),
to: new Date(),
},
{
["cookie-banner-acceptance-state"]: "true",
JSESSIONID: process.env.CUMULUS_JSESSIONID,
INGRESSCOOKIE: process.env.CUMULUS_INGRESSCOOKIE,
},
);
expect(responseReceipts).toBeInstanceOf(Array);
const response = await MigrosAPI.account.cumulus.getCumulusReceipt(
{
receiptId: responseReceipts[0].id,
},
{
JSESSIONID: process.env.CUMULUS_JSESSIONID,
INGRESSCOOKIE: process.env.CUMULUS_INGRESSCOOKIE,
},
);
expect(response).toHaveProperty("cumulus");
});
});
48 changes: 25 additions & 23 deletions tests/cumulus-receipts.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { describe, expect, test } from '@jest/globals';
// import { MigrosAPI } from "../src";
import { describe, expect, test } from "@jest/globals";
import { MigrosAPI } from "../src";
import * as dotenv from "dotenv";
import path from "path";

describe('Check for Migros Cumulus Receipts', () => {
test('Retrieve Cumulus Receipts', async () => {
/*
const response = await MigrosAPI.account.cumulus.getCumulusReceipts({
from: new Date("01.04.2022"),
to: new Date()
}, {
"BIGipServerpool_shared_migros.ch_80": ".",
"cookie-banner-acceptance-state": ".",
"mo-fulfilmentOption": ".",
"mo-lang": ".",
"mo-securityContext": ".",
"mo-sidebarsState": ".",
JSESSIONID: ".",
REALPERSON_SESSION: "."
})
*/
describe("Check for Migros Cumulus Receipts", () => {
test("Retrieve Cumulus Receipts", async () => {
dotenv.config({ path: path.join(__dirname, "../.env") });
if (!process.env.CUMULUS_JSESSIONID || !process.env.CUMULUS_INGRESSCOOKIE) {
console.log("Please provide JSESSIONID and INGRESSCOOKIE in .env");
return;
}
const responseReceipts = await MigrosAPI.account.cumulus.getCumulusReceipts(
{
from: new Date("01.12.2023"),
to: new Date(),
},
{
["cookie-banner-acceptance-state"]: "true",
JSESSIONID: process.env.CUMULUS_JSESSIONID,
INGRESSCOOKIE: process.env.CUMULUS_INGRESSCOOKIE,
},
);
expect(responseReceipts).toBeInstanceOf(Array);
});
});

expect(null).toBe(null)
});
});
2 changes: 1 addition & 1 deletion tests/migusto-recipe-products.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ describe("Search for recipe products", () => {
};
const response =
await MigrosAPI.migusto.recipeProducts(recipeProductOptions);
expect(response.productIds).toContain("233520695510");
expect(response.productIds).toContain("103322000000");
});
});

0 comments on commit a70d9fb

Please sign in to comment.