-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lvcq
committed
Oct 30, 2024
1 parent
3ef95b4
commit 644814c
Showing
4 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
const core = require('./XtPlayer'); | ||
|
||
|
||
window.XtPlayer = core; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 导入待测函数 | ||
const XtPlayer = require('./tPlayer/src/js/XtPlayer'); | ||
|
||
describe('XtPlayer 构造函数测试', () => { | ||
let player; | ||
|
||
beforeEach(() => { | ||
// 创建一个模拟的 DOM 元素 | ||
const element = document.createElement('div'); | ||
// 模拟选项 | ||
const options = { | ||
// 可以添加其他相关选项进行测试 | ||
}; | ||
|
||
player = new XtPlayer(element, options); | ||
}); | ||
|
||
test('构造函数初始化属性', () => { | ||
expect(player.info.author).toEqual('幻音い'); | ||
expect(player.info.website).toEqual('https://www.acgxt.com'); | ||
expect(player.info.version).toEqual('1.2.1'); | ||
expect(player.info.project).toEqual('https://xtplayer.acgxt.com'); | ||
expect(player.el).toBeDefined(); | ||
expect(player._build).toBeDefined(); | ||
expect(player._video).toBeDefined(); | ||
expect(player._options).toEqual(options); | ||
expect(player._isInit).toEqual(false); | ||
}); | ||
|
||
test('初始化时设置加载状态', () => { | ||
expect(player.setLoading).toHaveBeenCalledTimes(1); | ||
expect(player.setLoading).toHaveBeenCalledWith(true); | ||
}); | ||
|
||
test('初始化视频相关操作', () => { | ||
expect(player._initVideo).toHaveBeenCalledTimes(1); | ||
expect(player._initEvent).toHaveBeenCalledTimes(1); | ||
expect(player._initKey).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |