3
3
const expect = require ( 'chai' ) . expect
4
4
const fs = require ( 'fs' )
5
5
6
- const UnixfsFormat = require ( '../src' ) . format
6
+ const UnixFS = require ( '../src' )
7
7
8
8
describe ( 'unixfs-format' , ( ) => {
9
9
it ( 'raw' , ( done ) => {
10
- const data = new UnixfsFormat ( 'raw' , new Buffer ( 'bananas' ) )
10
+ const data = new UnixFS ( 'raw' , new Buffer ( 'bananas' ) )
11
11
const marsheled = data . marshal ( )
12
- const unmarsheled = UnixfsFormat . unmarshal ( marsheled )
12
+ const unmarsheled = UnixFS . unmarshal ( marsheled )
13
13
expect ( data . type ) . to . equal ( unmarsheled . type )
14
14
expect ( data . data ) . to . deep . equal ( unmarsheled . data )
15
15
expect ( data . blockSizes ) . to . deep . equal ( unmarsheled . blockSizes )
@@ -18,9 +18,9 @@ describe('unixfs-format', () => {
18
18
} )
19
19
20
20
it ( 'directory' , ( done ) => {
21
- const data = new UnixfsFormat ( 'directory' )
21
+ const data = new UnixFS ( 'directory' )
22
22
const marsheled = data . marshal ( )
23
- const unmarsheled = UnixfsFormat . unmarshal ( marsheled )
23
+ const unmarsheled = UnixFS . unmarshal ( marsheled )
24
24
expect ( data . type ) . to . equal ( unmarsheled . type )
25
25
expect ( data . data ) . to . deep . equal ( unmarsheled . data )
26
26
expect ( data . blockSizes ) . to . deep . equal ( unmarsheled . blockSizes )
@@ -29,9 +29,9 @@ describe('unixfs-format', () => {
29
29
} )
30
30
31
31
it ( 'file' , ( done ) => {
32
- const data = new UnixfsFormat ( 'file' , new Buffer ( 'batata' ) )
32
+ const data = new UnixFS ( 'file' , new Buffer ( 'batata' ) )
33
33
const marsheled = data . marshal ( )
34
- const unmarsheled = UnixfsFormat . unmarshal ( marsheled )
34
+ const unmarsheled = UnixFS . unmarshal ( marsheled )
35
35
expect ( data . type ) . to . equal ( unmarsheled . type )
36
36
expect ( data . data ) . to . deep . equal ( unmarsheled . data )
37
37
expect ( data . blockSizes ) . to . deep . equal ( unmarsheled . blockSizes )
@@ -40,10 +40,10 @@ describe('unixfs-format', () => {
40
40
} )
41
41
42
42
it ( 'file add blocksize' , ( done ) => {
43
- const data = new UnixfsFormat ( 'file' )
43
+ const data = new UnixFS ( 'file' )
44
44
data . addBlockSize ( 256 )
45
45
const marsheled = data . marshal ( )
46
- const unmarsheled = UnixfsFormat . unmarshal ( marsheled )
46
+ const unmarsheled = UnixFS . unmarshal ( marsheled )
47
47
expect ( data . type ) . to . equal ( unmarsheled . type )
48
48
expect ( data . data ) . to . deep . equal ( unmarsheled . data )
49
49
expect ( data . blockSizes ) . to . deep . equal ( unmarsheled . blockSizes )
@@ -52,10 +52,10 @@ describe('unixfs-format', () => {
52
52
} )
53
53
54
54
it ( 'file add and remove blocksize' , ( done ) => {
55
- const data = new UnixfsFormat ( 'file' )
55
+ const data = new UnixFS ( 'file' )
56
56
data . addBlockSize ( 256 )
57
57
const marsheled = data . marshal ( )
58
- const unmarsheled = UnixfsFormat . unmarshal ( marsheled )
58
+ const unmarsheled = UnixFS . unmarshal ( marsheled )
59
59
expect ( data . type ) . to . equal ( unmarsheled . type )
60
60
expect ( data . data ) . to . deep . equal ( unmarsheled . data )
61
61
expect ( data . blockSizes ) . to . deep . equal ( unmarsheled . blockSizes )
@@ -69,9 +69,9 @@ describe('unixfs-format', () => {
69
69
it . skip ( 'metadata' , ( done ) => { } )
70
70
71
71
it ( 'symlink' , ( done ) => {
72
- const data = new UnixfsFormat ( 'symlink' )
72
+ const data = new UnixFS ( 'symlink' )
73
73
const marsheled = data . marshal ( )
74
- const unmarsheled = UnixfsFormat . unmarshal ( marsheled )
74
+ const unmarsheled = UnixFS . unmarshal ( marsheled )
75
75
expect ( data . type ) . to . equal ( unmarsheled . type )
76
76
expect ( data . data ) . to . deep . equal ( unmarsheled . data )
77
77
expect ( data . blockSizes ) . to . deep . equal ( unmarsheled . blockSizes )
@@ -81,7 +81,7 @@ describe('unixfs-format', () => {
81
81
it ( 'wrong type' , ( done ) => {
82
82
var data
83
83
try {
84
- data = new UnixfsFormat ( 'bananas' )
84
+ data = new UnixFS ( 'bananas' )
85
85
} catch ( err ) {
86
86
expect ( err ) . to . exist
87
87
expect ( data ) . to . not . exist
@@ -92,7 +92,7 @@ describe('unixfs-format', () => {
92
92
describe ( 'interop' , ( ) => {
93
93
it ( 'raw' , ( done ) => {
94
94
var raw = fs . readFileSync ( __dirname + '/test-data/raw.unixfs' )
95
- const unmarsheled = UnixfsFormat . unmarshal ( raw )
95
+ const unmarsheled = UnixFS . unmarshal ( raw )
96
96
expect ( unmarsheled . data ) . to . deep . equal ( new Buffer ( 'Hello UnixFS\n' ) )
97
97
expect ( unmarsheled . type ) . to . equal ( 'file' )
98
98
expect ( unmarsheled . marshal ( ) ) . to . deep . equal ( raw )
@@ -101,7 +101,7 @@ describe('unixfs-format', () => {
101
101
102
102
it ( 'directory' , ( done ) => {
103
103
var raw = fs . readFileSync ( __dirname + '/test-data/directory.unixfs' )
104
- const unmarsheled = UnixfsFormat . unmarshal ( raw )
104
+ const unmarsheled = UnixFS . unmarshal ( raw )
105
105
expect ( unmarsheled . data ) . to . deep . equal ( undefined )
106
106
expect ( unmarsheled . type ) . to . equal ( 'directory' )
107
107
expect ( unmarsheled . marshal ( ) ) . to . deep . equal ( raw )
@@ -110,7 +110,7 @@ describe('unixfs-format', () => {
110
110
111
111
it ( 'file' , ( done ) => {
112
112
var raw = fs . readFileSync ( __dirname + '/test-data/file.txt.unixfs' )
113
- const unmarsheled = UnixfsFormat . unmarshal ( raw )
113
+ const unmarsheled = UnixFS . unmarshal ( raw )
114
114
expect ( unmarsheled . data ) . to . deep . equal ( new Buffer ( 'Hello UnixFS\n' ) )
115
115
expect ( unmarsheled . type ) . to . equal ( 'file' )
116
116
expect ( unmarsheled . marshal ( ) ) . to . deep . equal ( raw )
@@ -122,7 +122,7 @@ describe('unixfs-format', () => {
122
122
123
123
it ( 'symlink' , ( done ) => {
124
124
var raw = fs . readFileSync ( __dirname + '/test-data/symlink.txt.unixfs' )
125
- const unmarsheled = UnixfsFormat . unmarshal ( raw )
125
+ const unmarsheled = UnixFS . unmarshal ( raw )
126
126
expect ( unmarsheled . data ) . to . deep . equal ( new Buffer ( 'file.txt' ) )
127
127
expect ( unmarsheled . type ) . to . equal ( 'symlink' )
128
128
// TODO: waiting on https://github.com/ipfs/js-ipfs-data-importing/issues/3#issuecomment-182440079
0 commit comments