Skip to content

Commit

Permalink
test: add js suffix for imports
Browse files Browse the repository at this point in the history
Part of #218
  • Loading branch information
myfreeer committed Oct 5, 2024
1 parent 9d0a900 commit 7379f1c
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 31 deletions.
4 changes: 2 additions & 2 deletions test/downloader/worker-pool.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {join} from 'path';
// noinspection ES6PreferShortImport
import type {WorkerInfo} from '../../src/downloader/worker-pool';
import {WorkerPool} from '../../src/downloader/worker-pool';
import type {WorkerInfo} from '../../src/downloader/worker-pool.js';
import {WorkerPool} from '../../src/downloader/worker-pool.js';

describe('worker-pool', function () {
test('pool would work correctly', async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/life-cycle/detect-resource-type.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import {
binaryExtension,
detectResourceType
} from '../../src/life-cycle/detect-resource-type';
import {ResourceType} from '../../src/resource';
} from '../../src/life-cycle/detect-resource-type.js';
import {ResourceType} from '../../src/resource.js';

describe('detect-resource-type', function () {

Expand Down
14 changes: 7 additions & 7 deletions test/life-cycle/process-source-map.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type {CreateResourceArgument, Resource} from '../../src/resource';
import {createResource, ResourceType} from '../../src/resource';
import type {CreateResourceArgument, Resource} from '../../src/resource.js';
import {createResource, ResourceType} from '../../src/resource.js';
import {
isUriChar,
processSourceMap,
SOURCE_MAP_HEADER,
sourceMapPrefix,
X_SOURCE_MAP_HEADER
} from '../../src/life-cycle/process-source-map';
import type {DownloadResource} from '../../src/life-cycle/types';
} from '../../src/life-cycle/process-source-map.js';
import type {DownloadResource} from '../../src/life-cycle/types.js';
// noinspection ES6PreferShortImport
import type {PipelineExecutor} from '../../src/life-cycle/pipeline-executor';
import type {StaticDownloadOptions} from '../../src/options';
import type {Cheerio} from '../../src/types';
import type {PipelineExecutor} from '../../src/life-cycle/pipeline-executor.js';
import type {StaticDownloadOptions} from '../../src/options.js';
import type {Cheerio} from '../../src/types.js';

const fakeRes = (url: string): DownloadResource => {
const arg: CreateResourceArgument = {
Expand Down
6 changes: 3 additions & 3 deletions test/life-cycle/save-html-to-disk.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {load} from 'cheerio';
import * as fs from 'fs';
// noinspection ES6PreferShortImport
import {saveHtmlToDisk} from '../../src/life-cycle/save-html-to-disk';
import {saveHtmlToDisk} from '../../src/life-cycle/save-html-to-disk.js';
import {
fakeOpt,
fakePipeline,
mockFs,
mockModules,
resHtml as res
} from './save-mock-fs';
} from './save-mock-fs.js';
import {join} from 'path';
import {ResourceType} from '../../src/resource';
import {ResourceType} from '../../src/resource.js';

mockModules();

Expand Down
12 changes: 6 additions & 6 deletions test/life-cycle/save-mock-fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import type {
Resource,
ResourceBody,
ResourceEncoding
} from '../../src/resource';
import {createResource, ResourceType} from '../../src/resource';
import type {DownloadResource} from '../../src/life-cycle/types';
import type {StaticDownloadOptions} from '../../src/options';
} from '../../src/resource.js';
import {createResource, ResourceType} from '../../src/resource.js';
import type {DownloadResource} from '../../src/life-cycle/types.js';
import type {StaticDownloadOptions} from '../../src/options.js';
// noinspection ES6PreferShortImport
import type {PipelineExecutor} from '../../src/life-cycle/pipeline-executor';
import type {PipelineExecutor} from '../../src/life-cycle/pipeline-executor.js';
import {promises} from 'fs';
import {toString} from '../../src/util';
import {toString} from '../../src/util.js';

export const fakeOpt = {
concurrency: 0,
Expand Down
12 changes: 10 additions & 2 deletions test/life-cycle/save-resource-to-disk.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import * as fs from 'fs';
// noinspection ES6PreferShortImport
import {saveResourceToDisk} from '../../src/life-cycle/save-resource-to-disk';
import {
saveResourceToDisk
} from '../../src/life-cycle/save-resource-to-disk.js';
import {join} from 'path';
import {fakeOpt, fakePipeline, mockFs, mockModules, res} from './save-mock-fs';
import {
fakeOpt,
fakePipeline,
mockFs,
mockModules,
res
} from './save-mock-fs.js';

mockModules();

Expand Down
2 changes: 1 addition & 1 deletion test/life-cycle/skip-links.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
skipLinks,
unProcessableUriSchemes
} from '../../src/life-cycle/skip-links';
} from '../../src/life-cycle/skip-links.js';

describe('life-cycle/skip-links', function () {
test('skip-un-processable-uri-schemes', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/resource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
CreateResourceArgument,
RawResource,
Resource
} from '../src/resource';
} from '../src/resource.js';
import {
checkAbsoluteUri,
createResource,
Expand All @@ -13,8 +13,8 @@ import {
resolveFileUrl,
ResourceType,
urlOfSavePath
} from '../src/resource';
import URI = require('urijs');
} from '../src/resource.js';
import URI from 'urijs';

describe('resource', function () {
test('html-to-html-resource', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/sources.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {sources} from '../src/sources';
import {sources} from '../src/sources.js';
import {load} from 'cheerio';
import {ResourceType} from '../src/resource';
import {ResourceType} from '../src/resource.js';

describe('sources', function () {
test('source should contains type', () => {
Expand Down
8 changes: 5 additions & 3 deletions test/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import {
arrayToMap,
escapePath,
importDefaultFromPath,
isSiteMap, isUrlHttp,
isSiteMap,
isUrlHttp,
sleep,
toString, weakAssign
} from '../src/util';
toString,
weakAssign
} from '../src/util.js';
import {join} from 'path';

describe('util', function () {
Expand Down

0 comments on commit 7379f1c

Please sign in to comment.