Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Commit

Permalink
fix(test): update pkgmap tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Oct 15, 2018
1 parent 6612fcb commit 95e0f59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
4 changes: 0 additions & 4 deletions lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ const writeFileAsync = BB.promisify(fs.writeFile)
class Installer {
constructor (opts) {
this.opts = config(opts)
this.opts = this.opts.concat({
cache: path.join(this.opts.cache, '_cacache')
})

// Stats
this.startTime = Date.now()
Expand Down Expand Up @@ -337,7 +334,6 @@ class Installer {
const lockStr = JSON.stringify(this.pkg._shrinkwrap)
const lockHash = ssri.fromData(lockStr, {algorithms: ['sha256']})
const pkgMap = {
'cache': this.opts.cache,
'lockfile_integrity': lockHash.toString(),
'path_prefix': '/.package-map.json'
}
Expand Down
22 changes: 7 additions & 15 deletions test/pkgmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ const pkgmap = require('../lib/pkgmap.js')

test('resolve: finds an existing path into a .package-map.json', async t => {
process.tink = {
opts: {
cache: './here'
}
cache: './here'
}
const fixture = new Tacks(Dir({
'.package-map.json': File({
Expand Down Expand Up @@ -48,7 +46,7 @@ test('resolve: finds an existing path into a .package-map.json', async t => {
}))
fixture.create(testDir.path)
const prefix = path.join(testDir.path, '.package-map.json', 'eggplant')
t.deepEqual(pkgmap.resolve(prefix, 'hello.js'), {
t.similar(pkgmap.resolve(prefix, 'hello.js'), {
cache: './here',
hash: 'sha1-deadbeef',
pkg: {
Expand All @@ -59,7 +57,7 @@ test('resolve: finds an existing path into a .package-map.json', async t => {
}, 'found file spec inside a package-map')
t.equal(pkgmap.resolve(prefix, 'goodbye.js'), false, 'null on missing file')
const nested = path.join(prefix, 'node_modules', 'aubergine')
t.deepEqual(pkgmap.resolve(nested, 'bonjour.js'), {
t.similar(pkgmap.resolve(nested, 'bonjour.js'), {
cache: './here',
hash: 'sha1-badc0ffee',
pkg: {
Expand All @@ -69,7 +67,7 @@ test('resolve: finds an existing path into a .package-map.json', async t => {
}
}, 'found nested file spec inside a package-map')
const scoped = path.join(prefix, 'node_modules', '@myscope/scoped')
t.deepEqual(pkgmap.resolve(scoped, 'ohmy.js'), {
t.similar(pkgmap.resolve(scoped, 'ohmy.js'), {
cache: './here',
hash: 'sha1-abcdef',
pkg: {
Expand All @@ -79,7 +77,7 @@ test('resolve: finds an existing path into a .package-map.json', async t => {
}
}, 'found nested scoped spec inside a package-map')
rimraf.sync(path.join(testDir.path))
t.deepEqual(pkgmap.resolve(prefix, 'hello.js'), {
t.similar(pkgmap.resolve(prefix, 'hello.js'), {
cache: './here',
hash: 'sha1-deadbeef',
pkg: {
Expand All @@ -97,13 +95,10 @@ test('read: reads a file defined in a package map', async t => {
const cacheDir = path.join(testDir.path, '_cacache')
const hash = await cacache.put(cacheDir, 'eggplant:hello', 'hello world')
process.tink = {
opts: {
cache: cacheDir
}
cache: cacheDir
}
const fixture = new Tacks(Dir({
'.package-map.json': File({
cache: cacheDir,
path_prefix: '/.package-map.json',
packages: {
'eggplant': {
Expand Down Expand Up @@ -137,13 +132,10 @@ test('stat: get filesystem stats for a file', async t => {
const cacheDir = path.join(testDir.path, '_cacache')
const hash = await cacache.put(cacheDir, 'eggplant:hello', 'hello world')
process.tink = {
opts: {
cache: cacheDir
}
cache: cacheDir
}
const fixture = new Tacks(Dir({
'.package-map.json': File({
cache: cacheDir,
path_prefix: '/.package-map.json',
packages: {
'eggplant': {
Expand Down

0 comments on commit 95e0f59

Please sign in to comment.