-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make add command working with latest tag if offline or preferOffline …
…is setted (#2521)
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -630,9 +630,38 @@ test.skip('add asks for correct package version if user passes an incorrect one' | |
|
||
test.concurrent('install with latest tag', (): Promise<void> => { | ||
return runAdd(['left-pad@latest'], {}, 'latest-version-in-package', async (config) => { | ||
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock'))); | ||
const pkg = await fs.readJson(path.join(config.cwd, 'package.json')); | ||
const version = await getPackageVersion(config, 'left-pad'); | ||
|
||
assert.deepEqual(pkg.dependencies, {'left-pad': `^${version}`}); | ||
assert(lockfile.indexOf(`left-pad@^${version}:`) === 0); | ||
}); | ||
}); | ||
|
||
test.concurrent('install with latest tag and --offline flag', (): Promise<void> => { | ||
return runAdd(['left-pad@latest'], {}, 'latest-version-in-package', async (config, reporter, previousAdd) => { | ||
config.offline = true; | ||
const add = new Add(['left-pad@latest'], {}, config, reporter, previousAdd.lockfile); | ||
await add.init(); | ||
|
||
const pkg = await fs.readJson(path.join(config.cwd, 'package.json')); | ||
const version = await getPackageVersion(config, 'left-pad'); | ||
|
||
assert.deepEqual(pkg.dependencies, {'left-pad': `^${version}`}); | ||
}); | ||
}); | ||
|
||
test.concurrent('install with latest tag and --prefer-offline flag', (): Promise<void> => { | ||
return runAdd(['[email protected]'], {}, 'latest-version-in-package', async (config, reporter, previousAdd) => { | ||
config.preferOffline = true; | ||
const add = new Add(['left-pad@latest'], {}, config, reporter, previousAdd.lockfile); | ||
await add.init(); | ||
|
||
const pkg = await fs.readJson(path.join(config.cwd, 'package.json')); | ||
const version = await getPackageVersion(config, 'left-pad'); | ||
|
||
assert.deepEqual(pkg.dependencies, {'left-pad': `^${version}`}); | ||
assert.notEqual(version, '1.1.0'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters