mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-20 16:43:53 +01:00
Fix tests and lint
This commit is contained in:
29
.github/workflows/ci.yaml
vendored
29
.github/workflows/ci.yaml
vendored
@@ -14,28 +14,11 @@ jobs:
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
|
||||
- run: npm install
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
- run: npm test
|
||||
working-directory: npm/cli-darwin-arm64
|
||||
env: { NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}" }
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
|
||||
- name: Publish @yaakapp/cli-darwin-x64
|
||||
run: npm publish --provenance --access public
|
||||
working-directory: npm/cli-darwin-x64
|
||||
env: { NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}" }
|
||||
|
||||
- name: Publish @yaakapp/cli-linux-x64
|
||||
run: npm publish --provenance --access public
|
||||
working-directory: npm/cli-linux-x64
|
||||
env: { NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}" }
|
||||
|
||||
- name: Publish @yaakapp/cli-win32-x64
|
||||
run: npm publish --provenance --access public
|
||||
working-directory: npm/cli-win32-x64
|
||||
env: { NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}" }
|
||||
|
||||
- name: Publish @yaakapp/cli
|
||||
run: npm publish --provenance --access public
|
||||
working-directory: npm/cli
|
||||
env: { NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}" }
|
||||
- name: Run Tests
|
||||
run: npm test
|
||||
|
||||
14
package-lock.json
generated
14
package-lock.json
generated
@@ -7,6 +7,7 @@
|
||||
"name": "@yaakapp/plugins",
|
||||
"devDependencies": {
|
||||
"jsonpath": "^1.1.1",
|
||||
"typescript": "^5.5.2",
|
||||
"vitest": "^2.0.4"
|
||||
}
|
||||
},
|
||||
@@ -1408,6 +1409,19 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.6.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz",
|
||||
"integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/underscore": {
|
||||
"version": "1.12.1",
|
||||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz",
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "node scripts/build-plugins.cjs",
|
||||
"test": "vitest run"
|
||||
"test": "vitest run",
|
||||
"lint": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jsonpath": "^1.1.1",
|
||||
"vitest": "^2.0.4"
|
||||
"vitest": "^2.0.4",
|
||||
"typescript": "^5.5.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
import { Context } from '@yaakapp/api';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { pluginHookImport } from '../src';
|
||||
|
||||
const ctx = {} as Context;
|
||||
|
||||
describe('importer-openapi', () => {
|
||||
const p = path.join(__dirname, 'fixtures');
|
||||
const fixtures = fs.readdirSync(p);
|
||||
|
||||
test('Skips invalid file', async () => {
|
||||
const imported = await pluginHookImport({}, '{}');
|
||||
const imported = await pluginHookImport(ctx, '{}');
|
||||
expect(imported).toBeUndefined();
|
||||
})
|
||||
|
||||
for (const fixture of fixtures) {
|
||||
test('Imports ' + fixture, async () => {
|
||||
const contents = fs.readFileSync(path.join(p, fixture), 'utf-8');
|
||||
const imported = await pluginHookImport({}, contents);
|
||||
const imported = await pluginHookImport(ctx, contents);
|
||||
expect(imported?.resources.workspaces).toEqual([
|
||||
expect.objectContaining({
|
||||
name: 'Swagger Petstore - OpenAPI 3.0',
|
||||
|
||||
@@ -1,29 +1,19 @@
|
||||
import { Context, Model } from '@yaakapp/api';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
import { Model } from '../../../src-web/lib/models';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { pluginHookImport } from '../src';
|
||||
|
||||
let originalRandom = Math.random;
|
||||
const ctx = {} as Context;
|
||||
|
||||
describe('importer-postman', () => {
|
||||
beforeEach(() => {
|
||||
let i = 0;
|
||||
// Psuedo-random number generator to ensure consistent ID generation
|
||||
Math.random = vi.fn(() => ((i++ * 1000) % 133) / 100);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
Math.random = originalRandom;
|
||||
});
|
||||
|
||||
const p = path.join(__dirname, 'fixtures');
|
||||
const fixtures = fs.readdirSync(p);
|
||||
|
||||
for (const fixture of fixtures) {
|
||||
test('Imports ' + fixture, () => {
|
||||
const contents = fs.readFileSync(path.join(p, fixture), 'utf-8');
|
||||
const imported = pluginHookImport({}, contents);
|
||||
const imported = pluginHookImport(ctx, contents);
|
||||
const folder0 = newId('folder');
|
||||
const folder1 = newId('folder');
|
||||
expect(imported).toEqual({
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Context } from '@yaakapp/api';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { pluginHookImport } from '../src';
|
||||
|
||||
const ctx = {};
|
||||
const ctx = {} as Context;
|
||||
|
||||
describe('importer-yaak', () => {
|
||||
test('Skips invalid imports', () => {
|
||||
|
||||
Reference in New Issue
Block a user