spyne 0.19.1 → 0.20.0
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/.eslintrc.js +4 -3
- package/.travis.yml +24 -11
- package/karma.conf.js +76 -86
- package/lib/spyne.esm.js +15 -0
- package/lib/spyne.esm.js.map +1 -0
- package/lib/spyne.umd.js +9565 -0
- package/package.json +47 -27
- package/rollup.config.js +26 -0
- package/src/spyne/channels/channel-fetch-class.js +39 -43
- package/src/spyne/channels/channel-payload-class.js +61 -74
- package/src/spyne/channels/channel-proxy.js +25 -26
- package/src/spyne/channels/channel.js +141 -149
- package/src/spyne/channels/channels-config.js +46 -47
- package/src/spyne/channels/channels-map.js +61 -65
- package/src/spyne/channels/spyne-channel-lifecycle.js +12 -12
- package/src/spyne/channels/spyne-channel-route.js +241 -250
- package/src/spyne/channels/spyne-channel-ui.js +213 -75
- package/src/spyne/channels/spyne-channel-window.js +157 -157
- package/src/spyne/spyne-app.js +32 -19
- package/src/spyne/spyne-plugins.js +55 -70
- package/src/spyne/spyne.js +23 -23
- package/src/spyne/utils/channel-config-validator.js +10 -10
- package/src/spyne/utils/channel-fetch-util.js +72 -55
- package/src/spyne/utils/channel-payload-filter.js +89 -100
- package/src/spyne/utils/deep-merge.js +31 -29
- package/src/spyne/utils/frp-tools.js +108 -92
- package/src/spyne/utils/gc.js +6 -6
- package/src/spyne/utils/mixins/base-core-mixins.js +17 -15
- package/src/spyne/utils/mixins/base-streams-mixins.js +9 -9
- package/src/spyne/utils/route-channel-updater.js +23 -29
- package/src/spyne/utils/safe-clone.js +40 -58
- package/src/spyne/utils/sanitize-html.js +35 -0
- package/src/spyne/utils/security-policy.js +11 -0
- package/src/spyne/utils/spyne-app-properties.js +110 -114
- package/src/spyne/utils/spyne-logger.js +4 -11
- package/src/spyne/utils/spyne-plugins-methods.js +38 -63
- package/src/spyne/utils/spyne-trait.js +33 -33
- package/src/spyne/utils/spyne-utils-channel-route-url.js +229 -153
- package/src/spyne/utils/spyne-utils-channel-route.js +128 -138
- package/src/spyne/utils/spyne-utils-channel-window.js +39 -39
- package/src/spyne/utils/viewstream-animations.js +12 -12
- package/src/spyne/utils/viewstream-observables.js +45 -45
- package/src/spyne/views/dom-element-template.js +111 -114
- package/src/spyne/views/dom-element.js +82 -84
- package/src/spyne/views/view-stream-broadcaster.js +66 -62
- package/src/spyne/views/view-stream-element.js +105 -106
- package/src/spyne/views/view-stream-payload.js +25 -27
- package/src/spyne/views/view-stream-selector.js +157 -163
- package/src/spyne/views/view-stream.js +416 -640
- package/src/tests/channels/channel-dom.test.js +15 -15
- package/src/tests/channels/channel-fetch.test.js +51 -62
- package/src/tests/channels/channel-payload-class.test.js +50 -63
- package/src/tests/channels/channel-payload-filter.test.js +133 -193
- package/src/tests/channels/channel-route.test.js +102 -112
- package/src/tests/channels/channel-stream-item.test.js +19 -19
- package/src/tests/channels/channel-ui.test.js +15 -27
- package/src/tests/channels/channel-util-dom.test.js +31 -31
- package/src/tests/channels/channel.test.js +20 -25
- package/src/tests/channels/route-utils.test.js +61 -66
- package/src/tests/channels/url-utils.test.js +151 -151
- package/src/tests/channels/view-stream-broadcaster.test.js +7 -7
- package/src/tests/import.test.js +5 -5
- package/src/tests/index.js +6 -7
- package/src/tests/index.test.js +6 -8
- package/src/tests/mocks/channel-payload-data.js +218 -220
- package/src/tests/mocks/enhancer.test.js +5 -5
- package/src/tests/mocks/payload-ui.js +87 -90
- package/src/tests/mocks/routes-data.js +264 -266
- package/src/tests/mocks/spyne-docs.mocks.js +3 -3
- package/src/tests/mocks/template-renderer.mocks.js +47 -47
- package/src/tests/mocks/utils-data.js +78 -79
- package/src/tests/mocks/viewstream-internal-payload.mocks.js +50 -50
- package/src/tests/mocks/window-events-arr.js +1 -1
- package/src/tests/package-json.spec.test.js +9 -0
- package/src/tests/spyne-app.test.js +15 -18
- package/src/tests/spyne-plugin.test.js +16 -20
- package/src/tests/utils/channel-action-filter.test.js +84 -86
- package/src/tests/utils/channel-data-packet-generator.unused.js +62 -86
- package/src/tests/utils/channel-fetch-util.test.js +64 -66
- package/src/tests/utils/frp-tools.test.js +19 -19
- package/src/tests/utils/plugins-methods.test.js +31 -55
- package/src/tests/utils/security.test.js +10 -0
- package/src/tests/utils/spyne-app-properties.test.js +4 -8
- package/src/tests/views/dom-el-selectors.test.js +112 -119
- package/src/tests/views/dom-el-template-proxy.test.js +7 -0
- package/src/tests/views/dom-el-template.test.js +186 -156
- package/src/tests/views/dom-el.test.js +58 -56
- package/src/tests/views/view-stream-enhancer-loader.test.js +2 -2
- package/src/tests/views/view-stream-enhancer.test.js +11 -11
- package/src/tests/views/view-stream.test.js +22 -33
- package/webpack.config.js +76 -67
- package/docs/-_%20Solves%20equations%20of%20the%20form%20a%20_%20x%20=%20b.html +0 -487
- package/docs/DomItem.html +0 -298
- package/docs/DomItem_DomItem.html +0 -314
- package/docs/ViewStream.html +0 -2249
- package/docs/ViewStream_ViewStream.html +0 -503
- package/docs/custom/css/jsdoc-viewstream.css +0 -377
- package/docs/custom/layout.tmpl +0 -47
- package/docs/dom-item.js.html +0 -213
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/global.html +0 -548
- package/docs/index-custom.html +0 -79
- package/docs/index.html +0 -82
- package/docs/jsdoc.config.json +0 -22
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/styles/jsdoc-default.css +0 -358
- package/docs/styles/prettify-jsdoc.css +0 -111
- package/docs/styles/prettify-tomorrow.css +0 -132
- package/docs/view-stream.js.html +0 -767
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
// const assert = require('assert');
|
|
2
2
|
|
|
3
|
-
import { SpyneUtilsChannelRouteUrl } from '../../spyne/utils/spyne-utils-channel-route-url'
|
|
4
|
-
import { ChannelPayloadRouteData, ChannelPayloadRouteDataRegexOverride } from '../mocks/channel-payload-data'
|
|
3
|
+
import { SpyneUtilsChannelRouteUrl } from '../../spyne/utils/spyne-utils-channel-route-url'
|
|
4
|
+
import { ChannelPayloadRouteData, ChannelPayloadRouteDataRegexOverride } from '../mocks/channel-payload-data'
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
SpyneConfigData,
|
|
8
8
|
RouteDataForTests,
|
|
9
9
|
routeConfigWithRegexOverride,
|
|
10
10
|
windowLocationData
|
|
11
|
-
} from '../mocks/utils-data'
|
|
12
|
-
import { SpyneChannelRoute } from '../../spyne/channels/spyne-channel-route'
|
|
13
|
-
const R = require('ramda')
|
|
14
|
-
const ObjtoStr = JSON.stringify
|
|
11
|
+
} from '../mocks/utils-data'
|
|
12
|
+
import { SpyneChannelRoute } from '../../spyne/channels/spyne-channel-route'
|
|
13
|
+
const R = require('ramda')
|
|
14
|
+
const ObjtoStr = JSON.stringify
|
|
15
15
|
|
|
16
|
-
chai.use(require('chai-dom'))
|
|
16
|
+
chai.use(require('chai-dom'))
|
|
17
17
|
|
|
18
|
-
const routeConfig = SpyneConfigData.channels.ROUTE
|
|
18
|
+
const routeConfig = SpyneConfigData.channels.ROUTE
|
|
19
19
|
|
|
20
20
|
describe('Channel Route', () => {
|
|
21
21
|
it('should return window relevant data', () => {
|
|
@@ -28,134 +28,124 @@ describe('Channel Route', () => {
|
|
|
28
28
|
'port',
|
|
29
29
|
'pathname',
|
|
30
30
|
'search',
|
|
31
|
-
'hash']
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
expect(ObjtoStr(routeLocationObj)).to.equal(ObjtoStr(locationObj))
|
|
35
|
-
})
|
|
31
|
+
'hash']
|
|
32
|
+
const locationObj = R.pickAll(locationParamsArr, window.location)
|
|
33
|
+
const routeLocationObj = SpyneChannelRoute.getLocationData()
|
|
34
|
+
expect(ObjtoStr(routeLocationObj)).to.equal(ObjtoStr(locationObj))
|
|
35
|
+
})
|
|
36
36
|
|
|
37
37
|
it('should return payload from params', () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
expect(routePayload).to.be.an('object')
|
|
41
|
-
})
|
|
38
|
+
const payload = ChannelPayloadRouteData
|
|
39
|
+
const routePayload = SpyneChannelRoute.getDataFromParams(payload, routeConfig)
|
|
40
|
+
expect(routePayload).to.be.an('object')
|
|
41
|
+
})
|
|
42
42
|
|
|
43
43
|
it('should return slash route string from params', () => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
expect(routeFromParams).to.equal(queryStr)
|
|
48
|
-
})
|
|
44
|
+
const data = RouteDataForTests.multiple.data
|
|
45
|
+
const queryStr = RouteDataForTests.multiple.slash
|
|
46
|
+
const routeFromParams = SpyneChannelRoute.getRouteStrFromParams(data, routeConfig)
|
|
47
|
+
expect(routeFromParams).to.equal(queryStr)
|
|
48
|
+
})
|
|
49
49
|
|
|
50
50
|
it('should return query route string from params', () => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
expect(routeFromParams).to.equal(queryStr)
|
|
55
|
-
})
|
|
51
|
+
const data = RouteDataForTests.multiple.data
|
|
52
|
+
const queryStr = RouteDataForTests.multiple.query
|
|
53
|
+
const routeFromParams = SpyneChannelRoute.getRouteStrFromParams(data, routeConfig, 'query')
|
|
54
|
+
expect(routeFromParams).to.equal(queryStr)
|
|
55
|
+
})
|
|
56
56
|
|
|
57
57
|
it('should return params object from slash string', () => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const data = RouteDataForTests.multiple.data
|
|
59
|
+
const queryStr = RouteDataForTests.multiple.slash
|
|
60
|
+
const paramsFromRoute = SpyneChannelRoute.getParamsFromRouteStr(queryStr, routeConfig)
|
|
61
61
|
|
|
62
|
-
//console.log('params from str is ',queryStr)
|
|
63
|
-
expect(ObjtoStr(paramsFromRoute.routeData)).to.equal(ObjtoStr(data))
|
|
64
|
-
})
|
|
62
|
+
// console.log('params from str is ',queryStr)
|
|
63
|
+
expect(ObjtoStr(paramsFromRoute.routeData)).to.equal(ObjtoStr(data))
|
|
64
|
+
})
|
|
65
65
|
|
|
66
66
|
it('should return params object from slash string using array in routeConfig', () => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
routeConfig.routes.routePath
|
|
70
|
-
|
|
67
|
+
const data = RouteDataForTests.multipleRegexComplex.data
|
|
68
|
+
const queryStr = RouteDataForTests.multipleRegexComplex.slash
|
|
69
|
+
routeConfig.routes.routePath.work = 'holographs|photos|digital|videos'
|
|
70
|
+
const paramsFromRoute = SpyneChannelRoute.getParamsFromRouteStr(queryStr, routeConfig)
|
|
71
71
|
|
|
72
|
-
//console.log('params from str is ',JSON.stringify(paramsFromRoute))
|
|
72
|
+
// console.log('params from str is ',JSON.stringify(paramsFromRoute))
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
})
|
|
74
|
+
expect(ObjtoStr(paramsFromRoute.routeData)).to.equal(ObjtoStr(data))
|
|
75
|
+
})
|
|
76
76
|
|
|
77
77
|
it('should return params object from query string', () => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
expect(ObjtoStr(paramsFromRoute.routeData)).to.equal(ObjtoStr(data))
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const pl =
|
|
78
|
+
const data = RouteDataForTests.multiple.data
|
|
79
|
+
const queryStr = RouteDataForTests.multiple.query
|
|
80
|
+
const paramsFromRoute = SpyneChannelRoute.getParamsFromRouteStr(queryStr, routeConfig, 'query')
|
|
81
|
+
expect(ObjtoStr(paramsFromRoute.routeData)).to.equal(ObjtoStr(data))
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
describe('It shouold add automatically add next param', () => {
|
|
85
|
+
const pl =
|
|
87
86
|
{
|
|
88
87
|
payload: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
eventPreventDefault: 'true',
|
|
89
|
+
imageNum: 'work',
|
|
90
|
+
pageId: 'page-one',
|
|
91
|
+
text: 'WORK',
|
|
92
|
+
endRoute: 'true',
|
|
93
|
+
topicId: ''
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
}
|
|
98
97
|
|
|
99
|
-
|
|
98
|
+
const plNoPageId =
|
|
100
99
|
{
|
|
101
100
|
payload: {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
eventPreventDefault: 'true',
|
|
102
|
+
imageNum: 'work',
|
|
103
|
+
text: 'WORK',
|
|
104
|
+
endRoute: 'true',
|
|
105
|
+
topicId: ''
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
//console.log('updateForEndRoute ',updateForEndRoute)
|
|
151
|
-
expect(updateForEndRoute).to.deep.equal(newPl);
|
|
152
|
-
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
/* it('return route str by config type', () => {
|
|
109
|
+
const { ROUTE } = SpyneConfigData.channels
|
|
110
|
+
const { routeNamesArr } = ROUTE
|
|
111
|
+
const routeConfigJson = ROUTE
|
|
112
|
+
|
|
113
|
+
it('should find the author param based on endRoute bool', () => {
|
|
114
|
+
const updateForEndRoute = SpyneChannelRoute.checkForEndRoute(pl, routeConfigJson)
|
|
115
|
+
const { author } = updateForEndRoute.payload
|
|
116
|
+
expect(author).to.equal('')
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('should find the ramdonNum param based on endRoute bool', () => {
|
|
120
|
+
const newPl = R.clone(pl)
|
|
121
|
+
newPl.payload.pageId = 'page-three'
|
|
122
|
+
const updateForEndRoute = SpyneChannelRoute.checkForEndRoute(newPl, routeConfigJson)
|
|
123
|
+
const { randomNum } = updateForEndRoute.payload
|
|
124
|
+
expect(randomNum).to.equal('')
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it('should not yield any results and send warning', () => {
|
|
128
|
+
const newPl = R.clone(pl)
|
|
129
|
+
newPl.payload.pageId = 'page-three'
|
|
130
|
+
newPl.payload.randomNum = 'thirty-two'
|
|
131
|
+
const updateForEndRoute = SpyneChannelRoute.checkForEndRoute(newPl, routeConfigJson)
|
|
132
|
+
expect(updateForEndRoute).to.deep.equal(newPl)
|
|
133
|
+
})
|
|
134
|
+
it('should determine first param is missing', () => {
|
|
135
|
+
const updateForEndRoute = SpyneChannelRoute.checkForEndRoute(plNoPageId, routeConfigJson, false)
|
|
136
|
+
// console.log('updateForEndRoute ',updateForEndRoute)
|
|
137
|
+
expect(updateForEndRoute).to.deep.equal(plNoPageId)
|
|
138
|
+
})
|
|
139
|
+
it('should determine first param is missing and last param is entered', () => {
|
|
140
|
+
const newPl = R.clone(plNoPageId)
|
|
141
|
+
newPl.payload.randomNum = 'thirty-two'
|
|
142
|
+
const updateForEndRoute = SpyneChannelRoute.checkForEndRoute(newPl, routeConfigJson, false)
|
|
143
|
+
// console.log('updateForEndRoute ',updateForEndRoute)
|
|
144
|
+
expect(updateForEndRoute).to.deep.equal(newPl)
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
/* it('return route str by config type', () => {
|
|
159
149
|
const val = SpyneUtilsChannelRouteUrl.getLocationStrByType('hash');
|
|
160
150
|
// console.log('route str val is ',val,' -->',ObjtoStr(window.location));
|
|
161
151
|
|
|
@@ -166,5 +156,5 @@ describe('Channel Route', () => {
|
|
|
166
156
|
let payloadOverrideCheck = SpyneChannelRoute.checkForRouteParamsOverrides(ChannelPayloadRouteDataRegexOverride);
|
|
167
157
|
console.log("override check ",payloadOverrideCheck);
|
|
168
158
|
return true;
|
|
169
|
-
})
|
|
170
|
-
})
|
|
159
|
+
}); */
|
|
160
|
+
})
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { ChannelPayloadRouteData, ChannelPayloadUIData, DeepLinkData } from '../mocks/channel-payload-data'
|
|
2
|
-
import { ChannelPayload } from '../../spyne/channels/channel-payload-class'
|
|
1
|
+
import { ChannelPayloadRouteData, ChannelPayloadUIData, DeepLinkData } from '../mocks/channel-payload-data'
|
|
2
|
+
import { ChannelPayload } from '../../spyne/channels/channel-payload-class'
|
|
3
3
|
|
|
4
4
|
describe('Channel Stream Item tests', () => {
|
|
5
5
|
it('deeplink should return [payload, type, location]', () => {
|
|
6
|
-
const deepLinkData = DeepLinkData
|
|
6
|
+
const deepLinkData = DeepLinkData
|
|
7
7
|
// console.log('deep link data is ',deepLinkData);
|
|
8
8
|
|
|
9
|
-
return true
|
|
10
|
-
})
|
|
9
|
+
return true
|
|
10
|
+
})
|
|
11
11
|
|
|
12
12
|
it('action should exist in route actions array', () => {
|
|
13
|
-
const arr = ['CHANNEL_ROUTE_DEEPLINK_EVENT', 'CHANNEL_ROUTE_CHANGE_EVENT']
|
|
14
|
-
const action = 'CHANNEL_ROUTE_DEEPLINK_EVENT'
|
|
15
|
-
const channel = 'ROUTE'
|
|
16
|
-
|
|
17
|
-
expect(actionIsValid).to.equal(true)
|
|
18
|
-
})
|
|
13
|
+
const arr = ['CHANNEL_ROUTE_DEEPLINK_EVENT', 'CHANNEL_ROUTE_CHANGE_EVENT']
|
|
14
|
+
const action = 'CHANNEL_ROUTE_DEEPLINK_EVENT'
|
|
15
|
+
const channel = 'ROUTE'
|
|
16
|
+
const actionIsValid = ChannelPayload.validateAction(action, channel, arr)
|
|
17
|
+
expect(actionIsValid).to.equal(true)
|
|
18
|
+
})
|
|
19
19
|
|
|
20
20
|
it('action should not exist in route actions array', () => {
|
|
21
|
-
const arr = ['CHANNEL_ROUTE_DEEPLINK_EVENT', 'CHANNEL_ROUTE_CHANGE_EVENT']
|
|
22
|
-
const action = 'TEST'
|
|
23
|
-
const channel = 'ROUTE'
|
|
24
|
-
//let actionIsValid = ChannelPayload.validateAction(action, channel, arr);
|
|
25
|
-
|
|
26
|
-
return true
|
|
27
|
-
})
|
|
28
|
-
})
|
|
21
|
+
const arr = ['CHANNEL_ROUTE_DEEPLINK_EVENT', 'CHANNEL_ROUTE_CHANGE_EVENT']
|
|
22
|
+
const action = 'TEST'
|
|
23
|
+
const channel = 'ROUTE'
|
|
24
|
+
// let actionIsValid = ChannelPayload.validateAction(action, channel, arr);
|
|
25
|
+
// expect(actionIsValid).to.equal(false);
|
|
26
|
+
return true
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
import {SpyneChannelUI} from '../../spyne/channels/spyne-channel-ui'
|
|
2
|
-
import {payloadPreventDefault, payloadStopPropagation, payloadTwoEvents, payloadNoEvent, payloadEmptyEvent} from '../mocks/payload-ui'
|
|
1
|
+
import { SpyneChannelUI } from '../../spyne/channels/spyne-channel-ui'
|
|
2
|
+
import { payloadPreventDefault, payloadStopPropagation, payloadTwoEvents, payloadNoEvent, payloadEmptyEvent } from '../mocks/payload-ui'
|
|
3
3
|
|
|
4
4
|
describe('root test', () => {
|
|
5
|
-
|
|
6
5
|
const payload_eventPreventDefault =
|
|
7
6
|
|
|
8
7
|
it('should return no event from ui payload', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return true;
|
|
15
|
-
|
|
16
|
-
});
|
|
8
|
+
const payload = R.clone(payloadNoEvent)
|
|
9
|
+
const payloadUpdate = SpyneChannelUI.checkForEventMethods(payload)
|
|
17
10
|
|
|
11
|
+
return true
|
|
12
|
+
})
|
|
18
13
|
|
|
19
14
|
it('should return event paylaod from ui payload', () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
const payload = R.clone(payloadPreventDefault)
|
|
16
|
+
const payloadUpdate = SpyneChannelUI.checkForEventMethods(payload)
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
18
|
+
return true
|
|
19
|
+
})
|
|
28
20
|
|
|
29
21
|
it('should return event paylaods from ui payload', () => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return true;
|
|
36
|
-
|
|
37
|
-
});
|
|
22
|
+
const payload = R.clone(payloadTwoEvents)
|
|
23
|
+
const payloadUpdate = SpyneChannelUI.checkForEventMethods(payload)
|
|
38
24
|
|
|
39
|
-
|
|
25
|
+
return true
|
|
26
|
+
})
|
|
27
|
+
})
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { SpyneChannelWindow} from '../../spyne/channels/spyne-channel-window'
|
|
2
|
-
import { SpyneUtilsChannelWindow } from '../../spyne/utils/spyne-utils-channel-window'
|
|
3
|
-
import { SpyneConfigData } from '../mocks/utils-data'
|
|
1
|
+
import { SpyneChannelWindow } from '../../spyne/channels/spyne-channel-window'
|
|
2
|
+
import { SpyneUtilsChannelWindow } from '../../spyne/utils/spyne-utils-channel-window'
|
|
3
|
+
import { SpyneConfigData } from '../mocks/utils-data'
|
|
4
4
|
|
|
5
|
-
const domData = SpyneConfigData.channels.WINDOW
|
|
5
|
+
const domData = SpyneConfigData.channels.WINDOW
|
|
6
6
|
|
|
7
7
|
describe('channel dom util tests', () => {
|
|
8
8
|
describe('channel dom media queries', () => {
|
|
9
9
|
it('should create media query', () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
expect(mqMatchesQuery).to.be.equal(true)
|
|
14
|
-
})
|
|
10
|
+
const queryStr = domData.mediaQueries.test
|
|
11
|
+
const mq = SpyneUtilsChannelWindow.createMediaQuery(queryStr)
|
|
12
|
+
const mqMatchesQuery = SpyneUtilsChannelWindow.checkIfValidMediaQuery(mq, queryStr)
|
|
13
|
+
expect(mqMatchesQuery).to.be.equal(true)
|
|
14
|
+
})
|
|
15
15
|
|
|
16
16
|
it('should create media query observable', () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return true
|
|
21
|
-
})
|
|
17
|
+
const queryStr = domData.mediaQueries.test
|
|
18
|
+
const mq = SpyneUtilsChannelWindow.createMediaQuery(queryStr)
|
|
19
|
+
const obs$ = SpyneUtilsChannelWindow.createMediaQueryHandler(mq, 'test')
|
|
20
|
+
return true
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
it('should return obs$ arr based on config ', () => {
|
|
24
|
-
|
|
25
|
-
expect(obs$Arr.length).to.equal(2)
|
|
26
|
-
})
|
|
27
|
-
})
|
|
24
|
+
const obs$Arr = SpyneUtilsChannelWindow.createMergedObsFromObj(domData)
|
|
25
|
+
expect(obs$Arr.length).to.equal(2)
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
28
|
|
|
29
29
|
describe('channel dom create window event', () => {
|
|
30
30
|
it('it should create a window event', () => {
|
|
31
|
-
const onUnload = e => localStorage.setItem('ubu', window.document.body.outerHTML)
|
|
32
|
-
|
|
31
|
+
const onUnload = e => localStorage.setItem('ubu', window.document.body.outerHTML)
|
|
32
|
+
const obs$ = SpyneUtilsChannelWindow.createDomObservableFromEvent('beforeunload')
|
|
33
33
|
// obs$.subscribe(onUnload);
|
|
34
|
-
expect(obs$.constructor.name).to.equal('Observable')
|
|
35
|
-
})
|
|
36
|
-
})
|
|
34
|
+
expect(obs$.constructor.name).to.equal('Observable')
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
37
|
|
|
38
38
|
describe('channel dom window resize', () => {
|
|
39
39
|
it('add resize screenItem from config', () => {
|
|
40
40
|
|
|
41
|
-
})
|
|
42
|
-
})
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
43
|
|
|
44
44
|
describe('channel dom scroll', () => {
|
|
45
45
|
it('add dom scroll from config', () => {
|
|
46
|
-
return true
|
|
47
|
-
})
|
|
46
|
+
return true
|
|
47
|
+
})
|
|
48
48
|
it('add mousewheel scroll from config', () => {
|
|
49
|
-
return true
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
})
|
|
49
|
+
return true
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
})
|
|
@@ -1,44 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {SpyneApp} = require('../../spyne/spyne-app')
|
|
4
|
-
|
|
1
|
+
import { Channel, SpyneAppProperties } from '../../spyne/spyne'
|
|
2
|
+
const { expect, assert } = require('chai')
|
|
3
|
+
const { SpyneApp } = require('../../spyne/spyne-app')
|
|
5
4
|
|
|
6
5
|
describe('should test channel instance', () => {
|
|
7
|
-
const channelName =
|
|
6
|
+
const channelName = 'CHANNEL_MYTEST_CHANNEL'
|
|
8
7
|
SpyneApp.registerChannel(new Channel(channelName))
|
|
9
8
|
|
|
10
|
-
before(function(){
|
|
11
|
-
|
|
9
|
+
before(function() {
|
|
12
10
|
|
|
13
11
|
})
|
|
14
12
|
|
|
15
|
-
|
|
16
13
|
it('registered channel should exist', () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})
|
|
14
|
+
const channelExists = SpyneAppProperties.channelsMap.testStream(channelName)
|
|
15
|
+
expect(channelExists).to.be.true
|
|
16
|
+
})
|
|
20
17
|
|
|
21
|
-
it('should create default data action when data is added and no actions set', ()=>{
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
it('should create default data action when data is added and no actions set', () => {
|
|
19
|
+
const channelProps = { sendCachedPayload:false, name:channelName, data: { foo:'bar' } }
|
|
20
|
+
const emptyActionsObj = {}
|
|
24
21
|
|
|
25
|
-
const {props, actionsObj} = Channel.checkForPersistentDataMode(channelProps, emptyActionsObj)
|
|
22
|
+
const { props, actionsObj } = Channel.checkForPersistentDataMode(channelProps, emptyActionsObj)
|
|
26
23
|
|
|
27
24
|
const finalActionsObj = {
|
|
28
25
|
CHANNEL_MYTEST_CHANNEL_EVENT: 'CHANNEL_MYTEST_CHANNEL_EVENT'
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
expect(props.sendCachedPayload).to.be.true
|
|
32
|
-
expect(actionsObj).to.deep.equal(finalActionsObj)
|
|
33
|
-
|
|
28
|
+
expect(props.sendCachedPayload).to.be.true
|
|
29
|
+
expect(actionsObj).to.deep.equal(finalActionsObj)
|
|
34
30
|
})
|
|
35
31
|
|
|
36
|
-
it('should update SpyneAppProperties doNotTrackList if doNotTrack is true', ()=>{
|
|
37
|
-
const channelName=
|
|
38
|
-
const doNotTrack = true
|
|
39
|
-
Channel.checkForNotTrackFlag({channelName, doNotTrack})
|
|
32
|
+
it('should update SpyneAppProperties doNotTrackList if doNotTrack is true', () => {
|
|
33
|
+
const channelName = 'CHANNEL_MY_TEST_CHANNEL'
|
|
34
|
+
const doNotTrack = true
|
|
35
|
+
Channel.checkForNotTrackFlag({ channelName, doNotTrack })
|
|
40
36
|
const untrackedChannelsArr = SpyneAppProperties.getUntrackedChannelsList()
|
|
41
|
-
expect(untrackedChannelsArr).to.deep.eq([channelName])
|
|
37
|
+
expect(untrackedChannelsArr).to.deep.eq([channelName])
|
|
42
38
|
})
|
|
43
|
-
|
|
44
|
-
});
|
|
39
|
+
})
|