add basic categories to tests
This commit is contained in:
parent
b3212bd327
commit
9798659af8
|
@ -10,6 +10,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio": "^1.0.0-rc.12",
|
"cheerio": "^1.0.0-rc.12",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"iso-639-1": "^3.1.0",
|
"iso-639-1": "^3.1.0",
|
||||||
|
@ -1794,6 +1795,23 @@
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"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": {
|
"node_modules/cross-fetch": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz",
|
||||||
|
@ -1805,7 +1823,6 @@
|
||||||
},
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.3",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
|
@ -3585,8 +3602,7 @@
|
||||||
"node_modules/isexe": {
|
"node_modules/isexe": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||||
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
|
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node_modules/iso-639-1": {
|
"node_modules/iso-639-1": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
|
@ -4277,7 +4293,6 @@
|
||||||
},
|
},
|
||||||
"node_modules/path-key": {
|
"node_modules/path-key": {
|
||||||
"version": "3.1.1",
|
"version": "3.1.1",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
|
@ -4785,7 +4800,6 @@
|
||||||
},
|
},
|
||||||
"node_modules/shebang-command": {
|
"node_modules/shebang-command": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"shebang-regex": "^3.0.0"
|
"shebang-regex": "^3.0.0"
|
||||||
|
@ -4796,7 +4810,6 @@
|
||||||
},
|
},
|
||||||
"node_modules/shebang-regex": {
|
"node_modules/shebang-regex": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
|
@ -5774,7 +5787,6 @@
|
||||||
},
|
},
|
||||||
"node_modules/which": {
|
"node_modules/which": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"isexe": "^2.0.0"
|
"isexe": "^2.0.0"
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
"cli": "ts-node ./src/dev-cli/index.ts",
|
"cli": "ts-node ./src/dev-cli/index.ts",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"test:watch": "vitest",
|
"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:integration": "node ./tests/cjs && node ./tests/esm && node ./tests/browser",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
"lint": "eslint --ext .ts,.js src/",
|
"lint": "eslint --ext .ts,.js src/",
|
||||||
|
@ -78,6 +79,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio": "^1.0.0-rc.12",
|
"cheerio": "^1.0.0-rc.12",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"iso-639-1": "^3.1.0",
|
"iso-639-1": "^3.1.0",
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
describe('abc', () => {
|
||||||
|
it('should do thing', () => {
|
||||||
|
expect(true).toBe(false);
|
||||||
|
})
|
||||||
|
})
|
|
@ -2,7 +2,7 @@
|
||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
import { gatherAllEmbeds, gatherAllSources } from '@/providers/all';
|
import { gatherAllEmbeds, gatherAllSources } from '@/providers/all';
|
||||||
import { Embed, Sourcerer } from '@/providers/base';
|
import { makeEmbed, makeSourcerer } from '@/providers/base';
|
||||||
|
|
||||||
export function makeProviderMocks() {
|
export function makeProviderMocks() {
|
||||||
const embedsMock = vi.fn<Parameters<typeof gatherAllEmbeds>, ReturnType<typeof gatherAllEmbeds>>();
|
const embedsMock = vi.fn<Parameters<typeof gatherAllEmbeds>, ReturnType<typeof gatherAllEmbeds>>();
|
||||||
|
@ -13,104 +13,104 @@ export function makeProviderMocks() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const sourceA = {
|
const sourceA = makeSourcerer({
|
||||||
id: 'a',
|
id: 'a',
|
||||||
name: 'A',
|
name: 'A',
|
||||||
rank: 1,
|
rank: 1,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
flags: [],
|
flags: [],
|
||||||
} as Sourcerer;
|
});
|
||||||
const sourceB = {
|
const sourceB = makeSourcerer({
|
||||||
id: 'b',
|
id: 'b',
|
||||||
name: 'B',
|
name: 'B',
|
||||||
rank: 2,
|
rank: 2,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
flags: [],
|
flags: [],
|
||||||
} as Sourcerer;
|
});
|
||||||
const sourceCDisabled = {
|
const sourceCDisabled = makeSourcerer({
|
||||||
id: 'c',
|
id: 'c',
|
||||||
name: 'C',
|
name: 'C',
|
||||||
rank: 3,
|
rank: 3,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
flags: [],
|
flags: [],
|
||||||
} as Sourcerer;
|
});
|
||||||
const sourceAHigherRank = {
|
const sourceAHigherRank = makeSourcerer({
|
||||||
id: 'a',
|
id: 'a',
|
||||||
name: 'A',
|
name: 'A',
|
||||||
rank: 100,
|
rank: 100,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
flags: [],
|
flags: [],
|
||||||
} as Sourcerer;
|
});
|
||||||
const sourceGSameRankAsA = {
|
const sourceGSameRankAsA = makeSourcerer({
|
||||||
id: 'g',
|
id: 'g',
|
||||||
name: 'G',
|
name: 'G',
|
||||||
rank: 1,
|
rank: 1,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
flags: [],
|
flags: [],
|
||||||
} as Sourcerer;
|
});
|
||||||
const fullSourceYMovie = {
|
const fullSourceYMovie = makeSourcerer({
|
||||||
id: 'y',
|
id: 'y',
|
||||||
name: 'Y',
|
name: 'Y',
|
||||||
rank: 105,
|
rank: 105,
|
||||||
scrapeMovie: vi.fn(),
|
scrapeMovie: vi.fn(),
|
||||||
flags: [],
|
flags: [],
|
||||||
} as Sourcerer;
|
});
|
||||||
const fullSourceYShow = {
|
const fullSourceYShow = makeSourcerer({
|
||||||
id: 'y',
|
id: 'y',
|
||||||
name: 'Y',
|
name: 'Y',
|
||||||
rank: 105,
|
rank: 105,
|
||||||
scrapeShow: vi.fn(),
|
scrapeShow: vi.fn(),
|
||||||
flags: [],
|
flags: [],
|
||||||
} as Sourcerer;
|
});
|
||||||
const fullSourceZBoth = {
|
const fullSourceZBoth = makeSourcerer({
|
||||||
id: 'z',
|
id: 'z',
|
||||||
name: 'Z',
|
name: 'Z',
|
||||||
rank: 106,
|
rank: 106,
|
||||||
scrapeMovie: vi.fn(),
|
scrapeMovie: vi.fn(),
|
||||||
scrapeShow: vi.fn(),
|
scrapeShow: vi.fn(),
|
||||||
flags: [],
|
flags: [],
|
||||||
} as Sourcerer;
|
});
|
||||||
|
|
||||||
const embedD = {
|
const embedD = makeEmbed({
|
||||||
id: 'd',
|
id: 'd',
|
||||||
rank: 4,
|
rank: 4,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
} as Embed;
|
} as any);
|
||||||
const embedA = {
|
const embedA = makeEmbed({
|
||||||
id: 'a',
|
id: 'a',
|
||||||
rank: 5,
|
rank: 5,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
} as Embed;
|
} as any);
|
||||||
const embedEDisabled = {
|
const embedEDisabled = makeEmbed({
|
||||||
id: 'e',
|
id: 'e',
|
||||||
rank: 6,
|
rank: 6,
|
||||||
disabled: true,
|
disabled: true,
|
||||||
} as Embed;
|
} as any);
|
||||||
const embedDHigherRank = {
|
const embedDHigherRank = makeEmbed({
|
||||||
id: 'd',
|
id: 'd',
|
||||||
rank: 4000,
|
rank: 4000,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
} as Embed;
|
} as any);
|
||||||
const embedFSameRankAsA = {
|
const embedFSameRankAsA = makeEmbed({
|
||||||
id: 'f',
|
id: 'f',
|
||||||
rank: 5,
|
rank: 5,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
} as Embed;
|
} as any);
|
||||||
const embedHSameRankAsSourceA = {
|
const embedHSameRankAsSourceA = makeEmbed({
|
||||||
id: 'h',
|
id: 'h',
|
||||||
rank: 1,
|
rank: 1,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
} as Embed;
|
} as any);
|
||||||
const fullEmbedX = {
|
const fullEmbedX = makeEmbed({
|
||||||
id: 'x',
|
id: 'x',
|
||||||
name: 'X',
|
name: 'X',
|
||||||
rank: 104,
|
rank: 104,
|
||||||
} as Embed;
|
} as any);
|
||||||
const fullEmbedZ = {
|
const fullEmbedZ = makeEmbed({
|
||||||
id: 'z',
|
id: 'z',
|
||||||
name: 'Z',
|
name: 'Z',
|
||||||
rank: 109,
|
rank: 109,
|
||||||
} as Embed;
|
} as any);
|
||||||
|
|
||||||
export const mockSources = {
|
export const mockSources = {
|
||||||
sourceA,
|
sourceA,
|
|
@ -1,4 +1,4 @@
|
||||||
import { mockEmbeds, mockSources } from '@/__test__/providerTests';
|
import { mockEmbeds, mockSources } from '../providerTests';
|
||||||
import { getBuiltinEmbeds, getBuiltinSources } from '@/entrypoint/providers';
|
import { getBuiltinEmbeds, getBuiltinSources } from '@/entrypoint/providers';
|
||||||
import { FeatureMap } from '@/entrypoint/utils/targets';
|
import { FeatureMap } from '@/entrypoint/utils/targets';
|
||||||
import { getProviders } from '@/providers/get';
|
import { getProviders } from '@/providers/get';
|
|
@ -1,4 +1,4 @@
|
||||||
import { mockEmbeds, mockSources } from '@/__test__/providerTests';
|
import { mockEmbeds, mockSources } from '../providerTests.ts';
|
||||||
import { makeProviders } from '@/entrypoint/declare';
|
import { makeProviders } from '@/entrypoint/declare';
|
||||||
import { targets } from '@/entrypoint/utils/targets';
|
import { targets } from '@/entrypoint/utils/targets';
|
||||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
@ -1,4 +1,4 @@
|
||||||
import { mockEmbeds, mockSources } from '@/__test__/providerTests';
|
import { mockEmbeds, mockSources } from '../providerTests.ts';
|
||||||
import { makeProviders } from '@/entrypoint/declare';
|
import { makeProviders } from '@/entrypoint/declare';
|
||||||
import { targets } from '@/entrypoint/utils/targets';
|
import { targets } from '@/entrypoint/utils/targets';
|
||||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
@ -5,7 +5,9 @@ const dts = require('vite-plugin-dts');
|
||||||
const pkg = require('./package.json');
|
const pkg = require('./package.json');
|
||||||
const fs = require('fs/promises');
|
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({
|
module.exports = defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
|
@ -34,10 +36,13 @@ module.exports = defineConfig({
|
||||||
outDir: 'lib',
|
outDir: 'lib',
|
||||||
|
|
||||||
lib: {
|
lib: {
|
||||||
entry: main,
|
entry: path.resolve(__dirname, 'src/index.ts'),
|
||||||
name: 'index',
|
name: 'index',
|
||||||
fileName: 'index',
|
fileName: 'index',
|
||||||
formats: ['umd', 'es'],
|
formats: ['umd', 'es'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
test: {
|
||||||
|
include: tests
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue