我有一个功能,可以设置文档标题和描述,并且我需要编写一个测试。
函数.js
const setMetaTags = function() {
document.title = "brandName";
const description = document.querySelector('meta[name="description"]');
if (description) {
description.setAttribute('content', 'text text text text');
}
};
Run Code Online (Sandbox Code Playgroud)
测试.js
import sum from './func.js';
describe('testFunc', () => {
it('should test something', () => {
const spyFunc = setMetaTags();
Object.defineProperty(global.document, 'meta[name="description"]', { value: ?? });
});
});
Run Code Online (Sandbox Code Playgroud)
???
| 归档时间: |
|
| 查看次数: |
976 次 |
| 最近记录: |