add basic categories to tests

This commit is contained in:
mrjvs 2024-01-17 17:18:12 +01:00
parent b3212bd327
commit 9798659af8
15 changed files with 71 additions and 45 deletions

26
package-lock.json generated
View File

@ -10,6 +10,7 @@
"license": "MIT",
"dependencies": {
"cheerio": "^1.0.0-rc.12",
"cross-env": "^7.0.3",
"crypto-js": "^4.1.1",
"form-data": "^4.0.0",
"iso-639-1": "^3.1.0",
@ -1794,6 +1795,23 @@
"dev": true,
"license": "MIT"
},
"node_modules/cross-env": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
"integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==",
"dependencies": {
"cross-spawn": "^7.0.1"
},
"bin": {
"cross-env": "src/bin/cross-env.js",
"cross-env-shell": "src/bin/cross-env-shell.js"
},
"engines": {
"node": ">=10.14",
"npm": ">=6",
"yarn": ">=1"
}
},
"node_modules/cross-fetch": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz",
@ -1805,7 +1823,6 @@
},
"node_modules/cross-spawn": {
"version": "7.0.3",
"dev": true,
"license": "MIT",
"dependencies": {
"path-key": "^3.1.0",
@ -3585,8 +3602,7 @@
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"dev": true
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
},
"node_modules/iso-639-1": {
"version": "3.1.0",
@ -4277,7 +4293,6 @@
},
"node_modules/path-key": {
"version": "3.1.1",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@ -4785,7 +4800,6 @@
},
"node_modules/shebang-command": {
"version": "2.0.0",
"dev": true,
"license": "MIT",
"dependencies": {
"shebang-regex": "^3.0.0"
@ -4796,7 +4810,6 @@
},
"node_modules/shebang-regex": {
"version": "3.0.0",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@ -5774,7 +5787,6 @@
},
"node_modules/which": {
"version": "2.0.2",
"dev": true,
"license": "ISC",
"dependencies": {
"isexe": "^2.0.0"

View File

@ -38,6 +38,7 @@
"cli": "ts-node ./src/dev-cli/index.ts",
"test": "vitest run",
"test:watch": "vitest",
"test:providers": "cross-env MW_TEST_PROVIDERS=true vitest run",
"test:integration": "node ./tests/cjs && node ./tests/esm && node ./tests/browser",
"test:coverage": "vitest run --coverage",
"lint": "eslint --ext .ts,.js src/",
@ -78,6 +79,7 @@
},
"dependencies": {
"cheerio": "^1.0.0-rc.12",
"cross-env": "^7.0.3",
"crypto-js": "^4.1.1",
"form-data": "^4.0.0",
"iso-639-1": "^3.1.0",

View File

@ -0,0 +1,7 @@
import { describe, expect, it } from "vitest";
describe('abc', () => {
it('should do thing', () => {
expect(true).toBe(false);
})
})

View File

@ -2,7 +2,7 @@
import { vi } from 'vitest';
import { gatherAllEmbeds, gatherAllSources } from '@/providers/all';
import { Embed, Sourcerer } from '@/providers/base';
import { makeEmbed, makeSourcerer } from '@/providers/base';
export function makeProviderMocks() {
const embedsMock = vi.fn<Parameters<typeof gatherAllEmbeds>, ReturnType<typeof gatherAllEmbeds>>();
@ -13,104 +13,104 @@ export function makeProviderMocks() {
};
}
const sourceA = {
const sourceA = makeSourcerer({
id: 'a',
name: 'A',
rank: 1,
disabled: false,
flags: [],
} as Sourcerer;
const sourceB = {
});
const sourceB = makeSourcerer({
id: 'b',
name: 'B',
rank: 2,
disabled: false,
flags: [],
} as Sourcerer;
const sourceCDisabled = {
});
const sourceCDisabled = makeSourcerer({
id: 'c',
name: 'C',
rank: 3,
disabled: true,
flags: [],
} as Sourcerer;
const sourceAHigherRank = {
});
const sourceAHigherRank = makeSourcerer({
id: 'a',
name: 'A',
rank: 100,
disabled: false,
flags: [],
} as Sourcerer;
const sourceGSameRankAsA = {
});
const sourceGSameRankAsA = makeSourcerer({
id: 'g',
name: 'G',
rank: 1,
disabled: false,
flags: [],
} as Sourcerer;
const fullSourceYMovie = {
});
const fullSourceYMovie = makeSourcerer({
id: 'y',
name: 'Y',
rank: 105,
scrapeMovie: vi.fn(),
flags: [],
} as Sourcerer;
const fullSourceYShow = {
});
const fullSourceYShow = makeSourcerer({
id: 'y',
name: 'Y',
rank: 105,
scrapeShow: vi.fn(),
flags: [],
} as Sourcerer;
const fullSourceZBoth = {
});
const fullSourceZBoth = makeSourcerer({
id: 'z',
name: 'Z',
rank: 106,
scrapeMovie: vi.fn(),
scrapeShow: vi.fn(),
flags: [],
} as Sourcerer;
});
const embedD = {
const embedD = makeEmbed({
id: 'd',
rank: 4,
disabled: false,
} as Embed;
const embedA = {
} as any);
const embedA = makeEmbed({
id: 'a',
rank: 5,
disabled: false,
} as Embed;
const embedEDisabled = {
} as any);
const embedEDisabled = makeEmbed({
id: 'e',
rank: 6,
disabled: true,
} as Embed;
const embedDHigherRank = {
} as any);
const embedDHigherRank = makeEmbed({
id: 'd',
rank: 4000,
disabled: false,
} as Embed;
const embedFSameRankAsA = {
} as any);
const embedFSameRankAsA = makeEmbed({
id: 'f',
rank: 5,
disabled: false,
} as Embed;
const embedHSameRankAsSourceA = {
} as any);
const embedHSameRankAsSourceA = makeEmbed({
id: 'h',
rank: 1,
disabled: false,
} as Embed;
const fullEmbedX = {
} as any);
const fullEmbedX = makeEmbed({
id: 'x',
name: 'X',
rank: 104,
} as Embed;
const fullEmbedZ = {
} as any);
const fullEmbedZ = makeEmbed({
id: 'z',
name: 'Z',
rank: 109,
} as Embed;
} as any);
export const mockSources = {
sourceA,

View File

@ -1,4 +1,4 @@
import { mockEmbeds, mockSources } from '@/__test__/providerTests';
import { mockEmbeds, mockSources } from '../providerTests';
import { getBuiltinEmbeds, getBuiltinSources } from '@/entrypoint/providers';
import { FeatureMap } from '@/entrypoint/utils/targets';
import { getProviders } from '@/providers/get';

View File

@ -1,4 +1,4 @@
import { mockEmbeds, mockSources } from '@/__test__/providerTests';
import { mockEmbeds, mockSources } from '../providerTests.ts';
import { makeProviders } from '@/entrypoint/declare';
import { targets } from '@/entrypoint/utils/targets';
import { afterEach, describe, expect, it, vi } from 'vitest';

View File

@ -1,4 +1,4 @@
import { mockEmbeds, mockSources } from '@/__test__/providerTests';
import { mockEmbeds, mockSources } from '../providerTests.ts';
import { makeProviders } from '@/entrypoint/declare';
import { targets } from '@/entrypoint/utils/targets';
import { afterEach, describe, expect, it, vi } from 'vitest';

View File

@ -5,7 +5,9 @@ const dts = require('vite-plugin-dts');
const pkg = require('./package.json');
const fs = require('fs/promises');
const main = path.resolve(__dirname, 'src/index.ts');
const shouldTestProviders = process.env.MW_TEST_PROVIDERS === "true"
let tests = ['src/__test__/standard/**/*.test.ts'];
if (shouldTestProviders) tests = ['src/__test__/providers/**/*.test.ts']
module.exports = defineConfig({
plugins: [
@ -34,10 +36,13 @@ module.exports = defineConfig({
outDir: 'lib',
lib: {
entry: main,
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'index',
fileName: 'index',
formats: ['umd', 'es'],
},
},
test: {
include: tests
}
});