UNPKG

1.91 kBJavaScriptView Raw
1import MeasurementFramework, {userTrail} from "../index"
2import {greater, incrementEventValue} from "../lib/userTrail"
3
4describe("User Trail Test Script", function () {
5 // The 'it' function of Jasmine defined an individual tests. The first argument is
6 // a description of the tests that's appended to the module name. Because a module name
7 // is typically a noun, like the name of the function being tested, the description for
8 // an individual tests is typically written in an action-data format.
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 // Check the results; "expect" and toEqual are Jasmine methods.
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