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

Commit 265b610

Browse files
committed
chore: fix linting
License: MIT Signed-off-by: achingbrain <alex@achingbrain.net>
1 parent d832277 commit 265b610

File tree

1 file changed

+33
-34
lines changed

1 file changed

+33
-34
lines changed

test/ls.spec.js

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,19 @@ describe('ls', function () {
8080

8181
methods.forEach(method => {
8282
describe(`ls ${method.name}`, function () {
83-
it('lists the root directory by default', () => {
83+
it('lists the root directory by default', async () => {
8484
const fileName = `small-file-${Math.random()}.txt`
8585
const content = Buffer.from('Hello world')
86-
87-
return mfs.write(`/${fileName}`, content, {
86+
87+
await mfs.write(`/${fileName}`, content, {
8888
create: true
8989
})
90-
.then(() => method.ls())
91-
.then((result) => method.collect(result))
92-
.then(files => {
93-
expect(files.find(file => file.name === fileName)).to.be.ok()
94-
})
90+
const result = await method.ls()
91+
const files = await method.collect(result)
92+
93+
expect(files.find(file => file.name === fileName)).to.be.ok()
9594
})
96-
95+
9796
it('refuses to lists files with an empty path', () => {
9897
return method.ls('')
9998
.then((result) => method.collect(result))
@@ -104,7 +103,7 @@ describe('ls', function () {
104103
expect(error.message).to.contain('paths must not be empty')
105104
})
106105
})
107-
106+
108107
it('refuses to lists files with an invalid path', () => {
109108
return method.ls('not-valid')
110109
.then((result) => method.collect(result))
@@ -115,12 +114,12 @@ describe('ls', function () {
115114
expect(error.message).to.contain('paths must start with a leading /')
116115
})
117116
})
118-
117+
119118
it('lists files in a directory', () => {
120119
const dirName = `dir-${Math.random()}`
121120
const fileName = `small-file-${Math.random()}.txt`
122121
const content = Buffer.from('Hello world')
123-
122+
124123
return mfs.write(`/${dirName}/${fileName}`, content, {
125124
create: true,
126125
parents: true
@@ -135,12 +134,12 @@ describe('ls', function () {
135134
expect(files[0].hash).to.equal('')
136135
})
137136
})
138-
137+
139138
it('lists files in a directory with meta data', () => {
140139
const dirName = `dir-${Math.random()}`
141140
const fileName = `small-file-${Math.random()}.txt`
142141
const content = Buffer.from('Hello world')
143-
142+
144143
return mfs.write(`/${dirName}/${fileName}`, content, {
145144
create: true,
146145
parents: true
@@ -156,11 +155,11 @@ describe('ls', function () {
156155
expect(files[0].size).to.equal(content.length)
157156
})
158157
})
159-
158+
160159
it('lists a file', () => {
161160
const fileName = `small-file-${Math.random()}.txt`
162161
const content = Buffer.from('Hello world')
163-
162+
164163
return mfs.write(`/${fileName}`, content, {
165164
create: true
166165
})
@@ -174,11 +173,11 @@ describe('ls', function () {
174173
expect(files[0].hash).to.equal('')
175174
})
176175
})
177-
176+
178177
it('lists a file with meta data', () => {
179178
const fileName = `small-file-${Math.random()}.txt`
180179
const content = Buffer.from('Hello world')
181-
180+
182181
return mfs.write(`/${fileName}`, content, {
183182
create: true
184183
})
@@ -193,11 +192,11 @@ describe('ls', function () {
193192
expect(files[0].size).to.equal(content.length)
194193
})
195194
})
196-
195+
197196
it('lists a file with a base32 hash', () => {
198197
const fileName = `small-file-${Math.random()}.txt`
199198
const content = Buffer.from('Hello world')
200-
199+
201200
return mfs.write(`/${fileName}`, content, {
202201
create: true
203202
})
@@ -214,7 +213,7 @@ describe('ls', function () {
214213
expect(files[0].hash.startsWith('b')).to.equal(true)
215214
})
216215
})
217-
216+
218217
it('fails to list non-existent file', () => {
219218
return method.ls('/i-do-not-exist')
220219
.then((result) => method.collect(result))
@@ -225,53 +224,53 @@ describe('ls', function () {
225224
expect(error.message).to.contain('does not exist')
226225
})
227226
})
228-
227+
229228
it('lists a sharded directory contents', async () => {
230229
const shardSplitThreshold = 10
231230
const fileCount = 11
232231
const dirPath = await createShardedDirectory(mfs, shardSplitThreshold, fileCount)
233-
232+
234233
const files = await method.collect(await method.ls(dirPath, {
235234
long: true
236235
}))
237-
236+
238237
expect(files.length).to.equal(fileCount)
239-
238+
240239
files.forEach(file => {
241240
// should be a file
242241
expect(file.type).to.equal(0)
243242
})
244243
})
245-
244+
246245
it('lists a file inside a sharded directory directly', async () => {
247246
const dirPath = await createShardedDirectory(mfs)
248-
249-
const files = await method.collect(await method.ls(dirPath, {
247+
248+
const files = await method.collect(await method.ls(dirPath, {
250249
long: true
251250
}))
252-
251+
253252
const filePath = `${dirPath}/${files[0].name}`
254-
253+
255254
// should be able to ls new file directly
256255
expect(await method.collect(await method.ls(filePath, {
257256
long: true
258257
}))).to.not.be.empty()
259258
})
260-
259+
261260
it('lists the contents of a directory inside a sharded directory', async () => {
262261
const shardedDirPath = await createShardedDirectory(mfs)
263262
const dirPath = `${shardedDirPath}/subdir-${Math.random()}`
264263
const fileName = `small-file-${Math.random()}.txt`
265-
264+
266265
await mfs.mkdir(`${dirPath}`)
267266
await mfs.write(`${dirPath}/${fileName}`, Buffer.from([0, 1, 2, 3]), {
268267
create: true
269268
})
270-
269+
271270
const files = await method.collect(await method.ls(dirPath, {
272271
long: true
273272
}))
274-
273+
275274
expect(files.length).to.equal(1)
276275
expect(files.filter(file => file.name === fileName)).to.be.ok()
277276
})

0 commit comments

Comments
 (0)