api,http-api: updating babel usage and fixing tests

This commit is contained in:
Hunter Miller 2021-11-09 13:16:48 -06:00
parent 6f31b629a7
commit 4b5db5c332
9 changed files with 141 additions and 467 deletions

View File

@ -4,7 +4,8 @@
"@babel/preset-env", "@babel/preset-env",
{ {
"targets": "> 1%", "targets": "> 1%",
"useBuiltIns": "usage" "useBuiltIns": "usage",
"corejs": "3.19.1"
} }
] ]
] ]

View File

@ -1,18 +1,18 @@
{ {
"name": "@urbit/api", "name": "@urbit/api",
"version": "2.0.0", "version": "2.1.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@urbit/api", "name": "@urbit/api",
"version": "2.0.0", "version": "2.1.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"big-integer": "^1.6.48", "big-integer": "^1.6.48",
"core-js": "^3.19.1",
"immer": "^9.0.1", "immer": "^9.0.1",
"lodash": "^4.17.20",
"urbit-ob": "^5.0.1" "urbit-ob": "^5.0.1"
}, },
"devDependencies": { "devDependencies": {
@ -20,13 +20,13 @@
"@rollup/plugin-babel": "^5.3.0", "@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^21.0.1", "@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.0.6", "@rollup/plugin-node-resolve": "^13.0.6",
"@types/lodash": "^4.14.168",
"@types/node": "^15.12.5", "@types/node": "^15.12.5",
"@typescript-eslint/eslint-plugin": "^4.28.2", "@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2", "@typescript-eslint/parser": "^4.28.2",
"@urbit/eslint-config": "^1.0.3", "@urbit/eslint-config": "^1.0.3",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"eslint-plugin-react": "^7.24.0", "eslint-plugin-react": "^7.24.0",
"rollup": "^2.59.0",
"rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0", "rollup-plugin-typescript2": "^0.30.0",
@ -542,12 +542,6 @@
"integrity": "sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg==", "integrity": "sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg==",
"dev": true "dev": true
}, },
"node_modules/@types/lodash": {
"version": "4.14.171",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.171.tgz",
"integrity": "sha512-7eQ2xYLLI/LsicL2nejW9Wyko3lcpN6O/z0ZLHrEQsg280zIdCv1t/0m6UtBjUHokCGBQ3gYTbHzDkZ1xOBwwg==",
"dev": true
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "15.14.1", "version": "15.14.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.14.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-15.14.1.tgz",
@ -987,6 +981,16 @@
"safe-buffer": "~5.1.1" "safe-buffer": "~5.1.1"
} }
}, },
"node_modules/core-js": {
"version": "3.19.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.19.1.tgz",
"integrity": "sha512-Tnc7E9iKd/b/ff7GFbhwPVzJzPztGrChB8X8GLqoYGdEOG8IpLnK1xPyo3ZoO3HsK6TodJS58VGPOxA+hLHQMg==",
"hasInstallScript": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
}
},
"node_modules/debug": { "node_modules/debug": {
"version": "4.3.2", "version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
@ -1328,7 +1332,6 @@
"os": [ "os": [
"darwin" "darwin"
], ],
"peer": true,
"engines": { "engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0" "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
} }
@ -1799,11 +1802,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/lodash.chunk": { "node_modules/lodash.chunk": {
"version": "4.2.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz", "resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz",
@ -2238,7 +2236,6 @@
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.59.0.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.59.0.tgz",
"integrity": "sha512-l7s90JQhCQ6JyZjKgo7Lq1dKh2RxatOM+Jr6a9F7WbS9WgKbocyUSeLmZl8evAse7y96Ae98L2k1cBOwWD8nHw==", "integrity": "sha512-l7s90JQhCQ6JyZjKgo7Lq1dKh2RxatOM+Jr6a9F7WbS9WgKbocyUSeLmZl8evAse7y96Ae98L2k1cBOwWD8nHw==",
"dev": true, "dev": true,
"peer": true,
"bin": { "bin": {
"rollup": "dist/bin/rollup" "rollup": "dist/bin/rollup"
}, },
@ -3019,12 +3016,6 @@
"integrity": "sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg==", "integrity": "sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg==",
"dev": true "dev": true
}, },
"@types/lodash": {
"version": "4.14.171",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.171.tgz",
"integrity": "sha512-7eQ2xYLLI/LsicL2nejW9Wyko3lcpN6O/z0ZLHrEQsg280zIdCv1t/0m6UtBjUHokCGBQ3gYTbHzDkZ1xOBwwg==",
"dev": true
},
"@types/node": { "@types/node": {
"version": "15.14.1", "version": "15.14.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.14.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-15.14.1.tgz",
@ -3329,6 +3320,11 @@
"safe-buffer": "~5.1.1" "safe-buffer": "~5.1.1"
} }
}, },
"core-js": {
"version": "3.19.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.19.1.tgz",
"integrity": "sha512-Tnc7E9iKd/b/ff7GFbhwPVzJzPztGrChB8X8GLqoYGdEOG8IpLnK1xPyo3ZoO3HsK6TodJS58VGPOxA+hLHQMg=="
},
"debug": { "debug": {
"version": "4.3.2", "version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
@ -3578,8 +3574,7 @@
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true, "dev": true,
"optional": true, "optional": true
"peer": true
}, },
"function-bind": { "function-bind": {
"version": "1.1.1", "version": "1.1.1",
@ -3910,11 +3905,6 @@
"p-locate": "^4.1.0" "p-locate": "^4.1.0"
} }
}, },
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"lodash.chunk": { "lodash.chunk": {
"version": "4.2.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz", "resolved": "https://registry.npmjs.org/lodash.chunk/-/lodash.chunk-4.2.0.tgz",
@ -4234,7 +4224,6 @@
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.59.0.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.59.0.tgz",
"integrity": "sha512-l7s90JQhCQ6JyZjKgo7Lq1dKh2RxatOM+Jr6a9F7WbS9WgKbocyUSeLmZl8evAse7y96Ae98L2k1cBOwWD8nHw==", "integrity": "sha512-l7s90JQhCQ6JyZjKgo7Lq1dKh2RxatOM+Jr6a9F7WbS9WgKbocyUSeLmZl8evAse7y96Ae98L2k1cBOwWD8nHw==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"fsevents": "~2.3.2" "fsevents": "~2.3.2"
} }

View File

@ -25,6 +25,7 @@
"dependencies": { "dependencies": {
"@babel/runtime": "^7.16.0", "@babel/runtime": "^7.16.0",
"big-integer": "^1.6.48", "big-integer": "^1.6.48",
"core-js": "^3.19.1",
"immer": "^9.0.1", "immer": "^9.0.1",
"urbit-ob": "^5.0.1" "urbit-ob": "^5.0.1"
}, },

View File

@ -1,10 +1,12 @@
{ {
"presets": [ "presets": [
"@babel/preset-typescript", //needed for .ts jest tests
[ [
"@babel/preset-env", "@babel/preset-env",
{ {
"targets": "> 1%", "targets": "> 1%",
"useBuiltIns": "usage" "useBuiltIns": "usage",
"corejs": "3.19.1"
} }
] ]
] ]

View File

@ -0,0 +1,3 @@
dist
node_modules
coverage

View File

@ -23,7 +23,7 @@ module.exports = {
// collectCoverageFrom: undefined, // collectCoverageFrom: undefined,
// The directory where Jest should output its coverage files // The directory where Jest should output its coverage files
coverageDirectory: "coverage", coverageDirectory: 'coverage',
// An array of regexp pattern strings used to skip coverage collection // An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [ // coveragePathIgnorePatterns: [
@ -137,7 +137,7 @@ module.exports = {
// snapshotSerializers: [], // snapshotSerializers: [],
// The test environment that will be used for testing // The test environment that will be used for testing
testEnvironment: "jsdom", testEnvironment: 'jsdom',
// Options that will be passed to the testEnvironment // Options that will be passed to the testEnvironment
// testEnvironmentOptions: {}, // testEnvironmentOptions: {},
@ -166,7 +166,7 @@ module.exports = {
// testRunner: "jest-circus/runner", // testRunner: "jest-circus/runner",
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
testURL: "http://localhost", testURL: 'http://localhost',
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real", // timers: "real",

File diff suppressed because it is too large Load Diff

View File

@ -35,6 +35,7 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.15.8", "@babel/core": "^7.15.8",
"@babel/preset-env": "^7.15.8", "@babel/preset-env": "^7.15.8",
"@babel/preset-typescript": "^7.16.0",
"@rollup/plugin-babel": "^5.3.0", "@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^21.0.1", "@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.0.6", "@rollup/plugin-node-resolve": "^13.0.6",
@ -60,6 +61,7 @@
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@microsoft/fetch-event-source": "^2.0.0", "@microsoft/fetch-event-source": "^2.0.0",
"browser-or-node": "^1.3.0" "browser-or-node": "^1.3.0",
"core-js": "^3.19.1"
} }
} }

View File

@ -1,6 +1,4 @@
import Urbit from '../src'; import Urbit from '../src';
import { Readable } from 'streams';
import 'jest'; import 'jest';
function fakeSSE(messages = [], timeout = 0) { function fakeSSE(messages = [], timeout = 0) {
@ -54,7 +52,7 @@ const fakeFetch = (body) => () =>
const wait = (ms: number) => new Promise((res) => setTimeout(res, ms)); const wait = (ms: number) => new Promise((res) => setTimeout(res, ms));
process.on('unhandledRejection', () => { process.on('unhandledRejection', (error) => {
console.error(error); console.error(error);
}); });
@ -91,7 +89,7 @@ describe('Initialisation', () => {
) )
.mockImplementationOnce(() => .mockImplementationOnce(() =>
Promise.resolve({ ok: true, body: fakeSSE([], 100) }) Promise.resolve({ ok: true, body: fakeSSE([], 100) })
) );
airlock.onError = jest.fn(); airlock.onError = jest.fn();
try { try {
@ -163,7 +161,7 @@ describe('subscription', () => {
) )
.mockImplementationOnce(() => .mockImplementationOnce(() =>
Promise.resolve({ ok: false, body: fakeSSE([ack(1, true)]) }) Promise.resolve({ ok: false, body: fakeSSE([ack(1, true)]) })
) );
const params = { const params = {
app: 'app', app: 'app',