From ca068b93b86c5eea61cf23a028ce937158beaefb Mon Sep 17 00:00:00 2001 From: Tobias Bocanegra Date: Mon, 21 Oct 2024 09:05:54 +0200 Subject: [PATCH] chore: remove testutils (#554) --- .husky/pre-commit | 3 --- package.json | 3 +-- test/conditions.integration.test.js | 2 +- test/edgedict.integration.test.js | 2 +- test/package.integration.test.js | 2 +- test/utils.js | 35 +++++++++++++++++++++++++++++ 6 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 test/utils.js diff --git a/.husky/pre-commit b/.husky/pre-commit index 36af2198..2312dc58 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - npx lint-staged diff --git a/package.json b/package.json index bd728fbc..53e76323 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "docs": "jsdoc2md --files src/*.js -t README.md.hbs -d 3 > README.md", "semantic-release": "semantic-release", "semantic-release-dry": "semantic-release --dry-run --no-ci --branches $CI_BRANCH", - "prepare": "husky install" + "prepare": "husky" }, "exports": { ".": "./src/index.js", @@ -46,7 +46,6 @@ }, "devDependencies": { "@adobe/eslint-config-helix": "2.0.8", - "@adobe/helix-testutils": "0.4.17", "@semantic-release/changelog": "6.0.3", "@semantic-release/git": "10.0.1", "c8": "9.1.0", diff --git a/test/conditions.integration.test.js b/test/conditions.integration.test.js index c6d116cc..49db87f5 100644 --- a/test/conditions.integration.test.js +++ b/test/conditions.integration.test.js @@ -1,8 +1,8 @@ /* eslint-env mocha */ import assert from 'assert'; -import { condit } from '@adobe/helix-testutils'; import nock from 'nock'; import f from '../src/index.js'; +import { condit } from './utils.js'; describe('#integration condition updates', () => { let fastly; diff --git a/test/edgedict.integration.test.js b/test/edgedict.integration.test.js index 7e6a02be..8944a907 100644 --- a/test/edgedict.integration.test.js +++ b/test/edgedict.integration.test.js @@ -1,9 +1,9 @@ /* eslint-env mocha */ import assert, { AssertionError } from 'assert'; -import { condit } from '@adobe/helix-testutils'; import nock from 'nock'; import f from '../src/index.js'; +import { condit } from './utils.js'; describe('#integration edge dictionary updates', () => { let fastly; diff --git a/test/package.integration.test.js b/test/package.integration.test.js index c308a43d..52f75622 100644 --- a/test/package.integration.test.js +++ b/test/package.integration.test.js @@ -3,8 +3,8 @@ import assert from 'assert'; import path from 'path'; import fs from 'fs/promises'; import nock from 'nock'; -import { condit } from '@adobe/helix-testutils'; import f from '../src/index.js'; +import { condit } from './utils.js'; describe('#integration compute@edge packages', () => { let fastly; diff --git a/test/utils.js b/test/utils.js new file mode 100644 index 00000000..85d364a2 --- /dev/null +++ b/test/utils.js @@ -0,0 +1,35 @@ +/* + * Copyright 2024 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +/* eslint-env mocha */ +export function condit(name, condition, mochafn) { + if (condition()) { + return it(name, mochafn); + } + return it.skip(`${name} (${condition.description || 'condition not met'})`, mochafn); +} + +condit.hasenv = (name) => { + const fn = function env() { + return !!process.env[name]; + }; + fn.description = `env var ${name} must be set`; + return fn; +}; + +condit.hasenvs = (names) => { + const fn = function envs() { + return names.reduce((p, c) => p && !!process.env[c], true); + }; + + fn.description = `env vars ${names.join(', ')} must be set`; + return fn; +};