Skip to content

Commit 394192d

Browse files
committed
chore: remove backward compatiblity tests
read-package-json and read-package-json-fast test were initially put in place to ensure this package was fully compatible. This package is now used almost everywhere in npm, and the things we are adding to finish the removal of those other packages is MORE correct here than in those old packages, so the tests won't even work anymore.
1 parent a8b1cc9 commit 394192d

2 files changed

Lines changed: 4 additions & 39 deletions

File tree

test/normalize.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const t = require('tap')
2-
const { join } = require('node:path')
32
const pkg = require('../')
4-
const rpj = require('read-package-json-fast')
53

64
const testMethods = {
75
// eslint-disable-next-line max-len
@@ -17,15 +15,9 @@ const testMethods = {
1715
const p = t.testdir(testdir)
1816
return pkg.normalize(dir(p), opts)
1917
},
20-
'read-package-json-fast': (t, testdir = {}, { dir = (v) => v } = {}) => {
21-
const p = t.testdir(testdir)
22-
return rpj(join(dir(p), 'package.json')).then(r => ({ content: r }))
23-
},
2418
}
2519

2620
for (const [name, testNormalize] of Object.entries(testMethods)) {
27-
const isLegacy = name === 'read-package-json-fast'
28-
2921
t.test(name, async t => {
3022
t.test('errors for bad/missing data', async t => {
3123
t.test('raises an error for missing file', t =>
@@ -352,9 +344,6 @@ for (const [name, testNormalize] of Object.entries(testMethods)) {
352344
})
353345

354346
t.test('skipping steps', async t => {
355-
if (isLegacy) {
356-
return t.skip('rpj does not have configurable steps')
357-
}
358347
const packageJson = {
359348
_lodash: true,
360349
dependencies: { a: '' },

test/prepare.js

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,9 @@ const testMethods = {
1616
res.logs = logs
1717
return res
1818
},
19-
'read-package-json': (t, testdir, { dir = (v) => v } = {}) => {
20-
const p = t.testdir(testdir)
21-
const rpj = t.mock('read-package-json') // reset rpj caches
22-
const logs = []
23-
const logger = (...a) => logs.push(a.slice(1))
24-
return new Promise((res, rej) => {
25-
rpj(join(dir(p), 'package.json'), logger, (err, content) => {
26-
if (err) {
27-
rej(err)
28-
} else {
29-
res({ content, logs })
30-
}
31-
})
32-
})
33-
},
3419
}
3520

3621
for (const [name, testPrepare] of Object.entries(testMethods)) {
37-
const isLegacy = name === 'read-package-json'
3822
t.test(name, async t => {
3923
t.test('errors for bad/missing data', async t => {
4024
t.test('invalid version', t =>
@@ -562,8 +546,7 @@ for (const [name, testPrepare] of Object.entries(testMethods)) {
562546
testgitref: 'filegitref',
563547
},
564548
}), { dir: (p) => join(p, 'sub'), root: true })
565-
// rpj has no way prevent walking up all directories
566-
t.strictSame(content.gitHead, isLegacy ? 'filegitref' : undefined)
549+
t.strictSame(content.gitHead, undefined)
567550
})
568551
t.end()
569552
})
@@ -653,9 +636,6 @@ for (const [name, testPrepare] of Object.entries(testMethods)) {
653636
})
654637

655638
t.test('skipping steps', async t => {
656-
if (isLegacy) {
657-
return t.skip('rpj does not have configurable steps')
658-
}
659639
const packageJson = {
660640
scripts: { test: './node_modules/.bin/test' },
661641
main: './custom-path.js',
@@ -732,13 +712,9 @@ for (const [name, testPrepare] of Object.entries(testMethods)) {
732712
readme: 'ERROR: No README data found!',
733713
gitHead: 'testgitref',
734714
})
735-
if (isLegacy) {
736-
t.skip('rpj does not save files')
737-
} else {
738-
await t.rejects(parsed.save(), {
739-
message: /No package.json/,
740-
})
741-
}
715+
await t.rejects(parsed.save(), {
716+
message: /No package.json/,
717+
})
742718
})
743719
t.end()
744720
})

0 commit comments

Comments
 (0)