mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 22:50:18 +00:00
Add test
This commit is contained in:
parent
5044dd030d
commit
46ab9e223f
BIN
api/api-npm/__test__/data/transitive-deps/A-0.1.0.tgz
Normal file
BIN
api/api-npm/__test__/data/transitive-deps/A-0.1.0.tgz
Normal file
Binary file not shown.
BIN
api/api-npm/__test__/data/transitive-deps/B-0.1.0.tgz
Normal file
BIN
api/api-npm/__test__/data/transitive-deps/B-0.1.0.tgz
Normal file
Binary file not shown.
BIN
api/api-npm/__test__/data/transitive-deps/C-0.1.0.tgz
Normal file
BIN
api/api-npm/__test__/data/transitive-deps/C-0.1.0.tgz
Normal file
Binary file not shown.
BIN
api/api-npm/__test__/data/transitive-deps/C-0.2.0.tgz
Normal file
BIN
api/api-npm/__test__/data/transitive-deps/C-0.2.0.tgz
Normal file
Binary file not shown.
12
api/api-npm/__test__/data/transitive-deps/project/main.aqua
Normal file
12
api/api-npm/__test__/data/transitive-deps/project/main.aqua
Normal file
@ -0,0 +1,12 @@
|
||||
aqua Main
|
||||
|
||||
export versionBC, versionAC
|
||||
|
||||
use "A.aqua"
|
||||
use "B.aqua"
|
||||
|
||||
func versionAC() -> string:
|
||||
<- A.versionC()
|
||||
|
||||
func versionBC() -> string:
|
||||
<- B.versionC()
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "Project",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"A": "file:../A-0.1.0.tgz",
|
||||
"B": "file:../B-0.1.0.tgz"
|
||||
}
|
||||
}
|
34
api/api-npm/__test__/imports.spec.ts
Normal file
34
api/api-npm/__test__/imports.spec.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { gatherImportsFromNpm } from "../imports.js";
|
||||
|
||||
describe("imports", () => {
|
||||
it("should resolve transitive dependencies", async () => {
|
||||
const imports = await gatherImportsFromNpm(
|
||||
"./__test__/data/transitive-deps/project",
|
||||
);
|
||||
|
||||
const projectPath = Object.keys(imports).find((p) => p.endsWith("project"));
|
||||
|
||||
expect(projectPath).toBeDefined();
|
||||
|
||||
const projectImports = imports[projectPath!];
|
||||
|
||||
expect(projectImports.length).toEqual(2);
|
||||
|
||||
const [dep1Path, dep2Path] = projectImports;
|
||||
|
||||
const dep1Imports = imports[dep1Path];
|
||||
const dep2Imports = imports[dep2Path];
|
||||
|
||||
expect(dep1Imports.length).toEqual(1);
|
||||
expect(dep2Imports.length).toEqual(1);
|
||||
|
||||
const [dep1Transitive] = dep1Imports;
|
||||
const [dep2Transitive] = dep2Imports;
|
||||
|
||||
expect(dep1Transitive.endsWith("C")).toBeTruthy();
|
||||
expect(dep2Transitive.endsWith("C")).toBeTruthy();
|
||||
|
||||
// Transitive dependency should be resolved to different paths
|
||||
expect(dep1Transitive).not.toEqual(dep2Transitive);
|
||||
});
|
||||
});
|
2
api/api-npm/imports.d.ts
vendored
2
api/api-npm/imports.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
import Arborist from "@npmcli/arborist";
|
||||
|
||||
import type { Imports } from "./index.d.ts";
|
||||
export declare type Imports = Record<string, string[]>;
|
||||
|
||||
/**
|
||||
* Gather imports for aqua compiler from
|
||||
|
2
api/api-npm/index.d.ts
vendored
2
api/api-npm/index.d.ts
vendored
@ -21,8 +21,6 @@ export declare class CompilationResult {
|
||||
generatedSources: GeneratedSource[];
|
||||
}
|
||||
|
||||
export type Imports = Record<string, string[]> | string[];
|
||||
|
||||
/** Common arguments for all compile functions */
|
||||
type CommonArgs = {
|
||||
/** Paths to directories, which you want to import .aqua files from. Example: ["./path/to/dir"] */
|
||||
|
16
api/api-npm/jest.config.cjs
Normal file
16
api/api-npm/jest.config.cjs
Normal file
@ -0,0 +1,16 @@
|
||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||
module.exports = {
|
||||
extensionsToTreatAsEsm: [".ts"],
|
||||
preset: "ts-jest/presets/default-esm",
|
||||
moduleNameMapper: {
|
||||
"^(\\.{1,2}/.*)\\.js$": "$1",
|
||||
},
|
||||
transform: {
|
||||
"^.+\\.tsx?$": [
|
||||
"ts-jest",
|
||||
{
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
@ -27,12 +27,21 @@
|
||||
"url": "https://github.com/fluencelabs/aqua/issues"
|
||||
},
|
||||
"homepage": "https://github.com/fluencelabs/aqua#readme",
|
||||
"scripts": {
|
||||
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest --detectOpenHandles"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@npmcli/arborist": "7.2.1",
|
||||
"treeverse": "3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fluencelabs/interfaces": "0.9.0",
|
||||
"prettier": "3.0.0"
|
||||
"@types/jest": "29.5.2",
|
||||
"@types/node": "^20.10.3",
|
||||
"prettier": "3.0.0",
|
||||
"jest": "29.5.0",
|
||||
"ts-jest": "29.1.0",
|
||||
"ts-node": "10.9.1",
|
||||
"typescript": "5.1.3"
|
||||
}
|
||||
}
|
||||
|
21
api/api-npm/tsconfig.json
Normal file
21
api/api-npm/tsconfig.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"lib": ["es2015", "dom"],
|
||||
"declaration": true,
|
||||
"outDir": "dist",
|
||||
"moduleResolution": "nodenext",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": false,
|
||||
"strictNullChecks": false,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"exclude": ["node_modules", "dist", "bundle"],
|
||||
"include": ["__test__/**/*"],
|
||||
"ts-node": {
|
||||
"esm": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user