1 | import MeasurementFramework, {userTrail} from "../index"
|
2 | import {greater, incrementEventValue} from "../lib/userTrail"
|
3 |
|
4 | describe("User Trail Test Script", function () {
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | const FIRST_TEST_EVENT = "First Test Event"
|
10 | const SECOND_TEST_EVENT = "Second Test Event"
|
11 |
|
12 | const test_events = [FIRST_TEST_EVENT, SECOND_TEST_EVENT]
|
13 | userTrail(test_events, [
|
14 | function () {
|
15 | return "Test Funnel Stage"
|
16 | },
|
17 | function () {
|
18 | if (greater(FIRST_TEST_EVENT, 1)) {
|
19 | return "Next Level Funnel Stage"
|
20 | } else {
|
21 | return false;
|
22 | }
|
23 | }
|
24 | ])
|
25 | var initial_state = MeasurementFramework.init()
|
26 |
|
27 | it("should set initial funnel stage", function () {
|
28 |
|
29 |
|
30 | expect(initial_state.funnelStage()).toEqual("Test Funnel Stage")
|
31 | expect(initial_state.userTrail()).toEqual({
|
32 | FirstTestEvent: 0,
|
33 | SecondTestEvent: 0
|
34 | })
|
35 | incrementEventValue(FIRST_TEST_EVENT)
|
36 | incrementEventValue(FIRST_TEST_EVENT)
|
37 | expect(initial_state.userTrail()).toEqual({
|
38 | FirstTestEvent: 2,
|
39 | SecondTestEvent: 0
|
40 | })
|
41 | expect(initial_state.funnelStage()).toEqual("Next Level Funnel Stage")
|
42 | })
|
43 |
|
44 | it("should not load extra framework code", function () {
|
45 | var new_initial_state = MeasurementFramework.init()
|
46 | expect(new_initial_state).toEqual(undefined)
|
47 | })
|
48 |
|
49 | it("should accept changes in events", function () {
|
50 |
|
51 | })
|
52 | }) |
\ | No newline at end of file |