Skip to content

Commit

Permalink
Merge pull request #383 from xapijs/feature/adapters
Browse files Browse the repository at this point in the history
✨ feature/adapters
  • Loading branch information
CookieCookson authored Jun 27, 2024
2 parents 83755ef + b14b10d commit 47d79bb
Show file tree
Hide file tree
Showing 89 changed files with 940 additions and 383 deletions.
19 changes: 19 additions & 0 deletions jest.config.edge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require("dotenv").config();

module.exports = {
preset: "ts-jest",
projects: [
{
displayName: "edge-fetch-unit",
testMatch: ["**/*.unit.test.ts"],
testEnvironment: "@edge-runtime/jest-environment",
setupFiles: ["./test/mockFetch.ts", "./test/setupFetch.ts"],
},
{
displayName: "edge-fetch-int",
testMatch: ["**/*.int.test.ts"],
testEnvironment: "@edge-runtime/jest-environment",
setupFilesAfterEnv: ["./test/setupInt.ts", "./test/setupFetch.ts"],
},
],
};
64 changes: 62 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,72 @@ module.exports = {
},
projects: [
{
displayName: "dom",
displayName: "dom-axios-unit",
testMatch: ["**/*.unit.test.ts"],
testEnvironment: "jsdom",
setupFiles: [
"./test/mockAxios.ts",
"./test/mockFetch.ts",
"./test/setupAxios.ts",
],
},
{
displayName: "node",
displayName: "dom-fetch-unit",
testMatch: ["**/*.unit.test.ts"],
testEnvironment: "jsdom",
setupFiles: [
"./test/mockAxios.ts",
"./test/mockFetch.ts",
"./test/setupFetch.ts",
],
},
{
displayName: "node-axios-unit",
testMatch: ["**/*.unit.test.ts"],
testEnvironment: "node",
setupFiles: [
"./test/mockAxios.ts",
"./test/mockFetch.ts",
"./test/setupAxios.ts",
],
},
{
displayName: "node-fetch-unit",
testMatch: ["**/*.unit.test.ts"],
testEnvironment: "node",
setupFiles: [
"./test/mockAxios.ts",
"./test/mockFetch.ts",
"./test/setupFetch.ts",
],
},
{
displayName: "dom-axios-int",
testMatch: ["**/*.int.test.ts"],
testEnvironment: "jsdom",
setupFilesAfterEnv: ["./test/setupInt.ts"],
},
{
displayName: "dom-fetch-int",
testMatch: ["**/*.int.test.ts"],
testEnvironment: "jsdom",
setupFilesAfterEnv: [
"./test/setupInt.ts",
"./test/polyfillFetch.ts",
"./test/setupFetch.ts",
],
},
{
displayName: "node-axios-int",
testMatch: ["**/*.int.test.ts"],
testEnvironment: "node",
setupFilesAfterEnv: ["./test/setupInt.ts", "./test/setupAxios.ts"],
},
{
displayName: "node-fetch-int",
testMatch: ["**/*.int.test.ts"],
testEnvironment: "node",
setupFilesAfterEnv: ["./test/setupInt.ts", "./test/setupFetch.ts"],
},
],
};
196 changes: 180 additions & 16 deletions package-lock.json

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

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xapi/xapi",
"version": "2.2.7",
"version": "2.3.0-alpha.1",
"description": "Communicate over xAPI using JavaScript.",
"main": "dist/XAPI.cjs.js",
"module": "dist/XAPI.esm.js",
Expand All @@ -16,9 +16,10 @@
"build:types": "tsc --emitDeclarationOnly",
"build": "npm run clean && npm run build:types && npm run build:js",
"format": "prettier --write '**/*.{js,jsx,json,ts,tsx}'",
"test": "jest --runInBand && npm run test:example:node:require && npm run test:example:node:import",
"test:unit": "jest --testPathPattern=.unit.test.ts",
"test:int": "jest --testPathPattern=.int.test.ts --runInBand",
"test": "jest --runInBand && npm run test:edge && npm run test:example:node:require && npm run test:example:node:import",
"test:edge": "jest --runInBand --config jest.config.edge.js",
"test:unit": "jest --selectProjects dom-axios-unit dom-fetch-unit node-axios-unit node-fetch-unit",
"test:int": "jest --selectProjects dom-axios-int dom-fetch-int node-axios-int node-fetch-int --runInBand",
"test:format": "prettier --check .",
"test:example:node:require": "node ./example/node/require.js",
"test:example:node:import": "node --experimental-modules --es-module-specifier-resolution=node ./example/node/import.mjs",
Expand All @@ -44,6 +45,7 @@
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/preset-env": "^7.23.2",
"@babel/preset-typescript": "^7.23.2",
"@edge-runtime/jest-environment": "^2.3.10",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.1",
Expand All @@ -66,7 +68,7 @@
"rollup": "^4.3.0",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2",
"uuid": "^9.0.1"
"whatwg-fetch": "^3.6.20"
},
"dependencies": {
"axios": "^1.6.0"
Expand Down
1 change: 1 addition & 0 deletions src/XAPI.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ forEachLRS((_xapi, credential) => {
test("can perform basic authentication challenges when no authorization process is required", () => {
const noAuthXapi = new XAPI({
endpoint: endpoint,
adapter: global.adapter,
});
expect(noAuthXapi.getAbout()).resolves.toBeDefined();
});
Expand Down
Loading

0 comments on commit 47d79bb

Please sign in to comment.