Skip to content

Commit

Permalink
Merge pull request #560 from eik-lib/convert_tests_to_esm
Browse files Browse the repository at this point in the history
Convert tests to esm
  • Loading branch information
wkillerud authored Jul 29, 2024
2 parents ee93a4b + 8bbf7b3 commit e6d3dd2
Show file tree
Hide file tree
Showing 19 changed files with 257 additions and 228 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"formatters"
],
"scripts": {
"test": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --no-coverage-report --no-cov --timeout 0 --test-regex=.test.js --test-ignore=node_modules",
"test:integration": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --no-coverage-report --no-cov --timeout 0 test/integration/**/*.test.js",
"test:unit": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --no-coverage-report --no-cov --timeout 0 test/*.test.js",
"test:tasks": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --no-coverage-report --no-cov --timeout 0 test/tasks/*.test.js",
"test": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --no-coverage-report --no-cov --timeout 0 --test-regex=.test.mjs --test-ignore=node_modules",
"test:integration": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --no-coverage-report --no-cov --timeout 0 test/integration/**/*.test.mjs",
"test:unit": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --no-coverage-report --no-cov --timeout 0 test/*.test.mjs",
"test:tasks": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --no-coverage-report --no-cov --timeout 0 test/tasks/*.test.mjs",
"test:ci:integration": "npm run test:integration -- --jobs=1",
"test:ci:unit": "npm run test:unit -- --jobs=1",
"test:ci:tasks": "npm run test:tasks -- --jobs=1",
Expand Down
28 changes: 15 additions & 13 deletions test/alias.test.js → test/alias.test.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/* eslint-disable no-param-reassign */

'use strict';

const os = require('os');
const fs = require('fs').promises;
const { join, basename } = require('path');
const { test, beforeEach, afterEach } = require('tap');
const EikService = require('@eik/service');
const fastify = require('fastify');
const { sink } = require('@eik/core');
const { mockLogger } = require('./utils');
const cli = require('..');
import fastify from 'fastify';
import { promises as fs } from 'fs';
import os from 'os';
import { exec as execCallback } from 'child_process';
import { join, basename } from 'path';
import { mockLogger } from './utils.mjs';
import { test, beforeEach, afterEach } from 'tap';
import EikService from '@eik/service';
import { sink } from '@eik/core';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import cli from '../classes/index.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

beforeEach(async (t) => {
const server = fastify({ logger: false });
Expand Down
30 changes: 15 additions & 15 deletions test/integration/alias.test.js → test/integration/alias.test.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';

/* eslint-disable no-param-reassign */

const fastify = require('fastify');
const fs = require('fs').promises;
const os = require('os');
const cp = require('child_process');
const { join, basename } = require('path');
const { test, beforeEach, afterEach } = require('tap');
const fetch = require('node-fetch');
const EikService = require('@eik/service');
const { sink } = require('@eik/core');
const cli = require('../..');
import fastify from 'fastify';
import { promises as fs } from 'node:fs';
import os from 'node:os';
import { exec as execCallback } from 'child_process';
import { join, basename } from 'node:path';
import { test, beforeEach, afterEach } from 'tap';
import EikService from '@eik/service';
import { sink } from '@eik/core';
import cli from '../../classes/index.js';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

function exec(cmd) {
return new Promise((resolve) => {
cp.exec(cmd, (error, stdout, stderr) => {
execCallback(cmd, (error, stdout, stderr) => {
resolve({ error, stdout, stderr });
});
});
Expand Down
23 changes: 13 additions & 10 deletions test/integration/init.test.js → test/integration/init.test.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
'use strict';
import { promises as fs } from 'fs';
import os from 'os';
import { test } from 'tap';
import { join, basename } from 'path';
import { readFileSync } from 'fs';
import { exec as execCallback } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

const fs = require('fs').promises;
const os = require('os');
const { test } = require('tap');
const { join, basename } = require('path');
const { readFileSync } = require('fs');
const cp = require('child_process');
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

function exec(cmd) {
return new Promise((resolve) => {
cp.exec(cmd, (error, stdout, stderr) => {
execCallback(cmd, (error, stdout, stderr) => {
resolve({ error, stdout, stderr });
});
});
Expand All @@ -22,7 +25,7 @@ test('Initializing a new eik.json file', async (t) => {
const publishCmd = `${eik} init --cwd ${folder}`;
await exec(publishCmd);

const assets = JSON.parse(readFileSync(join(folder, 'eik.json')));
const assets = JSON.parse(readFileSync(join(folder, 'eik.json'), { encoding: 'utf8' }));

t.equal(assets.name, '', 'eik.json "name" field should be empty');
t.equal(
Expand All @@ -45,7 +48,7 @@ test('Initializing a new eik.json file passing custom values', async (t) => {
--server http://localhost:4001`;
await exec(publishCmd.split('\n').join(' '));

const assets = JSON.parse(readFileSync(join(folder, 'eik.json')));
const assets = JSON.parse(readFileSync(join(folder, 'eik.json'), { encoding: 'utf8' }));

t.equal(
assets.name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
'use strict';

/* eslint-disable no-param-reassign */
const fastify = require('fastify');
const fs = require('fs').promises;
const os = require('os');
const cp = require('child_process');
const { join, basename } = require('path');
const { test, beforeEach, afterEach } = require('tap');
const EikService = require('@eik/service');
const { sink } = require('@eik/core');
const cli = require('../..');
import fastify from 'fastify';
import { promises as fs } from 'fs';
import os from 'os';
import { exec as execCallback } from 'child_process';
import { join, basename } from 'path';
import { test, beforeEach, afterEach } from 'tap';
import EikService from '@eik/service';
import { sink } from '@eik/core';
import cli from '../../classes/index.js';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

function exec(cmd) {
return new Promise((resolve) => {
cp.exec(cmd, (error, stdout, stderr) => {
execCallback(cmd, (error, stdout, stderr) => {
resolve({ error, stdout, stderr });
});
});
Expand Down
28 changes: 14 additions & 14 deletions test/integration/login.test.js → test/integration/login.test.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* eslint-disable no-param-reassign */

'use strict';

// const util = require('util');
const fastify = require('fastify');
const fs = require('fs').promises;
const os = require('os');
const cp = require('child_process');
const { join, basename } = require('path');
const { test, beforeEach, afterEach } = require('tap');
const EikService = require('@eik/service');
const { sink } = require('@eik/core');
import fastify from 'fastify';
import { promises as fs } from 'fs';
import os from 'os';
import { exec as execCallback } from 'child_process';
import { join, basename } from 'path';
import { test, beforeEach, afterEach } from 'tap';
import EikService from '@eik/service';
import { sink } from '@eik/core';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

function exec(cmd) {
return new Promise((resolve) => {
cp.exec(cmd, (error, stdout, stderr) => {
execCallback(cmd, (error, stdout, stderr) => {
resolve({ error, stdout, stderr });
});
});
Expand Down
28 changes: 15 additions & 13 deletions test/integration/map.test.js → test/integration/map.test.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
'use strict';
import fastify from 'fastify';
import { promises as fs } from 'fs';
import os from 'os';
import { exec as execCallback } from 'child_process';
import { join, basename } from 'path';
import { test, beforeEach, afterEach } from 'tap';
import fetch from 'node-fetch';
import EikService from '@eik/service';
import { sink } from '@eik/core';
import cli from '../../classes/index.js';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

/* eslint-disable no-param-reassign */
const fastify = require('fastify');
const fs = require('fs').promises;
const os = require('os');
const cp = require('child_process');
const { join, basename } = require('path');
const { test, beforeEach, afterEach } = require('tap');
const fetch = require('node-fetch');
const EikService = require('@eik/service');
const { sink } = require('@eik/core');
const cli = require('../..');
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

function exec(cmd) {
return new Promise((resolve) => {
cp.exec(cmd, (error, stdout, stderr) => {
execCallback(cmd, (error, stdout, stderr) => {
resolve({ error, stdout, stderr });
});
});
Expand Down
26 changes: 14 additions & 12 deletions test/integration/meta.test.js → test/integration/meta.test.mjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
'use strict';
import fastify from 'fastify';
import { promises as fs } from 'fs';
import os from 'os';
import { exec as execCallback } from 'child_process';
import { join, basename } from 'path';
import { test, beforeEach, afterEach } from 'tap';
import EikService from '@eik/service';
import { sink } from '@eik/core';
import cli from '../../classes/index.js';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

/* eslint-disable no-param-reassign */
const fastify = require('fastify');
const fs = require('fs').promises;
const os = require('os');
const cp = require('child_process');
const { join, basename } = require('path');
const { test, beforeEach, afterEach } = require('tap');
const EikService = require('@eik/service');
const { sink } = require('@eik/core');
const cli = require('../..');
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

function exec(cmd) {
return new Promise((resolve) => {
cp.exec(cmd, (error, stdout, stderr) => {
execCallback(cmd, (error, stdout, stderr) => {
resolve({ error, stdout, stderr });
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
'use strict';

/* eslint-disable no-param-reassign */
const fastify = require('fastify');
const fs = require('fs').promises;
const os = require('os');
const cp = require('child_process');
const { join, basename } = require('path');
const { test, beforeEach, afterEach } = require('tap');
const fetch = require('node-fetch');
const EikService = require('@eik/service');
const { sink } = require('@eik/core');
const cli = require('../..');
import fastify from 'fastify';
import { promises as fs } from 'fs';
import os from 'os';
import { exec as execCallback } from 'child_process';
import { join, basename } from 'path';
import { test, beforeEach, afterEach } from 'tap';
import EikService from '@eik/service';
import { sink } from '@eik/core';
import cli from '../../classes/index.js';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

function exec(cmd) {
return new Promise((resolve) => {
cp.exec(cmd, (error, stdout, stderr) => {
execCallback(cmd, (error, stdout, stderr) => {
resolve({ error, stdout, stderr });
});
});
Expand Down
22 changes: 13 additions & 9 deletions test/integrity.test.js → test/integrity.test.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/* eslint-disable no-param-reassign */
import fastify from 'fastify';
import { promises as fs } from 'fs';
import os from 'os';
import { join, basename } from 'path';
import { mockLogger } from './utils.mjs';
import { test, beforeEach, afterEach } from 'tap';
import EikService from '@eik/service';
import { sink } from '@eik/core';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import cli from '../classes/index.js';

'use strict';

const { join } = require('path');
const fastify = require('fastify');
const { test, beforeEach, afterEach } = require('tap');
const EikService = require('@eik/service');
const { sink } = require('@eik/core');
const cli = require('..');
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

beforeEach(async (t) => {
const server = fastify({ logger: false });
Expand Down
24 changes: 14 additions & 10 deletions test/login.test.js → test/login.test.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/* eslint-disable no-param-reassign */

'use strict';

const { test, beforeEach, afterEach } = require('tap');
const fastify = require('fastify');
const EikService = require('@eik/service');
const { sink } = require('@eik/core');
const { mockLogger } = require('./utils');
const cli = require('..');
import fastify from 'fastify';
import { promises as fs } from 'fs';
import os from 'os';
import { join, basename } from 'path';
import { mockLogger } from './utils.mjs';
import { test, beforeEach, afterEach } from 'tap';
import EikService from '@eik/service';
import { sink } from '@eik/core';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import cli from '../classes/index.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

beforeEach(async (t) => {
const memSink = new sink.MEM();
Expand Down
25 changes: 13 additions & 12 deletions test/meta.test.js → test/meta.test.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/* eslint-disable no-param-reassign */
import fastify from 'fastify';
import { promises as fs } from 'fs';
import os from 'os';
import { join, basename } from 'path';
import { mockLogger } from './utils.mjs';
import { test, beforeEach, afterEach } from 'tap';
import EikService from '@eik/service';
import { sink } from '@eik/core';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import cli from '../classes/index.js';

'use strict';

const os = require('os');
const fs = require('fs').promises;
const { join, basename } = require('path');
const fastify = require('fastify');
const { test, beforeEach, afterEach } = require('tap');
const EikService = require('@eik/service');
const { sink } = require('@eik/core');
const { mockLogger } = require('./utils');
const cli = require('..');
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

beforeEach(async (t) => {
const server = fastify({ logger: false });
Expand Down
Loading

0 comments on commit e6d3dd2

Please sign in to comment.