spyne 0.14.8 → 0.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +2 -2
- package/karma.conf.js +27 -20
- package/lib/channel-action-filter.test.2418910233.js +20 -0
- package/lib/channel-dom.test.1490741340.js +20 -0
- package/lib/channel-fetch-util.test.3681936279.js +20 -0
- package/lib/channel-fetch.test.380764798.js +20 -0
- package/lib/channel-payload-class.test.2325155642.js +20 -0
- package/lib/channel-payload-filter.test.1598505124.js +20 -0
- package/lib/channel-route.test.921296320.js +20 -0
- package/lib/channel-stream-item.test.159699696.js +20 -0
- package/lib/channel-ui.test.291129654.js +20 -0
- package/lib/channel-util-dom.test.181212370.js +20 -0
- package/lib/channel.test.706832124.js +20 -0
- package/lib/commons.js +50363 -0
- package/lib/dom-el-selectors.test.3296414834.js +20 -0
- package/lib/dom-el-template.test.1459850380.js +20 -0
- package/lib/dom-el.test.2449130808.js +20 -0
- package/lib/frp-tools.test.1620088187.js +20 -0
- package/lib/import.test.723835576.js +20 -0
- package/lib/index.test.2146503294.js +20 -0
- package/lib/plugins-methods.test.3482246428.js +20 -0
- package/lib/route-utils.test.2932649409.js +20 -0
- package/lib/runtime.js +174 -0
- package/lib/spyne-app-properties.test.485192211.js +20 -0
- package/lib/spyne-app.test.4150724251.js +20 -0
- package/lib/spyne-plugin.test.3993976219.js +20 -0
- package/lib/spyne.js +15477 -18467
- package/lib/spyne.min.js +2 -12
- package/lib/spyne.min.js.LICENSE.txt +10 -0
- package/lib/url-utils.test.3668806082.js +20 -0
- package/lib/view-stream-broadcaster.test.2534955231.js +20 -0
- package/lib/view-stream-enhancer-loader.test.3395418180.js +20 -0
- package/lib/view-stream-enhancer.test.1043626253.js +20 -0
- package/lib/view-stream.test.1765314964.js +20 -0
- package/package.json +37 -65
- package/src/spyne/channels/channel-fetch-class.js +24 -1
- package/src/spyne/channels/channel-payload-class.js +102 -11
- package/src/spyne/channels/channel-proxy.js +6 -4
- package/src/spyne/channels/channel.js +66 -6
- package/src/spyne/channels/channels-config.js +2 -2
- package/src/spyne/channels/{channels-delegator.js → channels-map.js} +37 -21
- package/src/spyne/channels/spyne-channel-lifecycle.js +1 -1
- package/src/spyne/channels/spyne-channel-route.js +95 -15
- package/src/spyne/channels/spyne-channel-ui.js +1 -0
- package/src/spyne/channels/spyne-channel-window.js +60 -20
- package/src/spyne/spyne-app.js +181 -0
- package/src/spyne/spyne-plugins.js +146 -0
- package/src/spyne/spyne.js +11 -139
- package/src/spyne/utils/channel-fetch-util.js +1 -1
- package/src/spyne/utils/channel-payload-filter.js +166 -30
- package/src/spyne/utils/frp-tools.js +21 -1
- package/src/spyne/utils/mixins/base-streams-mixins.js +1 -0
- package/src/spyne/utils/spyne-app-properties.js +213 -0
- package/src/spyne/utils/spyne-logger.js +18 -0
- package/src/spyne/utils/spyne-plugins-methods.js +105 -0
- package/src/spyne/utils/spyne-scroll-lock.js +95 -0
- package/src/spyne/utils/spyne-utils-channel-route-url.js +2 -1
- package/src/spyne/utils/spyne-utils-channel-route.js +3 -1
- package/src/spyne/utils/spyne-utils-channel-window.js +2 -2
- package/src/spyne/views/dom-element-template.js +52 -23
- package/src/spyne/views/dom-element.js +11 -2
- package/src/spyne/views/view-stream-broadcaster.js +3 -3
- package/src/spyne/views/view-stream-payload.js +76 -15
- package/src/spyne/views/view-stream-selector.js +2 -2
- package/src/spyne/views/view-stream.js +219 -115
- package/src/tests/channels/channel-fetch.test.js +102 -0
- package/src/tests/channels/channel-payload-class.test.js +149 -0
- package/src/tests/channels/channel-payload-filter.test.js +298 -0
- package/src/tests/channels/channel-route.test.js +76 -1
- package/src/tests/channels/channel-stream-item.test.js +3 -2
- package/src/tests/channels/channel.test.js +38 -0
- package/src/tests/channels/route-utils.test.js +1 -1
- package/src/tests/index.js +0 -1
- package/src/tests/index.test.js +6 -0
- package/src/tests/mocks/channel-payload-data.js +93 -1
- package/src/tests/mocks/msf-user-data-small.json +4103 -0
- package/src/tests/mocks/msf-user-data.json +47035 -0
- package/src/tests/mocks/utils-data.js +20 -2
- package/src/tests/spyne-app.test.js +27 -0
- package/src/tests/spyne-plugin.test.js +49 -0
- package/src/tests/utils/channel-action-filter.test.js +22 -11
- package/src/tests/utils/channel-data-packet-generator.unused.js +119 -0
- package/src/tests/utils/plugins-methods.test.js +103 -0
- package/src/tests/utils/spyne-app-properties.test.js +11 -0
- package/src/tests/views/dom-el-selectors.test.js +1 -1
- package/webpack.config.js +30 -15
- package/lib/spyne.js.map +0 -1
- package/src/spyne/utils/viewstream-dom-utils.js +0 -8
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
const {expect, assert} = require('chai');
|
|
2
|
+
const MSFData = require('../mocks/msf-user-data.json');
|
|
3
|
+
const MSFDataSmall = require('../mocks/msf-user-data-small.json');
|
|
4
|
+
import {SpyneApp, Channel} from '../../spyne/spyne';
|
|
5
|
+
import {ChannelPayload} from '../../spyne/channels/channel-payload-class'
|
|
6
|
+
import {ChannelPayloadToTestFilters} from '../mocks/channel-payload-data';
|
|
7
|
+
import {ChannelPayloadFilter} from '../../spyne/utils/channel-payload-filter';
|
|
8
|
+
const R = require('ramda');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
describe('should test Channel Payload Class', () => {
|
|
12
|
+
const {srcElement, event, action} = ChannelPayloadToTestFilters;
|
|
13
|
+
const channelName = "CHANNEL_ROUTE";
|
|
14
|
+
SpyneApp.init({debug:true}, true);
|
|
15
|
+
|
|
16
|
+
before(()=>{
|
|
17
|
+
const spyneApp = SpyneApp;
|
|
18
|
+
spyneApp.registerChannel(new Channel("CHANNEL_MYCHANNEL"))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('should freeze the payload', ()=>{
|
|
24
|
+
const channnelPayload = new ChannelPayload(channelName, action, MSFData, srcElement, event)
|
|
25
|
+
const {payload} = channnelPayload;
|
|
26
|
+
let {section} = payload.content;
|
|
27
|
+
let payloadIsFrozen = false;
|
|
28
|
+
try{
|
|
29
|
+
section.header = 'new copy';
|
|
30
|
+
} catch(e){
|
|
31
|
+
payloadIsFrozen = true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//console.log('payload is ', {payloadIsFrozen, section});
|
|
35
|
+
|
|
36
|
+
expect(payloadIsFrozen).to.be.true;
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('should freeze the uintarray', ()=>{
|
|
40
|
+
const payloadObj = {
|
|
41
|
+
myArray: new Uint8Array(0),
|
|
42
|
+
myDataView: new DataView(new ArrayBuffer(32))
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const channnelPayload = new ChannelPayload(channelName, action, payloadObj, srcElement, event)
|
|
47
|
+
const {payload} = channnelPayload;
|
|
48
|
+
const {myArray} = payload;
|
|
49
|
+
//console.log('payload is ', {payloadIsFrozen, section});
|
|
50
|
+
// console.log('payload is ',typeof(myArray));
|
|
51
|
+
|
|
52
|
+
expect(myArray).to.exist
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/* it('should clone and unfreeze the props payload', ()=>{
|
|
57
|
+
|
|
58
|
+
const channnelPayload = new ChannelPayload(channelName, action, MSFData, srcElement, event)
|
|
59
|
+
const {payload, channel} = channnelPayload.props();
|
|
60
|
+
let {section} = payload.content;
|
|
61
|
+
let payloadPropsIsClone = true;
|
|
62
|
+
try{
|
|
63
|
+
section.header = 'new copy';
|
|
64
|
+
} catch(e){
|
|
65
|
+
payloadPropsIsClone = false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//console.log('payload props is ', {payloadPropsIsClone,channel, section});
|
|
69
|
+
|
|
70
|
+
expect(payloadPropsIsClone).to.be.true;
|
|
71
|
+
})
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
it('should clone and unfreeze the deconstructed props payload', ()=>{
|
|
76
|
+
const channnelPayload = new ChannelPayload(channelName, action, MSFData, srcElement, event)
|
|
77
|
+
const {content} = channnelPayload.props();
|
|
78
|
+
let {section} = content;
|
|
79
|
+
let payloadPropsIsClone = true;
|
|
80
|
+
try{
|
|
81
|
+
section.header = 'new copy';
|
|
82
|
+
} catch(e){
|
|
83
|
+
payloadPropsIsClone = false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//console.log('payload props DECON is ', {payloadPropsIsClone, section});
|
|
87
|
+
|
|
88
|
+
expect(payloadPropsIsClone).to.be.true;
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
|
|
97
|
+
it('should clone and unfreeze the updated new prop', ()=>{
|
|
98
|
+
const channnelPayload = new ChannelPayload(channelName, action, MSFData, srcElement, event)
|
|
99
|
+
const {payload, channel} = channnelPayload.props();
|
|
100
|
+
let {section} = payload.content;
|
|
101
|
+
let payloadPropsIsClone = true;
|
|
102
|
+
try{
|
|
103
|
+
section.linksData = {foo:'bar'};
|
|
104
|
+
section.linksData = {foo:3};
|
|
105
|
+
} catch(e){
|
|
106
|
+
payloadPropsIsClone = false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//console.log('payload props2 is ', {payloadPropsIsClone,channel, section}, section.linksData);
|
|
110
|
+
|
|
111
|
+
expect(payloadPropsIsClone).to.be.true;
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
it('should run shell tests', () => {
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
const channnelPayload = new ChannelPayload(channelName, action, MSFData, srcElement, event)
|
|
121
|
+
const getVals = (e)=>{
|
|
122
|
+
let {payload} = e;
|
|
123
|
+
let {content} = payload;
|
|
124
|
+
//content['ubu']=4;
|
|
125
|
+
console.log('channel FROZE payload class ',content)
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const getValsFromProps = (e)=>{
|
|
130
|
+
console.time("propsPairs");
|
|
131
|
+
let {payload} = e.props();
|
|
132
|
+
console.timeEnd('propsPairs');
|
|
133
|
+
let {section} = payload.content;
|
|
134
|
+
|
|
135
|
+
// section['ubu']=4;
|
|
136
|
+
//console.log('channel PROPS payload class ',section)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
//getVals(channnelPayload);
|
|
140
|
+
//getValsFromProps(channnelPayload);
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
//console.log('channel payload class ',window.Spyne.config.channels[channelName].payload[1].payload.isDeepLink)
|
|
144
|
+
|
|
145
|
+
return true;
|
|
146
|
+
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
});
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
const {expect, assert} = require('chai');
|
|
2
|
+
import {ChannelPayloadToTestFilters} from '../mocks/channel-payload-data';
|
|
3
|
+
import {ChannelPayloadFilter} from '../../spyne/utils/channel-payload-filter';
|
|
4
|
+
import {ChannelPayload} from '../../spyne/channels/channel-payload-class';
|
|
5
|
+
import {SpyneApp} from '../../spyne/spyne';
|
|
6
|
+
|
|
7
|
+
const R = require('ramda');
|
|
8
|
+
describe('should test channel payload filters parameter configuration', () => {
|
|
9
|
+
|
|
10
|
+
beforeEach(function() {
|
|
11
|
+
// runs once before the first test in this block
|
|
12
|
+
window.Spyne = {
|
|
13
|
+
'config' : {
|
|
14
|
+
'debug' : false
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const testModeBool = true;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
it('should throw an error if cp filter is empty', () => {
|
|
24
|
+
const cpFilter = new ChannelPayloadFilter(undefined, undefined, undefined, true);
|
|
25
|
+
const {filtersAreEmpty} = cpFilter;
|
|
26
|
+
expect(filtersAreEmpty).to.be.true;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should filter selector string only', () => {
|
|
30
|
+
const cpFilter = new ChannelPayloadFilter('.my-selector');
|
|
31
|
+
expect(cpFilter).to.be.a('function');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should filter selector string only but with testMode param', () => {
|
|
35
|
+
const mySelector = '.my-selector';
|
|
36
|
+
const cpFilter = new ChannelPayloadFilter(mySelector, {}, false, testModeBool);
|
|
37
|
+
const {testMode, selector} = cpFilter;
|
|
38
|
+
const correctVals = {
|
|
39
|
+
selector: mySelector,
|
|
40
|
+
testMode: testModeBool
|
|
41
|
+
}
|
|
42
|
+
expect({testMode, selector}).to.deep.equal(correctVals);
|
|
43
|
+
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should filter selector string and testMode param in filters', () => {
|
|
47
|
+
const mySelector = '.my-selector';
|
|
48
|
+
const cpFilter = new ChannelPayloadFilter({selector:mySelector, testMode:testModeBool});
|
|
49
|
+
const {testMode, selector} = cpFilter;
|
|
50
|
+
const correctVals = {
|
|
51
|
+
selector: mySelector,
|
|
52
|
+
testMode: testModeBool
|
|
53
|
+
}
|
|
54
|
+
expect({testMode, selector}).to.deep.equal(correctVals);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should add debugLabel as prop in filters', () => {
|
|
58
|
+
const mySelector = '.my-selector';
|
|
59
|
+
const cpFilter = new ChannelPayloadFilter({debugLabel: 'myTest', testMode:testModeBool});
|
|
60
|
+
const {debugLabel} = cpFilter;
|
|
61
|
+
expect(debugLabel).to.equal('myTest');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should filter selector array only', () => {
|
|
65
|
+
const mySelector = ['.my-selector', '#my-button', '#my-el.tester > li'];
|
|
66
|
+
const cpFilter = new ChannelPayloadFilter(mySelector, {}, 'myTest', testModeBool);
|
|
67
|
+
const {testMode, selector} = cpFilter;
|
|
68
|
+
const correctVals = {
|
|
69
|
+
selector: mySelector,
|
|
70
|
+
testMode: testModeBool
|
|
71
|
+
}
|
|
72
|
+
expect({testMode, selector}).to.deep.equal(correctVals);
|
|
73
|
+
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
it('should filter selector array only as prop in filters', () => {
|
|
78
|
+
const mySelector = ['.my-selector', '#my-button', '#my-el.tester > li'];
|
|
79
|
+
const cpFilter = new ChannelPayloadFilter({selector:mySelector, debugLabel:'myTest', testMode: testModeBool }, 'notCorrect', false, false);
|
|
80
|
+
const {selector} = cpFilter;
|
|
81
|
+
expect(selector).to.equal(mySelector);
|
|
82
|
+
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
it('should filter properties only by multiple params', () => {
|
|
87
|
+
const myProps = {
|
|
88
|
+
action: "CHANNEL_MYCHANNEL_MAIN_EVENT",
|
|
89
|
+
myPropFn: (v)=>v>=30
|
|
90
|
+
}
|
|
91
|
+
const cpFilter = new ChannelPayloadFilter(undefined ,myProps, 'myval', true);
|
|
92
|
+
const myPropFn = R.path(['propFilters', 'myPropFn'], cpFilter);
|
|
93
|
+
expect(myPropFn).to.be.a('function');
|
|
94
|
+
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should filter properties only one object param', () => {
|
|
98
|
+
const myProps = {
|
|
99
|
+
action: "CHANNEL_MYCHANNEL_MAIN_EVENT",
|
|
100
|
+
myPropFn: (v)=>v>=30,
|
|
101
|
+
testMode: testModeBool
|
|
102
|
+
}
|
|
103
|
+
const cpFilter = new ChannelPayloadFilter(myProps);
|
|
104
|
+
const myPropFn = R.path(['propFilters', 'myPropFn'], cpFilter);
|
|
105
|
+
expect(myPropFn).to.be.a('function');
|
|
106
|
+
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
describe('should test channel payload filters boolean correctness', ()=>{
|
|
118
|
+
|
|
119
|
+
const liSel = "#xqdlqmr";
|
|
120
|
+
//const spyneApp = SpyneApp;
|
|
121
|
+
|
|
122
|
+
beforeEach(function(){
|
|
123
|
+
SpyneApp.init({debug:true}, true)
|
|
124
|
+
|
|
125
|
+
const liElTmpl = `
|
|
126
|
+
<li class="page-card page-menu-4-card" id="xqdlqmr" name="PageCardView" data-vsid="xqdlqmr"><a href="/menu-3/sub-menu-4" data-channel="ROUTE" data-event-prevent-default="true" data-topic-id="sub-menu-2" data-nav-level="2">
|
|
127
|
+
<dl class="card-content">
|
|
128
|
+
<dt class="card-image">
|
|
129
|
+
</dt>
|
|
130
|
+
<dd class="card-text">
|
|
131
|
+
<h2>SUB-MENU-2</h2>
|
|
132
|
+
<p>Lorem ipsum dolor sit </p>
|
|
133
|
+
</dd>
|
|
134
|
+
</dl>
|
|
135
|
+
</li>
|
|
136
|
+
`;
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
const ul = document.createElement('ul');
|
|
140
|
+
ul.innerHTML = liElTmpl;
|
|
141
|
+
document.body.appendChild(ul);
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
ChannelPayloadToTestFilters.srcElement.el = document.querySelector(liSel);
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
it('should find the selector string ', ()=>{
|
|
149
|
+
const cpFilter = new ChannelPayloadFilter(liSel);
|
|
150
|
+
const payloadBool = cpFilter(ChannelPayloadToTestFilters);
|
|
151
|
+
expect(payloadBool).to.be.true;
|
|
152
|
+
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
it('should detect the wrong selector string ', ()=>{
|
|
156
|
+
const cpFilter = new ChannelPayloadFilter("#mysel");
|
|
157
|
+
const payloadBool = cpFilter(ChannelPayloadToTestFilters);
|
|
158
|
+
expect(payloadBool).to.be.false;
|
|
159
|
+
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
it('should detect the selector from an array ', ()=>{
|
|
164
|
+
const cpFilter = new ChannelPayloadFilter([liSel, 'ul', 'li.test']);
|
|
165
|
+
const payloadBool = cpFilter(ChannelPayloadToTestFilters);
|
|
166
|
+
expect(payloadBool).to.be.true;
|
|
167
|
+
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it('should detect the wrong selector from an array ', ()=>{
|
|
171
|
+
const cpFilter = new ChannelPayloadFilter(['dd', 'dt', 'ul', 'li.test']);
|
|
172
|
+
const payloadBool = cpFilter(ChannelPayloadToTestFilters);
|
|
173
|
+
expect(payloadBool).to.be.false;
|
|
174
|
+
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('should find the selector from filters', ()=>{
|
|
178
|
+
const selector = liSel;
|
|
179
|
+
const cpFilter = new ChannelPayloadFilter({selector});
|
|
180
|
+
const payloadBool = cpFilter(ChannelPayloadToTestFilters);
|
|
181
|
+
|
|
182
|
+
expect(payloadBool).to.be.true;
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
it('should detect the selector from an array in filters ', ()=>{
|
|
187
|
+
const selector = ['dd', 'dt', 'ul',liSel, 'li.test'];
|
|
188
|
+
const cpFilter = new ChannelPayloadFilter({selector});
|
|
189
|
+
const payloadBool = cpFilter(ChannelPayloadToTestFilters);
|
|
190
|
+
expect(payloadBool).to.be.true;
|
|
191
|
+
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
it('should detect the selector from an array and destructured prop in filters ', ()=>{
|
|
197
|
+
const selector = ['dd', 'dt', 'ul',liSel, 'li.test'];
|
|
198
|
+
const pageId = (v)=>/menu-\d/.test(v);
|
|
199
|
+
const cpFilter = new ChannelPayloadFilter({selector, pageId});
|
|
200
|
+
const payloadBool = cpFilter(ChannelPayloadToTestFilters);
|
|
201
|
+
expect(payloadBool).to.be.true;
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
it('should detect the selector from an array and routeValue prop in filters ', ()=>{
|
|
207
|
+
const selector = ['dd', 'dt', 'ul', liSel, 'li.test'];
|
|
208
|
+
const re = /menu-\d/;
|
|
209
|
+
const payload = R.compose(R.test(re), R.path(['routeData', 'pageId']));
|
|
210
|
+
const cpFilter = new ChannelPayloadFilter({selector, payload});
|
|
211
|
+
const payloadBool = cpFilter(ChannelPayloadToTestFilters);
|
|
212
|
+
expect(payloadBool).to.be.true;
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
it('should detect the selector from an array and multiple props in filters ', ()=>{
|
|
219
|
+
const selector = [liSel, 'dd', 'dt', 'ul', 'li.test'];
|
|
220
|
+
const re = /menu-\d/;
|
|
221
|
+
const action = "CHANNEL_ROUTE_CHANGE_EVENT";
|
|
222
|
+
const payload = R.compose(R.test(re), R.path(['routeData', 'pageId']));
|
|
223
|
+
const cpFilter = new ChannelPayloadFilter({selector, payload, action});
|
|
224
|
+
const payloadBool = cpFilter(ChannelPayloadToTestFilters);
|
|
225
|
+
expect(payloadBool).to.be.true;
|
|
226
|
+
|
|
227
|
+
return true;
|
|
228
|
+
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
describe('it should test channel payload filter with data packer ',()=>{
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
const liSel = "#xqdlqmr";
|
|
241
|
+
|
|
242
|
+
beforeEach(function(){
|
|
243
|
+
SpyneApp.init({debug:true}, true)
|
|
244
|
+
|
|
245
|
+
const liElTmpl = `
|
|
246
|
+
<li class="page-card page-menu-4-card" id="xqdlqmr" name="PageCardView" data-vsid="xqdlqmr"><a href="/menu-3/sub-menu-4" data-channel="ROUTE" data-event-prevent-default="true" data-topic-id="sub-menu-2" data-nav-level="2">
|
|
247
|
+
<dl class="card-content">
|
|
248
|
+
<dt class="card-image">
|
|
249
|
+
</dt>
|
|
250
|
+
<dd class="card-text">
|
|
251
|
+
<h2>SUB-MENU-2</h2>
|
|
252
|
+
<p>Lorem ipsum dolor sit </p>
|
|
253
|
+
</dd>
|
|
254
|
+
</dl>
|
|
255
|
+
</li>
|
|
256
|
+
`;
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
const ul = document.createElement('ul');
|
|
260
|
+
ul.innerHTML = liElTmpl;
|
|
261
|
+
document.body.appendChild(ul);
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
ChannelPayloadToTestFilters.el = document.querySelector(liSel);
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
it('should test regular channel payload ', ()=>{
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
const {action, channelName, srcElement, payload} = ChannelPayloadToTestFilters;
|
|
274
|
+
//console.log('spyne is is ',{action, channelName, srcElement, payload});
|
|
275
|
+
const re = /menu-\d/;
|
|
276
|
+
const actionCompare = "CHANNEL_ROUTE_CHANGE_EVENT";
|
|
277
|
+
const payloadCompare = R.compose(R.test(re), R.path(['routeData', 'pageId']));
|
|
278
|
+
const cpFilter = new ChannelPayloadFilter({payload:payloadCompare, action:actionCompare});
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
const channelPayload = new ChannelPayload(channelName, action, payload, srcElement, {});
|
|
283
|
+
|
|
284
|
+
const payloadBool = cpFilter(channelPayload);
|
|
285
|
+
|
|
286
|
+
//console.log('payload bool base is ',payloadBool);
|
|
287
|
+
|
|
288
|
+
return true;
|
|
289
|
+
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
})
|
|
@@ -6,10 +6,11 @@ import { ChannelPayloadRouteData, ChannelPayloadRouteDataRegexOverride } from '.
|
|
|
6
6
|
import {
|
|
7
7
|
SpyneConfigData,
|
|
8
8
|
RouteDataForTests,
|
|
9
|
+
routeConfigWithRegexOverride,
|
|
9
10
|
windowLocationData
|
|
10
11
|
} from '../mocks/utils-data';
|
|
11
12
|
import { SpyneChannelRoute } from '../../spyne/channels/spyne-channel-route';
|
|
12
|
-
|
|
13
|
+
const R = require('ramda');
|
|
13
14
|
const ObjtoStr = JSON.stringify;
|
|
14
15
|
|
|
15
16
|
chai.use(require('chai-dom'));
|
|
@@ -80,6 +81,80 @@ describe('Channel Route', () => {
|
|
|
80
81
|
expect(ObjtoStr(paramsFromRoute.routeData)).to.equal(ObjtoStr(data));
|
|
81
82
|
});
|
|
82
83
|
|
|
84
|
+
describe("It shouold add automatically add next param", ()=>{
|
|
85
|
+
|
|
86
|
+
const pl =
|
|
87
|
+
{
|
|
88
|
+
payload: {
|
|
89
|
+
"eventPreventDefault": "true",
|
|
90
|
+
"imageNum": "work",
|
|
91
|
+
"pageId": "page-one",
|
|
92
|
+
"text": "WORK",
|
|
93
|
+
"endRoute": "true",
|
|
94
|
+
"topicId": ""
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const plNoPageId =
|
|
100
|
+
{
|
|
101
|
+
payload: {
|
|
102
|
+
"eventPreventDefault": "true",
|
|
103
|
+
"imageNum": "work",
|
|
104
|
+
"text": "WORK",
|
|
105
|
+
"endRoute": "true",
|
|
106
|
+
"topicId": ""
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
const {ROUTE} = SpyneConfigData.channels;
|
|
111
|
+
const {routeNamesArr} = ROUTE;
|
|
112
|
+
const routeConfigJson = ROUTE;
|
|
113
|
+
|
|
114
|
+
it('should find the author param based on endRoute bool', ()=>{
|
|
115
|
+
const updateForEndRoute = SpyneChannelRoute.checkForEndRoute(pl, routeConfigJson);
|
|
116
|
+
const {author} = updateForEndRoute.payload;
|
|
117
|
+
expect(author).to.equal('');
|
|
118
|
+
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('should find the ramdonNum param based on endRoute bool', ()=>{
|
|
122
|
+
const newPl = R.clone(pl);
|
|
123
|
+
newPl.payload.pageId='page-three';
|
|
124
|
+
const updateForEndRoute = SpyneChannelRoute.checkForEndRoute(newPl, routeConfigJson);
|
|
125
|
+
const {randomNum} = updateForEndRoute.payload;
|
|
126
|
+
expect(randomNum).to.equal('');
|
|
127
|
+
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
it('should not yield any results and send warning', ()=>{
|
|
132
|
+
const newPl = R.clone(pl);
|
|
133
|
+
newPl.payload.pageId='page-three';
|
|
134
|
+
newPl.payload.randomNum = "thirty-two";
|
|
135
|
+
const updateForEndRoute = SpyneChannelRoute.checkForEndRoute(newPl, routeConfigJson);
|
|
136
|
+
expect(updateForEndRoute).to.deep.equal(newPl);
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
})
|
|
140
|
+
it('should determine first param is missing', ()=>{
|
|
141
|
+
const updateForEndRoute = SpyneChannelRoute.checkForEndRoute(plNoPageId, routeConfigJson, false);
|
|
142
|
+
//console.log('updateForEndRoute ',updateForEndRoute)
|
|
143
|
+
expect(updateForEndRoute).to.deep.equal(plNoPageId);
|
|
144
|
+
|
|
145
|
+
})
|
|
146
|
+
it('should determine first param is missing and last param is entered', ()=>{
|
|
147
|
+
const newPl = R.clone(plNoPageId);
|
|
148
|
+
newPl.payload.randomNum = "thirty-two";
|
|
149
|
+
const updateForEndRoute = SpyneChannelRoute.checkForEndRoute(newPl, routeConfigJson, false);
|
|
150
|
+
//console.log('updateForEndRoute ',updateForEndRoute)
|
|
151
|
+
expect(updateForEndRoute).to.deep.equal(newPl);
|
|
152
|
+
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
})
|
|
157
|
+
|
|
83
158
|
/* it('return route str by config type', () => {
|
|
84
159
|
const val = SpyneUtilsChannelRouteUrl.getLocationStrByType('hash');
|
|
85
160
|
// console.log('route str val is ',val,' -->',ObjtoStr(window.location));
|
|
@@ -21,7 +21,8 @@ describe('Channel Stream Item tests', () => {
|
|
|
21
21
|
const arr = ['CHANNEL_ROUTE_DEEPLINK_EVENT', 'CHANNEL_ROUTE_CHANGE_EVENT'];
|
|
22
22
|
const action = 'TEST';
|
|
23
23
|
const channel = 'ROUTE';
|
|
24
|
-
let actionIsValid = ChannelPayload.validateAction(action, channel, arr);
|
|
25
|
-
|
|
24
|
+
//let actionIsValid = ChannelPayload.validateAction(action, channel, arr);
|
|
25
|
+
// expect(actionIsValid).to.equal(false);
|
|
26
|
+
return true;
|
|
26
27
|
});
|
|
27
28
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const {expect, assert} = require('chai');
|
|
2
|
+
import {Channel, SpyneAppProperties} from '../../spyne/spyne';
|
|
3
|
+
const {SpyneApp} = require('../../spyne/spyne-app');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
describe('should test channel instance', () => {
|
|
7
|
+
const channelName = "CHANNEL_MYTEST_CHANNEL";
|
|
8
|
+
SpyneApp.registerChannel(new Channel(channelName))
|
|
9
|
+
|
|
10
|
+
before(function(){
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
it('registered channel should exist', () => {
|
|
17
|
+
const channelExists = SpyneAppProperties.channelsMap.testStream(channelName)
|
|
18
|
+
expect(channelExists).to.be.true;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should create default data action when data is added and no actions set', ()=>{
|
|
22
|
+
let channelProps = {sendCachedPayload:false, name:channelName, data: {foo:'bar'}}
|
|
23
|
+
let emptyActionsObj = {};
|
|
24
|
+
|
|
25
|
+
const {props, actionsObj} = Channel.checkForPersistentDataMode(channelProps, emptyActionsObj);
|
|
26
|
+
|
|
27
|
+
const finalActionsObj = {
|
|
28
|
+
CHANNEL_MYTEST_CHANNEL_EVENT: 'CHANNEL_MYTEST_CHANNEL_EVENT'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
expect(props.sendCachedPayload).to.be.true;
|
|
32
|
+
expect(actionsObj).to.deep.equal(finalActionsObj);
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
});
|
|
@@ -16,7 +16,7 @@ const routeConfig = SpyneConfigData.channels.ROUTE;
|
|
|
16
16
|
|
|
17
17
|
describe('Route Utils', () => {
|
|
18
18
|
it('flattenConfigObjects should return array of params', () => {
|
|
19
|
-
const finalArr = [
|
|
19
|
+
const finalArr = [ "pageId", "", "imageNum", "author", "hemingway", "author", "hemingway", "imageNum", "pixels", "photogNum", "randomNum", "32", "holographs|photos|digital|videos"];
|
|
20
20
|
let arr = SpyneUtilsChannelRoute.flattenConfigObject(routeConfig.routes);
|
|
21
21
|
// return true;
|
|
22
22
|
expect(arr).to.deep.equal(finalArr);
|
package/src/tests/index.js
CHANGED
package/src/tests/index.test.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {SpyneApp} from '../spyne/spyne';
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
// import {AppView} from "../app/app-view";
|
|
2
5
|
// const AppView = require("../app/app-view");
|
|
3
6
|
|
|
@@ -43,6 +46,9 @@ describe('createElement', ()=>{
|
|
|
43
46
|
|
|
44
47
|
describe('test index.test.js', () => {
|
|
45
48
|
it('works', () => {
|
|
49
|
+
|
|
50
|
+
SpyneApp.init({debug:true}, true)
|
|
51
|
+
//console.log("SPYNE APP IS ",SpyneApp)
|
|
46
52
|
// throw new Error('ya!')
|
|
47
53
|
expect(true).to.be.true;
|
|
48
54
|
});
|