|
|
|
@ -40,7 +40,6 @@ import { |
|
|
|
fetchJobDetail, |
|
|
|
fetchJobOverallScore, |
|
|
|
fetchPrivacyCenter, |
|
|
|
fetchSalaryData, |
|
|
|
} from '../api/api'; |
|
|
|
import type { |
|
|
|
AIInterviewData, |
|
|
|
@ -59,18 +58,17 @@ const hasLineStartingWith = (text: string, prefix: string) => |
|
|
|
|
|
|
|
describe('buildJobShareText(岗位详情分享)', () => { |
|
|
|
async function fixtures() { |
|
|
|
const [detail, overallScore, salaryData] = await Promise.all([ |
|
|
|
const [detail, overallScore] = await Promise.all([ |
|
|
|
fetchJobDetail('1'), |
|
|
|
fetchJobOverallScore('1'), |
|
|
|
fetchSalaryData('1'), |
|
|
|
]); |
|
|
|
return { detail, overallScore, salaryData }; |
|
|
|
return { detail, overallScore }; |
|
|
|
} |
|
|
|
|
|
|
|
it('首三行是「岗位|公司」「地点·经验·学历」「薪资区间」', async () => { |
|
|
|
const { detail, overallScore, salaryData } = await fixtures(); |
|
|
|
const { detail, overallScore } = await fixtures(); |
|
|
|
|
|
|
|
const lines = textOf(buildJobShareText(detail, overallScore, salaryData, 3)); |
|
|
|
const lines = textOf(buildJobShareText(detail, overallScore, 3)); |
|
|
|
|
|
|
|
expect(lines[0]).toBe(`${detail.positionName}|${detail.companyName}`); |
|
|
|
expect(lines[1]).toContain(detail.companyLocation); |
|
|
|
@ -80,58 +78,50 @@ describe('buildJobShareText(岗位详情分享)', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
it('薪资月数缺失时不输出「0薪」这种话', async () => { |
|
|
|
const { detail, overallScore, salaryData } = await fixtures(); |
|
|
|
const { detail, overallScore } = await fixtures(); |
|
|
|
|
|
|
|
const text = buildJobShareText({ ...detail, salaryMonths: 0 }, overallScore, salaryData, 3); |
|
|
|
const text = buildJobShareText({ ...detail, salaryMonths: 0 }, overallScore, 3); |
|
|
|
|
|
|
|
expect(text).not.toContain('0薪'); |
|
|
|
expect(hasLineStartingWith(text, '薪资 ')).toBe(true); |
|
|
|
}); |
|
|
|
|
|
|
|
it('没有评分数据时整行不出现(而不是输出 null 或 0 分)', async () => { |
|
|
|
const { detail, salaryData } = await fixtures(); |
|
|
|
const { detail } = await fixtures(); |
|
|
|
|
|
|
|
const text = buildJobShareText(detail, null, salaryData, 3); |
|
|
|
const text = buildJobShareText(detail, null, 3); |
|
|
|
|
|
|
|
expect(text).not.toContain('岗位综合评分'); |
|
|
|
expect(text).not.toContain('null'); |
|
|
|
expect(text).not.toContain('undefined'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('真实薪资样本数为 0 时不输出「真实薪资」(避免展示无依据的数据)', async () => { |
|
|
|
const { detail, overallScore, salaryData } = await fixtures(); |
|
|
|
|
|
|
|
const text = buildJobShareText(detail, overallScore, { ...salaryData, totalCount: 0 }, 3); |
|
|
|
|
|
|
|
expect(text).not.toContain('真实薪资'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('福利为空时不留下「福利:」这个空壳', async () => { |
|
|
|
const { detail, overallScore, salaryData } = await fixtures(); |
|
|
|
const { detail, overallScore } = await fixtures(); |
|
|
|
|
|
|
|
const text = buildJobShareText({ ...detail, benefits: [] }, overallScore, salaryData, 3); |
|
|
|
const text = buildJobShareText({ ...detail, benefits: [] }, overallScore, 3); |
|
|
|
|
|
|
|
expect(text).not.toContain('福利:'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('评价数为 0 时说「暂无员工评价」,不说「员工评价 0 条」', async () => { |
|
|
|
const { detail, overallScore, salaryData } = await fixtures(); |
|
|
|
const { detail, overallScore } = await fixtures(); |
|
|
|
|
|
|
|
const text = buildJobShareText(detail, overallScore, salaryData, 0); |
|
|
|
const text = buildJobShareText(detail, overallScore, 0); |
|
|
|
|
|
|
|
expect(text).toContain('暂无员工评价'); |
|
|
|
expect(text).not.toContain('员工评价 0 条'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('评价数大于 0 时给出条数', async () => { |
|
|
|
const { detail, overallScore, salaryData } = await fixtures(); |
|
|
|
const { detail, overallScore } = await fixtures(); |
|
|
|
|
|
|
|
expect(buildJobShareText(detail, overallScore, salaryData, 3)).toContain('员工评价 3 条'); |
|
|
|
expect(buildJobShareText(detail, overallScore, 3)).toContain('员工评价 3 条'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('以签名收尾', async () => { |
|
|
|
const { detail, overallScore, salaryData } = await fixtures(); |
|
|
|
expect(buildJobShareText(detail, overallScore, salaryData, 3)).toContain(SIGNATURE); |
|
|
|
const { detail, overallScore } = await fixtures(); |
|
|
|
expect(buildJobShareText(detail, overallScore, 3)).toContain(SIGNATURE); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|