Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Konard committed Jan 24, 2024
1 parent 80ef29f commit 1a5f319
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
testEnvironment: 'jsdom',
displayName: 'node',
testEnvironment: 'node',
verbose: true,
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"npm-pull": "npm-pull",
"npm-release": "npm run build; npm run test; npm-release",
"publish-next-version": "npm run build; npm run test; export CURRENT_VERSION=$(node automation/set-next-version.js); npm i; git add .; git commit -m $CURRENT_VERSION; git push",
"test": "npm run build && cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.js *.js --testTimeout=50000"
"test": "npm run build && cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.js test.js --testTimeout=50000 --detectOpenHandles"
},
"dependencies": {
"@deep-foundation/core": "~0.0.1",
Expand Down
25 changes: 23 additions & 2 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { DeepClient } from '@deep-foundation/deeplinks/imports/client';
import config from './config.json';
import { gql } from "@apollo/client/index.js";

const apollo = generateApolloClient(config.endpoint);
const deep = new DeepClient({ apolloClient: apollo });
let apollo = null;
let deep = null;

const searchNpmPackages = async (query) => {
const deepPackageKeyword = 'deep-package';
Expand Down Expand Up @@ -94,6 +94,13 @@ const getPackageFromNpm = async (packageName) => {
return data;
};

const ensureDeepClientCreated = async () => {
if (!deep) {
apollo = generateApolloClient(config.endpoint);
deep = new DeepClient({ apolloClient: apollo });
}
}

describe('packager tests', () => {
it('npm packages search', async () => {
const query1 = '123456789';
Expand All @@ -115,6 +122,8 @@ describe('packager tests', () => {
});

it.skip('package versions', async () => {
await ensureDeepClientCreated();

const namespaces = await getDeepPackagesVersions(["@deep-foundation/core"]);
console.log(JSON.stringify(namespaces, null, 2));
expect(namespaces.length).toBe(1);
Expand All @@ -123,6 +132,8 @@ describe('packager tests', () => {
});

it.skip('combined packages search', async () => {
await ensureDeepClientCreated();

const packages1 = await combinedPackagesSearch("@deep-foundation/pow");
console.log(JSON.stringify(packages1, null, 2));
expect(packages1.installedPackages.length).toBe(1);
Expand All @@ -138,6 +149,8 @@ describe('packager tests', () => {
});

it.skip('npm package', async () => {
await ensureDeepClientCreated();

const packageName = '@deep-foundation/pow';
const data = await getPackageFromNpm(packageName) as any;
console.log(JSON.stringify(data, null, 2));
Expand All @@ -148,10 +161,14 @@ describe('packager tests', () => {
});

it.skip('deep.linkId bug', async () => {
await ensureDeepClientCreated();

expect(deep.linkId).toBe(config.userId);
});

it.skip('GPT prompt', async () => {
await ensureDeepClientCreated();

const userId = config.userId;

// Create a node-link type with name Example1.
Expand Down Expand Up @@ -254,6 +271,8 @@ describe('packager tests', () => {
});

it.skip('GPT result 1', async () => {
await ensureDeepClientCreated();

const userId = config.userId;

// Create Vehicle type.
Expand All @@ -270,6 +289,8 @@ describe('packager tests', () => {
});

it.skip('GPT result 2', async () => {
await ensureDeepClientCreated();

const userId = config.userId;

// Create a node-link type with name Vehicle.
Expand Down

0 comments on commit 1a5f319

Please sign in to comment.