spyne 0.19.0 → 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 +46 -26
- 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,133 +1,131 @@
|
|
|
1
|
-
import { ChannelPayloadFilter } from '../../spyne/utils/channel-payload-filter'
|
|
2
|
-
import { internalViewStreamPayload, internvalRouteChannelPayload } from '../mocks/viewstream-internal-payload.mocks'
|
|
3
|
-
import { spyneDocsDomStr } from '../mocks/spyne-docs.mocks'
|
|
1
|
+
import { ChannelPayloadFilter } from '../../spyne/utils/channel-payload-filter'
|
|
2
|
+
import { internalViewStreamPayload, internvalRouteChannelPayload } from '../mocks/viewstream-internal-payload.mocks'
|
|
3
|
+
import { spyneDocsDomStr } from '../mocks/spyne-docs.mocks'
|
|
4
4
|
|
|
5
|
-
import * as R from 'ramda'
|
|
6
|
-
import {UnsubscriptionError} from 'rxjs'
|
|
7
|
-
internalViewStreamPayload.srcElement.el = document.querySelector('.has-svg.github')
|
|
5
|
+
import * as R from 'ramda'
|
|
6
|
+
import { UnsubscriptionError } from 'rxjs'
|
|
7
|
+
internalViewStreamPayload.srcElement.el = document.querySelector('.has-svg.github')
|
|
8
8
|
describe('channel action filter', () => {
|
|
9
|
-
let payload = internalViewStreamPayload
|
|
10
|
-
|
|
11
|
-
payload = R.mergeDeepRight(obj.channelPayload, obj.srcElement, { channel:obj.channel }, { event:obj.event })
|
|
12
|
-
payload
|
|
9
|
+
let payload = internalViewStreamPayload
|
|
10
|
+
const obj = R.clone(payload)
|
|
11
|
+
payload = R.mergeDeepRight(obj.channelPayload, obj.srcElement, { channel:obj.channel }, { event:obj.event })
|
|
12
|
+
payload.action = obj.action
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const payloadRoute = internvalRouteChannelPayload
|
|
15
15
|
|
|
16
16
|
beforeEach(function() {
|
|
17
|
-
document.body.insertAdjacentHTML('afterbegin', spyneDocsDomStr)
|
|
18
|
-
payload.el = document.querySelector('.has-svg.github')
|
|
17
|
+
document.body.insertAdjacentHTML('afterbegin', spyneDocsDomStr)
|
|
18
|
+
payload.el = document.querySelector('.has-svg.github')
|
|
19
19
|
}
|
|
20
|
-
)
|
|
20
|
+
)
|
|
21
21
|
|
|
22
22
|
// remove the html fixture from the DOM
|
|
23
23
|
afterEach(function() {
|
|
24
|
-
document.body.removeChild(document.getElementById('app'))
|
|
25
|
-
})
|
|
24
|
+
document.body.removeChild(document.getElementById('app'))
|
|
25
|
+
})
|
|
26
26
|
it('Create a new ChannelPayloadFilter', () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return filterConstructor.should.equal('Function')
|
|
30
|
-
})
|
|
27
|
+
const filter = new ChannelPayloadFilter({ test:true })
|
|
28
|
+
const filterConstructor = filter.constructor.name
|
|
29
|
+
return filterConstructor.should.equal('Function')
|
|
30
|
+
})
|
|
31
31
|
|
|
32
32
|
it('String selector only with no data', () => {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const filter = new ChannelPayloadFilter({ selector: '#header ul li:last-child' })
|
|
34
|
+
const filterVal = filter(payload)
|
|
35
35
|
// console.log(filterVal, 'filter val string');
|
|
36
|
-
expect(filterVal).to.eq(true)
|
|
37
|
-
})
|
|
36
|
+
expect(filterVal).to.eq(true)
|
|
37
|
+
})
|
|
38
38
|
|
|
39
39
|
it('Selectors array contains match but no data', () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
expect(filterVal).to.eq(true)
|
|
43
|
-
})
|
|
44
|
-
|
|
40
|
+
const filter = new ChannelPayloadFilter({ selector:['#header ul li:last-child', '#header ul li:first-child'] })
|
|
41
|
+
const filterVal = filter(payload)
|
|
42
|
+
expect(filterVal).to.eq(true)
|
|
43
|
+
})
|
|
45
44
|
|
|
46
45
|
it('Selectors array as first prop contains match but no data', () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
expect(filterVal).to.eq(true)
|
|
50
|
-
})
|
|
51
|
-
|
|
46
|
+
const filter = new ChannelPayloadFilter(['#header ul li:last-child', '#header ul li:first-child'])
|
|
47
|
+
const filterVal = filter(payload)
|
|
48
|
+
expect(filterVal).to.eq(true)
|
|
49
|
+
})
|
|
52
50
|
|
|
53
51
|
it('Static Data and String Selector returns true', () => {
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
const selector = '#header ul li:last-child'
|
|
53
|
+
const propFilters = {
|
|
56
54
|
type:'link',
|
|
57
55
|
linkType: 'external'
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
}
|
|
57
|
+
const filter = new ChannelPayloadFilter({ propFilters, selector })
|
|
58
|
+
const filterVal = filter(payload)
|
|
61
59
|
|
|
62
|
-
expect(filterVal).to.eq(true)
|
|
63
|
-
})
|
|
60
|
+
expect(filterVal).to.eq(true)
|
|
61
|
+
})
|
|
64
62
|
|
|
65
63
|
it('Dynamic Data and String Selector returns true', () => {
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
const selector = '#header ul li:last-child'
|
|
65
|
+
const propFilters = {
|
|
68
66
|
type: (str) => str === 'link',
|
|
69
67
|
linkType: R.test(/ext.*nal/)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
}
|
|
69
|
+
const filter = new ChannelPayloadFilter({ propFilters, selector })
|
|
70
|
+
const filterVal = filter(payload)
|
|
73
71
|
|
|
74
|
-
expect(filterVal).to.eq(true)
|
|
75
|
-
})
|
|
72
|
+
expect(filterVal).to.eq(true)
|
|
73
|
+
})
|
|
76
74
|
|
|
77
75
|
it('Dynamic Data with no selector returns true', () => {
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
const selector = '#header ul li:last-child'
|
|
77
|
+
const propFilters = {
|
|
80
78
|
type: (str) => str === 'link',
|
|
81
79
|
linkType: R.test(/ext.*nal/)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
}
|
|
81
|
+
const filter = new ChannelPayloadFilter({ propFilters, selector })
|
|
82
|
+
const filterVal = filter(payload)
|
|
85
83
|
|
|
86
|
-
expect(filterVal).to.eq(true)
|
|
87
|
-
})
|
|
84
|
+
expect(filterVal).to.eq(true)
|
|
85
|
+
})
|
|
88
86
|
|
|
89
87
|
it('Empty Filter', () => {
|
|
90
|
-
const testMode = true
|
|
91
|
-
|
|
92
|
-
const {selector, propFilters} = filter
|
|
93
|
-
const isEmpty = selector === undefined && R.isEmpty(propFilters)
|
|
94
|
-
expect(isEmpty).to.eq(true)
|
|
95
|
-
})
|
|
88
|
+
const testMode = true
|
|
89
|
+
const filter = new ChannelPayloadFilter({ testMode })
|
|
90
|
+
const { selector, propFilters } = filter
|
|
91
|
+
const isEmpty = selector === undefined && R.isEmpty(propFilters)
|
|
92
|
+
expect(isEmpty).to.eq(true)
|
|
93
|
+
})
|
|
96
94
|
|
|
97
95
|
it('Empty String selector with no data', () => {
|
|
98
|
-
const testMode = true
|
|
99
|
-
|
|
100
|
-
const {selector, propFilters} = filter
|
|
101
|
-
const isEmpty = R.isEmpty(selector) && R.isEmpty(propFilters)
|
|
102
|
-
expect(isEmpty).to.eq(true)
|
|
103
|
-
})
|
|
96
|
+
const testMode = true
|
|
97
|
+
const filter = new ChannelPayloadFilter('', {}, undefined, testMode)
|
|
98
|
+
const { selector, propFilters } = filter
|
|
99
|
+
const isEmpty = R.isEmpty(selector) && R.isEmpty(propFilters)
|
|
100
|
+
expect(isEmpty).to.eq(true)
|
|
101
|
+
})
|
|
104
102
|
|
|
105
103
|
it('Arrays of selectors with no data', () => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
expect(filterVal).to.eq(false)
|
|
109
|
-
})
|
|
104
|
+
const filter = new ChannelPayloadFilter(['a.test', 'a.b'], {})
|
|
105
|
+
const filterVal = filter(payload)
|
|
106
|
+
expect(filterVal).to.eq(false)
|
|
107
|
+
})
|
|
110
108
|
|
|
111
109
|
it('Dynamic Data with no selector returns false', () => {
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
const str = '#header ul li:last-child'
|
|
111
|
+
const data = {
|
|
114
112
|
type: (str) => str === 'Incorrect',
|
|
115
113
|
linkType: R.test(/ext.*nal/)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
expect(filterVal).to.eq(false)
|
|
120
|
-
})
|
|
114
|
+
}
|
|
115
|
+
const filter = new ChannelPayloadFilter(undefined, data)
|
|
116
|
+
const filterVal = filter(payload)
|
|
117
|
+
expect(filterVal).to.eq(false)
|
|
118
|
+
})
|
|
121
119
|
|
|
122
120
|
it('False array and false dynamic data', () => {
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
const str = '#header ul li:last-child'
|
|
122
|
+
const data = {
|
|
125
123
|
type: (str) => str === 'Incorrect',
|
|
126
124
|
linkType: R.test(/ext.*nal/)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
}
|
|
126
|
+
const filter = new ChannelPayloadFilter(['', '#header ul li:first-child'], data)
|
|
127
|
+
const filterVal = filter(payload)
|
|
130
128
|
|
|
131
|
-
expect(filterVal).to.eq(false)
|
|
132
|
-
})
|
|
133
|
-
})
|
|
129
|
+
expect(filterVal).to.eq(false)
|
|
130
|
+
})
|
|
131
|
+
})
|
|
@@ -1,119 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ChannelPayloadToTestFilters } from '../mocks/channel-payload-data'
|
|
2
|
+
import { ChannelDataPacketGenerator } from '../../spyne/utils/channel-data-packet-generator'
|
|
3
|
+
import { ChannelDataPacket } from '../../spyne/utils/channel-data-packet'
|
|
4
|
+
const { expect, assert } = require('chai')
|
|
5
|
+
const R = require('ramda')
|
|
6
6
|
|
|
7
7
|
describe('should test the ChannelDataPacketGenerator', () => {
|
|
8
|
-
|
|
9
8
|
it('should test the packet geneator', () => {
|
|
9
|
+
const packetGenerator = new ChannelDataPacketGenerator()
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//console.log('packet gen is ',{ChannelPayloadToTestFilters})
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return true;
|
|
11
|
+
// console.log('packet gen is ',{ChannelPayloadToTestFilters})
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
return true
|
|
14
|
+
})
|
|
19
15
|
|
|
20
|
-
it('should create a custom label for the map location', ()=>{
|
|
21
|
-
const packetLabel = ChannelDataPacketGenerator.createLabel()
|
|
22
|
-
const isValidString = /^(\w)+$/.test(packetLabel)
|
|
23
|
-
expect(isValidString).to.be.true
|
|
16
|
+
it('should create a custom label for the map location', () => {
|
|
17
|
+
const packetLabel = ChannelDataPacketGenerator.createLabel()
|
|
18
|
+
const isValidString = /^(\w)+$/.test(packetLabel)
|
|
19
|
+
expect(isValidString).to.be.true
|
|
24
20
|
})
|
|
25
21
|
|
|
26
|
-
it('should create a timestamp',()=>{
|
|
27
|
-
const timestamp = ChannelDataPacketGenerator.createTimeStamp()
|
|
28
|
-
expect(timestamp).to.be.a('number')
|
|
22
|
+
it('should create a timestamp', () => {
|
|
23
|
+
const timestamp = ChannelDataPacketGenerator.createTimeStamp()
|
|
24
|
+
expect(timestamp).to.be.a('number')
|
|
29
25
|
})
|
|
30
26
|
|
|
31
|
-
it('should create an empty unpacked data file', ()=>{
|
|
32
|
-
const unpackedDataArr = ChannelDataPacketGenerator.createUnpackedDataArr(ChannelPayloadToTestFilters)
|
|
33
|
-
expect(unpackedDataArr).to.be.a('array')
|
|
27
|
+
it('should create an empty unpacked data file', () => {
|
|
28
|
+
const unpackedDataArr = ChannelDataPacketGenerator.createUnpackedDataArr(ChannelPayloadToTestFilters)
|
|
29
|
+
expect(unpackedDataArr).to.be.a('array')
|
|
34
30
|
})
|
|
35
31
|
|
|
36
|
-
it('should allow for predicate test filter on packed data ',()=>{
|
|
37
|
-
const map = new Map()
|
|
38
|
-
const label = ChannelDataPacketGenerator.createLabel()
|
|
39
|
-
map.set(label, ChannelPayloadToTestFilters)
|
|
32
|
+
it('should allow for predicate test filter on packed data ', () => {
|
|
33
|
+
const map = new Map()
|
|
34
|
+
const label = ChannelDataPacketGenerator.createLabel()
|
|
35
|
+
map.set(label, ChannelPayloadToTestFilters)
|
|
40
36
|
|
|
41
|
-
const filterGateway = ChannelDataPacketGenerator.createFilterGateway(label, map)
|
|
42
|
-
const pred = R.propEq('CHANNEL_ROUTE_CHANGE_EVENT', 'action')
|
|
37
|
+
const filterGateway = ChannelDataPacketGenerator.createFilterGateway(label, map)
|
|
38
|
+
const pred = R.propEq('CHANNEL_ROUTE_CHANGE_EVENT', 'action')
|
|
43
39
|
|
|
44
40
|
const isCorrectAction = filterGateway(pred)
|
|
45
41
|
|
|
46
|
-
expect(isCorrectAction).to.be.true
|
|
47
|
-
|
|
42
|
+
expect(isCorrectAction).to.be.true
|
|
48
43
|
})
|
|
49
44
|
|
|
50
|
-
it('should create data packet ',()=>{
|
|
51
|
-
const channelDataPacketGen = new ChannelDataPacketGenerator()
|
|
52
|
-
|
|
53
|
-
console.time('initPacket');
|
|
54
|
-
const channelDataPacket = channelDataPacketGen.createDataPacket(ChannelPayloadToTestFilters, ['channelName', 'action']);
|
|
55
|
-
//console.log('channel data packet ',channelDataPacket.props)
|
|
56
|
-
console.timeEnd('initPacket');
|
|
45
|
+
it('should create data packet ', () => {
|
|
46
|
+
const channelDataPacketGen = new ChannelDataPacketGenerator()
|
|
57
47
|
|
|
58
|
-
|
|
59
|
-
channelDataPacket
|
|
60
|
-
//console.log(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return true;
|
|
48
|
+
console.time('initPacket')
|
|
49
|
+
const channelDataPacket = channelDataPacketGen.createDataPacket(ChannelPayloadToTestFilters, ['channelName', 'action'])
|
|
50
|
+
// console.log('channel data packet ',channelDataPacket.props)
|
|
51
|
+
console.timeEnd('initPacket')
|
|
64
52
|
|
|
53
|
+
// console.log("CHANNEL DATA ALL ",channelDataPacket);
|
|
54
|
+
channelDataPacket.unPacked = true
|
|
55
|
+
// console.log("CHANNEL DATA ALL 2 ",channelDataPacket.srcElement);
|
|
65
56
|
|
|
57
|
+
return true
|
|
66
58
|
})
|
|
67
59
|
|
|
60
|
+
it('should create a stripped down unpacked data obj', () => {
|
|
61
|
+
const obj = {
|
|
62
|
+
type : 'dog',
|
|
63
|
+
says : 'woof'
|
|
64
|
+
}
|
|
68
65
|
|
|
66
|
+
const obj2 = {
|
|
67
|
+
type : 'cat',
|
|
68
|
+
says : 'meow',
|
|
69
|
+
_unpacked : false,
|
|
70
|
+
loc : 'dog'
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var obj = {
|
|
73
|
-
'type' : 'dog',
|
|
74
|
-
'says' : 'woof'
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
var obj2 = {
|
|
78
|
-
'type' : 'cat',
|
|
79
|
-
'says' : 'meow',
|
|
80
|
-
'_unpacked' : false,
|
|
81
|
-
'loc' : 'dog'
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
Object.defineProperty(obj2, 'unpacked', {
|
|
88
|
-
|
|
89
|
-
get: ()=>obj2._unpacked,
|
|
90
|
-
set: (b) => {
|
|
91
|
-
if(b===true){
|
|
92
|
-
obj2.type = window[obj2.loc].type;
|
|
93
|
-
obj2.says = window[obj2.loc].says;
|
|
94
|
-
obj2._unpacked = b;
|
|
95
|
-
}
|
|
72
|
+
}
|
|
96
73
|
|
|
74
|
+
Object.defineProperty(obj2, 'unpacked', {
|
|
97
75
|
|
|
76
|
+
get: () => obj2._unpacked,
|
|
77
|
+
set: (b) => {
|
|
78
|
+
if (b === true) {
|
|
79
|
+
obj2.type = window[obj2.loc].type
|
|
80
|
+
obj2.says = window[obj2.loc].says
|
|
81
|
+
obj2._unpacked = b
|
|
98
82
|
}
|
|
83
|
+
}
|
|
99
84
|
|
|
85
|
+
})
|
|
100
86
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
window['dog'] = obj;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
//console.log(' both objs is ',window.dog, obj2);
|
|
107
|
-
obj2.unpacked = true;
|
|
108
|
-
// console.log(' both objs is ',window.dog, obj2);
|
|
109
|
-
|
|
87
|
+
window.dog = obj
|
|
110
88
|
|
|
111
|
-
|
|
89
|
+
// console.log(' both objs is ',window.dog, obj2);
|
|
90
|
+
obj2.unpacked = true
|
|
91
|
+
// console.log(' both objs is ',window.dog, obj2);
|
|
112
92
|
|
|
93
|
+
return true
|
|
113
94
|
})
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
95
|
+
})
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { ChannelFetchUtil } from '../../spyne/utils/channel-fetch-util'
|
|
1
|
+
import { ChannelFetchUtil } from '../../spyne/utils/channel-fetch-util'
|
|
2
2
|
|
|
3
3
|
describe('ChannelFetchUtil Tests', () => {
|
|
4
4
|
const mapFn = (p) => {
|
|
5
|
-
console.log('mapping fetched data ', p)
|
|
6
|
-
return p
|
|
7
|
-
}
|
|
5
|
+
console.log('mapping fetched data ', p)
|
|
6
|
+
return p
|
|
7
|
+
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const url = 'https://jsonplaceholder.typicode.com/posts/1'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const props = {
|
|
12
12
|
mapFn,
|
|
13
13
|
url,
|
|
14
14
|
method: 'GET'
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
const propsPost = {
|
|
18
18
|
mapFn,
|
|
19
19
|
url,
|
|
20
20
|
method: 'POST',
|
|
@@ -24,109 +24,107 @@ describe('ChannelFetchUtil Tests', () => {
|
|
|
24
24
|
body: 'bar',
|
|
25
25
|
userId: 1
|
|
26
26
|
}
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const propsWBodyAsString = {
|
|
30
30
|
url,
|
|
31
31
|
method: 'POST',
|
|
32
32
|
body: 'bar'
|
|
33
|
-
}
|
|
33
|
+
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
35
|
+
const propsGetStringified = {
|
|
36
|
+
method: 'GET',
|
|
37
|
+
url: 'https://jsonplaceholder.typicode.com/posts/1'
|
|
38
|
+
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
40
|
+
const propsStringified = {
|
|
41
|
+
body: '{"id":101,"title":"foo","body":"bar","userId":1}',
|
|
42
|
+
method: 'POST',
|
|
43
|
+
url: 'https://jsonplaceholder.typicode.com/posts/1'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// const baseServerOptions = { method: 'GET', headers: { "Accept": "application/json, text/plain, */*" } };
|
|
45
47
|
|
|
46
|
-
const baseServerOptions =
|
|
48
|
+
const baseServerOptions = ChannelFetchUtil.baseOptions()
|
|
47
49
|
|
|
48
50
|
describe('stringify body method', () => {
|
|
49
51
|
it('should convert body object to string', () => {
|
|
50
|
-
let bodyStr = ChannelFetchUtil.stringifyBodyIfItExists(propsPost)
|
|
51
|
-
bodyStr = R.omit(['mapFn'], bodyStr)
|
|
52
|
-
expect(bodyStr).to.deep.equal(propsStringified)
|
|
53
|
-
})
|
|
52
|
+
let bodyStr = ChannelFetchUtil.stringifyBodyIfItExists(propsPost)
|
|
53
|
+
bodyStr = R.omit(['mapFn'], bodyStr)
|
|
54
|
+
expect(bodyStr).to.deep.equal(propsStringified)
|
|
55
|
+
})
|
|
54
56
|
|
|
55
57
|
it('should not parse body when its a string', () => {
|
|
56
|
-
|
|
58
|
+
const bodyStr = ChannelFetchUtil.stringifyBodyIfItExists(propsWBodyAsString)
|
|
57
59
|
|
|
58
|
-
expect(bodyStr).to.deep.equal(propsWBodyAsString)
|
|
59
|
-
})
|
|
60
|
+
expect(bodyStr).to.deep.equal(propsWBodyAsString)
|
|
61
|
+
})
|
|
60
62
|
|
|
61
63
|
it('should not add body param if its missing', () => {
|
|
62
|
-
let bodyStr = ChannelFetchUtil.stringifyBodyIfItExists(props)
|
|
63
|
-
bodyStr = R.omit(['mapFn'], bodyStr)
|
|
64
|
-
expect(bodyStr).to.deep.equal(propsGetStringified)
|
|
65
|
-
})
|
|
66
|
-
})
|
|
64
|
+
let bodyStr = ChannelFetchUtil.stringifyBodyIfItExists(props)
|
|
65
|
+
bodyStr = R.omit(['mapFn'], bodyStr)
|
|
66
|
+
expect(bodyStr).to.deep.equal(propsGetStringified)
|
|
67
|
+
})
|
|
68
|
+
})
|
|
67
69
|
|
|
68
70
|
describe('create a new fetch util', () => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
const subscriber = (data) => console.log('data retruned ', data)
|
|
72
|
+
const p = R.clone(props)
|
|
71
73
|
// p.responseType = 'text';
|
|
72
74
|
|
|
73
75
|
// console.log("PROPS P",p);
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
const channelFetchUtil = new ChannelFetchUtil(p, subscriber, true)
|
|
76
78
|
|
|
77
79
|
it('should return correct server option', () => {
|
|
78
|
-
|
|
79
|
-
expect(serverOptions).to.deep.equal(baseServerOptions)
|
|
80
|
-
})
|
|
80
|
+
const serverOptions = R.omit(['mapFn'], channelFetchUtil.serverOptions)
|
|
81
|
+
expect(serverOptions).to.deep.equal(baseServerOptions)
|
|
82
|
+
})
|
|
81
83
|
|
|
82
84
|
it('should return correct response type', () => {
|
|
83
|
-
expect(channelFetchUtil.responseType).to.equal('json')
|
|
84
|
-
})
|
|
85
|
+
expect(channelFetchUtil.responseType).to.equal('json')
|
|
86
|
+
})
|
|
85
87
|
|
|
86
88
|
it('should return correct url', () => {
|
|
87
|
-
expect(channelFetchUtil.url).to.equal(url)
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
|
|
89
|
+
expect(channelFetchUtil.url).to.equal(url)
|
|
90
|
+
})
|
|
91
|
+
})
|
|
91
92
|
|
|
92
|
-
/* describe('it should fetch an image', ()=>{
|
|
93
|
+
/* describe('it should fetch an image', ()=>{
|
|
93
94
|
let imgUrl = "http://localhost/spyne/src/tests/mocks/imgs/goat.jpg";
|
|
94
95
|
|
|
95
|
-
|
|
96
96
|
it ('should return the image', ()=>{
|
|
97
97
|
let channelFetchUtil = new ChannelFetchUtil({url:imgUrl, responseType:'blob'}, subscriber);
|
|
98
98
|
let subscriber = (data) => console.log('data retruned ', data);
|
|
99
99
|
|
|
100
|
-
|
|
101
100
|
return true;
|
|
102
101
|
})
|
|
103
102
|
|
|
104
|
-
|
|
105
|
-
});*/
|
|
103
|
+
}); */
|
|
106
104
|
|
|
107
105
|
describe('fetch util updates method to POST from GET when body exists', () => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
p.responseType = 'text'
|
|
111
|
-
p.body = { foo:'bar' }
|
|
106
|
+
const subscriber = (data) => console.log('data retruned ', data)
|
|
107
|
+
const p = R.omit(['method', 'mapFn'], props)
|
|
108
|
+
p.responseType = 'text'
|
|
109
|
+
p.body = { foo:'bar' }
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
const channelFetchUtil = new ChannelFetchUtil(p, subscriber, true)
|
|
114
112
|
|
|
115
113
|
it('should return correct server option', () => {
|
|
116
|
-
|
|
117
|
-
return true
|
|
118
|
-
})
|
|
114
|
+
const serverOptions = R.omit(['mapFn'], channelFetchUtil.serverOptions)
|
|
115
|
+
return true
|
|
116
|
+
})
|
|
119
117
|
|
|
120
118
|
it('should return correct response type', () => {
|
|
121
|
-
expect(channelFetchUtil.responseType).to.equal('text')
|
|
122
|
-
})
|
|
119
|
+
expect(channelFetchUtil.responseType).to.equal('text')
|
|
120
|
+
})
|
|
123
121
|
|
|
124
122
|
it('should return correct url', () => {
|
|
125
|
-
expect(channelFetchUtil.url).to.equal(url)
|
|
126
|
-
})
|
|
123
|
+
expect(channelFetchUtil.url).to.equal(url)
|
|
124
|
+
})
|
|
127
125
|
|
|
128
126
|
it('should return default mapFn', () => {
|
|
129
|
-
expect(channelFetchUtil.mapFn).to.be.a('function')
|
|
130
|
-
})
|
|
131
|
-
})
|
|
132
|
-
})
|
|
127
|
+
expect(channelFetchUtil.mapFn).to.be.a('function')
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
})
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import * as R from 'ramda'
|
|
2
|
-
import { findStrOrRegexMatchStr } from '../../spyne/utils/frp-tools'
|
|
3
|
-
import { ViewStreamHashMethodsObj } from '../mocks/utils-data'
|
|
1
|
+
import * as R from 'ramda'
|
|
2
|
+
import { findStrOrRegexMatchStr } from '../../spyne/utils/frp-tools'
|
|
3
|
+
import { ViewStreamHashMethodsObj } from '../mocks/utils-data'
|
|
4
4
|
|
|
5
|
-
const hashMethodsObj = ViewStreamHashMethodsObj
|
|
5
|
+
const hashMethodsObj = ViewStreamHashMethodsObj
|
|
6
6
|
|
|
7
7
|
describe('functional reactive methods tests', () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const methodStrFound = 'UI_EVENT_CLICK'
|
|
9
|
+
const methodRegExFound = 'UI_EVENT_FOCUS'
|
|
10
|
+
const methodNotFound = 'UI_EVEN1T_FOCUS33'
|
|
11
11
|
|
|
12
12
|
describe('should find first string match from regex', () => {
|
|
13
|
-
|
|
13
|
+
const findMethodName = findStrOrRegexMatchStr(hashMethodsObj, methodStrFound)
|
|
14
14
|
// console.log('str found ', findMethodName,methodStrFound );
|
|
15
15
|
|
|
16
|
-
expect(findMethodName).to.equal(methodStrFound)
|
|
17
|
-
})
|
|
16
|
+
expect(findMethodName).to.equal(methodStrFound)
|
|
17
|
+
})
|
|
18
18
|
|
|
19
19
|
describe('should not find the String, but the regex', () => {
|
|
20
|
-
|
|
20
|
+
const findMethodName = findStrOrRegexMatchStr(hashMethodsObj, methodRegExFound)
|
|
21
21
|
|
|
22
22
|
// console.log('regex found ', findMethodName, methodRegExFound );
|
|
23
|
-
expect(findMethodName).to.equal('UI_EVENT_.*')
|
|
24
|
-
})
|
|
23
|
+
expect(findMethodName).to.equal('UI_EVENT_.*')
|
|
24
|
+
})
|
|
25
25
|
|
|
26
26
|
describe('should not find the String, or the regex', () => {
|
|
27
|
-
|
|
27
|
+
const findMethodName = findStrOrRegexMatchStr(hashMethodsObj, methodNotFound)
|
|
28
28
|
// console.log('neither str or regex found ', findMethodName, methodNotFound );
|
|
29
29
|
// console.log(' -------- ');
|
|
30
|
-
expect(findMethodName).to.equal(undefined)
|
|
31
|
-
})
|
|
30
|
+
expect(findMethodName).to.equal(undefined)
|
|
31
|
+
})
|
|
32
32
|
|
|
33
33
|
describe('should pull in closure args and test for local match', () => {
|
|
34
|
-
return true
|
|
35
|
-
})
|
|
36
|
-
})
|
|
34
|
+
return true
|
|
35
|
+
})
|
|
36
|
+
})
|