-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from l-hammer/block_show_support_args
block show track support arguments
- Loading branch information
Showing
4 changed files
with
58 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "v-track", | ||
"version": "0.8.5", | ||
"version": "0.8.6", | ||
"description": "一个基于Vue指令的埋点插件", | ||
"author": "LHammer <[email protected]>", | ||
"scripts": { | ||
|
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Created Date: 2019-08-05 | ||
* Author: 宋慧武 | ||
* ------ | ||
* Last Modified: Monday 2019-08-05 17:01:32 pm | ||
* Modified By: the developer formerly known as 宋慧武 at <[email protected]> | ||
* ------ | ||
* HISTORY: | ||
* ------ | ||
* Javascript will save your soul! | ||
*/ | ||
import Vue from "vue"; | ||
import VTrack from "@/"; | ||
import { mount, createLocalVue } from "@vue/test-utils"; | ||
import { mockParentNode, mockRect } from "../helper"; | ||
|
||
const localVue = createLocalVue(); | ||
const mockTrackAction = jest.fn((_, id) => id); | ||
const trackEvents = { | ||
18015: mockTrackAction | ||
}; | ||
const TrackShow = Vue.extend({ | ||
template: ` | ||
<div v-track:18015.show="{ id }" /> | ||
`, | ||
data() { | ||
return { | ||
id: "2019" | ||
}; | ||
} | ||
}); | ||
|
||
localVue.use(VTrack, { | ||
trackEvents | ||
}); | ||
|
||
jest.useFakeTimers(); | ||
|
||
describe("TrackShow", () => { | ||
it("确保DOM元素完全可见之后触发埋点,且至少间隔200ms执行一下", () => { | ||
const wrapper = mount(TrackShow, { localVue }); | ||
const vm = wrapper.vm; | ||
|
||
mockParentNode(vm.$el); | ||
mockRect(vm.$el); | ||
jest.runAllTimers(); | ||
|
||
expect(mockTrackAction.mock.results[0].value).toBe("2019"); | ||
expect(mockTrackAction).toBeCalledTimes(1); | ||
}); | ||
}); |