Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

test: remove @ts-expect-errors for this being mocha #4250

Merged
merged 4 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@
"workspaces": [
"packages/*"
]
}
}
20 changes: 2 additions & 18 deletions packages/interface-ipfs-core/src/add-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ export function testAddAll (factory, options) {

it('should add a File as array of tuples', async function () {
if (!supportsFileReader) {
// @ts-expect-error this is mocha
return this.skip('skip in node')
return this.skip()
}

const tuple = {
Expand All @@ -102,8 +101,7 @@ export function testAddAll (factory, options) {

it('should add array of objects with readable stream content', async function () {
if (!isNode) {
// @ts-expect-error this is mocha
this.skip('Only node supports readable streams')
this.skip()
}

const expectedCid = 'QmVv4Wz46JaZJeH5PMV4LGbRiiMKEmszPYY3g6fjGnVXBS'
Expand Down Expand Up @@ -336,7 +334,6 @@ export function testAddAll (factory, options) {
})

it('should add a directory with only-hash=true', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const content = String(Math.random() + Date.now())

Expand All @@ -358,21 +355,18 @@ export function testAddAll (factory, options) {
})

it('should add with mode as string', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const mode = '0777'
await testMode(mode, parseInt(mode, 8))
})

it('should add with mode as number', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const mode = parseInt('0777', 8)
await testMode(mode, mode)
})

it('should add with mtime as Date', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const mtime = new Date(5000)
await testMtime(mtime, {
Expand All @@ -382,7 +376,6 @@ export function testAddAll (factory, options) {
})

it('should add with mtime as { nsecs, secs }', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const mtime = {
secs: 5,
Expand All @@ -392,7 +385,6 @@ export function testAddAll (factory, options) {
})

it('should add with mtime as timespec', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
await testMtime({
Seconds: 5,
Expand All @@ -404,7 +396,6 @@ export function testAddAll (factory, options) {
})

it('should add with mtime as hrtime', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const mtime = process.hrtime()
await testMtime(mtime, {
Expand All @@ -414,7 +405,6 @@ export function testAddAll (factory, options) {
})

it('should add a directory from the file system', async function () {
// @ts-expect-error this is mocha
if (!isNode) this.skip()
const filesPath = resolve('test/fixtures/test-folder', 'interface-ipfs-core')

Expand All @@ -423,7 +413,6 @@ export function testAddAll (factory, options) {
})

it('should add a directory from the file system with an odd name', async function () {
// @ts-expect-error this is mocha
if (!isNode) this.skip()

const filesPath = resolve('test/fixtures/weird name folder [v0]', 'interface-ipfs-core')
Expand All @@ -433,7 +422,6 @@ export function testAddAll (factory, options) {
})

it('should ignore a directory from the file system', async function () {
// @ts-expect-error this is mocha
if (!isNode) this.skip()

const filesPath = resolve('test/fixtures/test-folder', 'interface-ipfs-core')
Expand All @@ -443,7 +431,6 @@ export function testAddAll (factory, options) {
})

it('should add a file from the file system', async function () {
// @ts-expect-error this is mocha
if (!isNode) this.skip()

const filePath = resolve('test/fixtures/test-folder', 'interface-ipfs-core')
Expand All @@ -454,7 +441,6 @@ export function testAddAll (factory, options) {
})

it('should add a hidden file in a directory from the file system', async function () {
// @ts-expect-error this is mocha
if (!isNode) this.skip()

const filesPath = resolve('test/fixtures', 'interface-ipfs-core')
Expand All @@ -465,10 +451,8 @@ export function testAddAll (factory, options) {
})

it('should add a file with only-hash=true', async function () {
// @ts-expect-error this is mocha
if (!isNode) this.skip()

// @ts-expect-error this is mocha
this.slow(10 * 1000)

const out = await all(ipfs.addAll([{
Expand Down
14 changes: 2 additions & 12 deletions packages/interface-ipfs-core/src/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ export function testAdd (factory, options) {

it('should add a File', async function () {
if (!supportsFileReader) {
// @ts-expect-error this is mocha
return this.skip('skip in node')
return this.skip()
}

const fileAdded = await ipfs.add(new File(['should add a File'], 'filename.txt', { type: 'text/plain' }))
Expand All @@ -83,8 +82,7 @@ export function testAdd (factory, options) {

it('should add a File as tuple', async function () {
if (!supportsFileReader) {
// @ts-expect-error this is mocha
return this.skip('skip in node')
return this.skip()
}

const tuple = {
Expand Down Expand Up @@ -212,7 +210,6 @@ export function testAdd (factory, options) {

it('should add readable stream', async function () {
if (!isNode) {
// @ts-expect-error this is mocha
this.skip()
}
const expectedCid = 'QmVv4Wz46JaZJeH5PMV4LGbRiiMKEmszPYY3g6fjGnVXBS'
Expand Down Expand Up @@ -264,7 +261,6 @@ export function testAdd (factory, options) {
})

it('should add with only-hash=true', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const content = String(Math.random() + Date.now())

Expand Down Expand Up @@ -292,21 +288,18 @@ export function testAdd (factory, options) {
})

it('should add with mode as string', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const mode = '0777'
await testMode(mode, parseInt(mode, 8))
})

it('should add with mode as number', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const mode = parseInt('0777', 8)
await testMode(mode, mode)
})

it('should add with mtime as Date', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const mtime = new Date(5000)
await testMtime(mtime, {
Expand All @@ -316,7 +309,6 @@ export function testAdd (factory, options) {
})

it('should add with mtime as { nsecs, secs }', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const mtime = {
secs: 5,
Expand All @@ -326,7 +318,6 @@ export function testAdd (factory, options) {
})

it('should add with mtime as timespec', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
await testMtime({
Seconds: 5,
Expand All @@ -338,7 +329,6 @@ export function testAdd (factory, options) {
})

it('should add with mtime as hrtime', async function () {
// @ts-expect-error this is mocha
this.slow(10 * 1000)
const mtime = process.hrtime()
await testMtime(mtime, {
Expand Down
2 changes: 0 additions & 2 deletions packages/interface-ipfs-core/src/dag/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export function testExport (factory, options) {
})

it('export of shuffled devnet export identical to canonical original', async function () {
// @ts-expect-error this is mocha
this.timeout(360000)

const input = loadFixture('test/fixtures/car/lotus_devnet_genesis.car', 'interface-ipfs-core')
Expand All @@ -83,7 +82,6 @@ export function testExport (factory, options) {
})

it('export of shuffled testnet export identical to canonical original', async function () {
// @ts-expect-error this is mocha
this.timeout(360000)

const input = loadFixture('test/fixtures/car/lotus_testnet_export_128.car', 'interface-ipfs-core')
Expand Down
3 changes: 0 additions & 3 deletions packages/interface-ipfs-core/src/files/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export function testTouch (factory, options) {
after(() => factory.clean())

it('should have default mtime', async function () {
// @ts-expect-error this is mocha
this.slow(5 * 1000)
const testPath = `/test-${nanoid()}`

Expand All @@ -74,7 +73,6 @@ export function testTouch (factory, options) {
})

it('should update file mtime', async function () {
// @ts-expect-error this is mocha
this.slow(5 * 1000)
const testPath = `/test-${nanoid()}`
const mtime = new Date()
Expand All @@ -92,7 +90,6 @@ export function testTouch (factory, options) {
})

it('should update directory mtime', async function () {
// @ts-expect-error this is mocha
this.slow(5 * 1000)
const testPath = `/test-${nanoid()}`
const mtime = new Date()
Expand Down
2 changes: 0 additions & 2 deletions packages/interface-ipfs-core/src/files/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export function testWrite (factory, options) {

it('writes a small file using a Node stream (Node only)', async function () {
if (!isNode) {
// @ts-expect-error this is mocha
this.skip()
}
const filePath = `/small-file-${Math.random()}.txt`
Expand All @@ -205,7 +204,6 @@ export function testWrite (factory, options) {

it('writes a small file using an HTML5 Blob (Browser only)', async function () {
if (!global.Blob || !global.FileReader) {
// @ts-expect-error this is mocha
return this.skip()
}

Expand Down
4 changes: 1 addition & 3 deletions packages/interface-ipfs-core/src/key/gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export function testGen (factory, options) {

keyTypes.forEach((kt) => {
it(`should generate a new ${kt.opts.type || 'default'} key`, async function () {
// @ts-expect-error this is mocha
this.timeout(20 * 1000)
const name = nanoid()
const key = await ipfs.key.gen(name, kt.opts)
Expand All @@ -61,8 +60,7 @@ export function testGen (factory, options) {
} catch (/** @type {any} */ err) {
if (err.code === 'ERR_NOT_IMPLEMENTED') {
// key export is not exposed over the HTTP API
// @ts-expect-error this is mocha
this.skip('Cannot verify key type')
this.skip()
}

throw err
Expand Down
1 change: 0 additions & 1 deletion packages/interface-ipfs-core/src/key/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function testList (factory, options) {
after(() => factory.clean())

it('should list all the keys', async function () {
// @ts-expect-error this is mocha
this.timeout(60 * 1000)

const keys = await Promise.all([1, 2, 3].map(() => ipfs.key.gen(nanoid(), { type: 'rsa', size: 2048 })))
Expand Down
1 change: 0 additions & 1 deletion packages/interface-ipfs-core/src/key/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function testRename (factory, options) {
after(() => factory.clean())

it('should rename a key', async function () {
// @ts-expect-error this is mocha
this.timeout(30 * 1000)

const oldName = nanoid()
Expand Down
1 change: 0 additions & 1 deletion packages/interface-ipfs-core/src/key/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function testRm (factory, options) {
after(() => factory.clean())

it('should rm a key', async function () {
// @ts-expect-error this is mocha
this.timeout(30 * 1000)

const key = await ipfs.key.gen(nanoid(), { type: 'rsa', size: 2048 })
Expand Down
6 changes: 0 additions & 6 deletions packages/interface-ipfs-core/src/miscellaneous/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ export function testDns (factory, options) {
expect(res).to.match(/\/ipns\/.+$/)
} catch (/** @type {any} */ err) {
if (err.message.includes('could not resolve name')) {
// @ts-expect-error this is mocha
return this.skip()
}

// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

Expand All @@ -62,13 +60,11 @@ export function testDns (factory, options) {
expect(res).to.match(/\/ipfs\/.+$/)
} catch (/** @type {any} */ err) {
if (err.message.includes('could not resolve name')) {
// @ts-expect-error this is mocha
return this.skip()
}

// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

Expand All @@ -86,13 +82,11 @@ export function testDns (factory, options) {
expect(res).to.match(/\/ipfs\/.+$/)
} catch (/** @type {any} */ err) {
if (err.message.includes('could not resolve name')) {
// @ts-expect-error this is mocha
return this.skip()
}

// happens when running tests offline
if (err.message.includes(`ECONNREFUSED ${domain}`)) {
// @ts-expect-error this is mocha
return this.skip()
}

Expand Down
2 changes: 0 additions & 2 deletions packages/interface-ipfs-core/src/miscellaneous/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export function testId (factory, options) {
it('should return swarm ports opened after startup', async function () {
if (isWebWorker) {
// TODO: webworkers are not currently dialable
// @ts-expect-error this is mocha
return this.skip()
}

Expand All @@ -69,7 +68,6 @@ export function testId (factory, options) {
it('should get the id of another node in the swarm', async function () {
if (isWebWorker) {
// TODO: https://github.com/libp2p/js-libp2p-websockets/issues/129
// @ts-expect-error this is mocha
return this.skip()
}

Expand Down
Loading