项目文件夹

文件
wehub-resource-sync 9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:39:48 +08:00

39 行
1.8 KiB
JavaScript

import { describe, expect, it } from 'vitest';
import { getRegistry } from '@jackwener/opencli/registry';
import { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';
import './job-detail.js';
const { normalizeJobUrl, decodeLinkedinRedirect, normalizeDetail } = await import('./job-detail.js').then((m) => m.__test__);
describe('linkedin job-detail adapter', () => {
const command = getRegistry().get('linkedin/job-detail');
it('registers command shape', () => {
expect(command).toBeDefined();
expect(command.strategy).toBe('cookie');
expect(command.browser).toBe(true);
expect(command.columns).toContain('description');
});
it('normalizes exact LinkedIn job urls', () => {
expect(normalizeJobUrl('https://www.linkedin.com/jobs/view/123456?x=1')).toBe('https://www.linkedin.com/jobs/search/?currentJobId=123456');
});
it('rejects non-job URLs', () => {
expect(() => normalizeJobUrl('https://www.linkedin.com/feed/')).toThrow(ArgumentError);
expect(() => normalizeJobUrl('https://example.com/jobs/view/1')).toThrow(ArgumentError);
});
it('decodes LinkedIn redirect apply urls', () => {
expect(decodeLinkedinRedirect('https://www.linkedin.com/redir/redirect/?url=https%3A%2F%2Fexample.com%2Fapply')).toBe('https://example.com/apply');
expect(decodeLinkedinRedirect('https://www.linkedin.com/redir/redirect/?url=javascript%3Aalert(1)')).toBe('');
expect(decodeLinkedinRedirect('javascript:alert(1)')).toBe('');
});
it('requires stable title in extracted detail', () => {
expect(() => normalizeDetail({ title: '' })).toThrow(CommandExecutionError);
expect(normalizeDetail({ title: 'Senior Engineer', company: 'Acme', description: 'Build things' }))
.toMatchObject({ title: 'Senior Engineer', company: 'Acme', description: 'Build things' });
});
});