Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit a7bdb9a

Browse files
author
Alan Shaw
authored
refactor: relax check for undefined property (#365)
If `x` has a property explicitly set to `undefined` then `expect(x).to.eql(y)` requires `y` to also have a property set to undefined. This PR relaxes that requirement to also allow `y` to simply not have the property. This is to save having to explicitly re-define this property to undefined when y has been `JSON.stringify`'d. This happens in the ipfs-postmsg-proxy and this change removes the need for the proxy to know the shape of this object (or at least which properties might have been undefined). License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent 0b37b57 commit a7bdb9a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

js/src/files/stat.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ module.exports = (createCommon, options) => {
5555

5656
ipfs.files.stat(`${testDir}/b`, (err, stat) => {
5757
expect(err).to.not.exist()
58-
expect(stat).to.eql({
58+
expect(stat).to.include({
5959
type: 'file',
6060
blocks: 1,
6161
size: 13,
6262
hash: 'QmcZojhwragQr5qhTeFAmELik623Z21e3jBTpJXoQ9si1T',
6363
cumulativeSize: 71,
64-
withLocality: false,
65-
local: undefined,
66-
sizeLocal: undefined
64+
withLocality: false
6765
})
66+
expect(stat.local).to.be.undefined()
67+
expect(stat.sizeLocal).to.be.undefined()
6868
done()
6969
})
7070
})
@@ -81,16 +81,16 @@ module.exports = (createCommon, options) => {
8181

8282
ipfs.files.stat(testDir, (err, stat) => {
8383
expect(err).to.not.exist()
84-
expect(stat).to.eql({
84+
expect(stat).to.include({
8585
type: 'directory',
8686
blocks: 1,
8787
size: 0,
8888
hash: 'QmQGn7EvzJZRbhcwHrp4UeMeS56WsLmrey9JhfkymjzXQu',
8989
cumulativeSize: 118,
90-
withLocality: false,
91-
local: undefined,
92-
sizeLocal: undefined
90+
withLocality: false
9391
})
92+
expect(stat.local).to.be.undefined()
93+
expect(stat.sizeLocal).to.be.undefined()
9494
done()
9595
})
9696
})
@@ -135,16 +135,16 @@ module.exports = (createCommon, options) => {
135135
it('should stat outside of mfs', function (done) {
136136
ipfs.files.stat('/ipfs/' + fixtures.smallFile.cid, (err, stat) => {
137137
expect(err).to.not.exist()
138-
expect(stat).to.eql({
138+
expect(stat).to.include({
139139
type: 'file',
140140
blocks: 0,
141141
size: 12,
142142
hash: fixtures.smallFile.cid,
143143
cumulativeSize: 20,
144-
withLocality: false,
145-
local: undefined,
146-
sizeLocal: undefined
144+
withLocality: false
147145
})
146+
expect(stat.local).to.be.undefined()
147+
expect(stat.sizeLocal).to.be.undefined()
148148
done()
149149
})
150150
})

0 commit comments

Comments
 (0)