This repository was archived by the owner on Jul 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +73
-0
lines changed Expand file tree Collapse file tree 2 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,43 @@ describe('merge', () => {
174
174
expect ( updated ) . to . have . property ( 'peerRecordEnvelope' ) . that . deep . equals ( original . peerRecordEnvelope )
175
175
} )
176
176
177
+ it ( 'merges protocols' , async ( ) => {
178
+ const peer : PeerData = {
179
+ multiaddrs : [
180
+ addr1 ,
181
+ addr2
182
+ ] ,
183
+ metadata : {
184
+ foo : Uint8Array . from ( [ 0 , 1 , 2 ] )
185
+ } ,
186
+ tags : {
187
+ tag1 : { value : 10 }
188
+ } ,
189
+ protocols : [
190
+ '/foo/bar'
191
+ ] ,
192
+ peerRecordEnvelope : Uint8Array . from ( [ 3 , 4 , 5 ] )
193
+ }
194
+
195
+ const original = await peerStore . save ( otherPeerId , peer )
196
+ const updated = await peerStore . merge ( otherPeerId , {
197
+ protocols : [
198
+ '/bar/foo'
199
+ ]
200
+ } )
201
+
202
+ expect ( updated ) . to . have . property ( 'protocols' ) . that . deep . equals ( [
203
+ '/bar/foo' ,
204
+ '/foo/bar'
205
+ ] )
206
+
207
+ // other fields should be untouched
208
+ expect ( updated ) . to . have . property ( 'addresses' ) . that . deep . equals ( original . addresses )
209
+ expect ( updated ) . to . have . property ( 'metadata' ) . that . deep . equals ( original . metadata )
210
+ expect ( updated ) . to . have . property ( 'tags' ) . that . deep . equals ( original . tags )
211
+ expect ( updated ) . to . have . property ( 'peerRecordEnvelope' ) . that . deep . equals ( original . peerRecordEnvelope )
212
+ } )
213
+
177
214
it ( 'merges peer record envelope' , async ( ) => {
178
215
const peer : PeerData = {
179
216
multiaddrs : [
Original file line number Diff line number Diff line change @@ -159,6 +159,42 @@ describe('patch', () => {
159
159
expect ( updated ) . to . have . property ( 'peerRecordEnvelope' ) . that . deep . equals ( original . peerRecordEnvelope )
160
160
} )
161
161
162
+ it ( 'replaces protocols' , async ( ) => {
163
+ const peer : PeerData = {
164
+ multiaddrs : [
165
+ addr1 ,
166
+ addr2
167
+ ] ,
168
+ metadata : {
169
+ foo : Uint8Array . from ( [ 0 , 1 , 2 ] )
170
+ } ,
171
+ tags : {
172
+ tag1 : { value : 10 }
173
+ } ,
174
+ protocols : [
175
+ '/foo/bar'
176
+ ] ,
177
+ peerRecordEnvelope : Uint8Array . from ( [ 3 , 4 , 5 ] )
178
+ }
179
+
180
+ const original = await peerStore . save ( otherPeerId , peer )
181
+ const updated = await peerStore . patch ( otherPeerId , {
182
+ protocols : [
183
+ '/bar/foo'
184
+ ]
185
+ } )
186
+
187
+ expect ( updated ) . to . have . property ( 'protocols' ) . that . deep . equals ( [
188
+ '/bar/foo'
189
+ ] )
190
+
191
+ // other fields should be untouched
192
+ expect ( updated ) . to . have . property ( 'addresses' ) . that . deep . equals ( original . addresses )
193
+ expect ( updated ) . to . have . property ( 'metadata' ) . that . deep . equals ( original . metadata )
194
+ expect ( updated ) . to . have . property ( 'tags' ) . that . deep . equals ( original . tags )
195
+ expect ( updated ) . to . have . property ( 'peerRecordEnvelope' ) . that . deep . equals ( original . peerRecordEnvelope )
196
+ } )
197
+
162
198
it ( 'replaces peer record envelope' , async ( ) => {
163
199
const peer : PeerData = {
164
200
multiaddrs : [
You can’t perform that action at this time.
0 commit comments