@@ -79,37 +79,33 @@ describe('unixfs-format', () => {
79
79
expect ( data . blockSizes ) . to . not . deep . equal ( unmarshalled . blockSizes )
80
80
} )
81
81
82
- it ( 'default mode for files' , ( ) => {
82
+ it ( 'mode' , ( ) => {
83
+ const mode = parseInt ( '0555' , 8 )
83
84
const data = new UnixFS ( 'file' )
84
- expect ( data . mode ) . to . equal ( parseInt ( '0644' , 8 ) )
85
- const marshalled = data . marshal ( )
86
- const unmarshalled = UnixFS . unmarshal ( marshalled )
87
- expect ( unmarshalled . mode ) . to . equal ( parseInt ( '0644' , 8 ) )
88
- } )
85
+ data . mode = mode
89
86
90
- it ( 'default mode for directories' , ( ) => {
91
- const data = new UnixFS ( 'directory' )
92
- expect ( data . mode ) . to . equal ( parseInt ( '0755' , 8 ) )
93
- const marshalled = data . marshal ( )
94
- const unmarshalled = UnixFS . unmarshal ( marshalled )
95
- expect ( unmarshalled . mode ) . to . equal ( parseInt ( '0755' , 8 ) )
87
+ expect ( UnixFS . unmarshal ( data . marshal ( ) ) ) . to . have . property ( 'mode' , mode )
96
88
} )
97
89
98
- it ( 'default mode for hamt-sharded-directories' , ( ) => {
99
- const data = new UnixFS ( 'hamt-sharded-directory' )
100
- expect ( data . mode ) . to . equal ( parseInt ( '0755' , 8 ) )
101
- const marshalled = data . marshal ( )
102
- const unmarshalled = UnixFS . unmarshal ( marshalled )
103
- expect ( unmarshalled . mode ) . to . equal ( parseInt ( '0755' , 8 ) )
90
+ it ( 'removes mode' , ( ) => {
91
+ const mode = parseInt ( '0555' , 8 )
92
+ const data = new UnixFS ( 'file' )
93
+ data . mode = mode
94
+
95
+ const unmarshalled = UnixFS . unmarshal ( data . marshal ( ) )
96
+ expect ( unmarshalled ) . to . have . property ( 'mode' , mode )
97
+
98
+ delete unmarshalled . mode
99
+
100
+ expect ( UnixFS . unmarshal ( unmarshalled . marshal ( ) ) ) . to . not . have . property ( 'mode' )
104
101
} )
105
102
106
- it ( 'mode' , ( ) => {
107
- const mode = parseInt ( '0555' , 8 )
103
+ it ( 'sets mode to 0 ' , ( ) => {
104
+ const mode = 0
108
105
const data = new UnixFS ( 'file' )
109
106
data . mode = mode
110
- const marshalled = data . marshal ( )
111
- const unmarshalled = UnixFS . unmarshal ( marshalled )
112
- expect ( unmarshalled . mode ) . to . equal ( mode )
107
+
108
+ expect ( UnixFS . unmarshal ( data . marshal ( ) ) ) . to . have . property ( 'mode' , mode )
113
109
} )
114
110
115
111
it ( 'mtime' , ( ) => {
@@ -121,6 +117,27 @@ describe('unixfs-format', () => {
121
117
expect ( unmarshalled . mtime ) . to . equal ( mtime )
122
118
} )
123
119
120
+ it ( 'removes mtime' , ( ) => {
121
+ const mtime = parseInt ( Date . now ( ) / 1000 )
122
+ const data = new UnixFS ( 'file' )
123
+ data . mtime = mtime
124
+
125
+ const unmarshalled = UnixFS . unmarshal ( data . marshal ( ) )
126
+ expect ( unmarshalled ) . to . have . property ( 'mtime' , mtime )
127
+
128
+ delete unmarshalled . mtime
129
+
130
+ expect ( UnixFS . unmarshal ( unmarshalled . marshal ( ) ) ) . to . not . have . property ( 'mtime' )
131
+ } )
132
+
133
+ it ( 'sets mtime to 0' , ( ) => {
134
+ const mtime = 0
135
+ const data = new UnixFS ( 'file' )
136
+ data . mtime = mtime
137
+
138
+ expect ( UnixFS . unmarshal ( data . marshal ( ) ) ) . to . have . property ( 'mtime' , mtime )
139
+ } )
140
+
124
141
// figuring out what is this metadata for https://github.com/ipfs/js-ipfs-data-importing/issues/3#issuecomment-182336526
125
142
it . skip ( 'metadata' , ( ) => { } )
126
143
0 commit comments