File: parse-package-path.js

package info (click to toggle)
node-yarnpkg 1.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 92,980 kB
  • sloc: sh: 323; makefile: 19
file content (19 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* @flow */

import parsePackagePath, {isValidPackagePath} from '../../src/util/parse-package-path.js';

test('parsePackagePath', () => {
  expect(parsePackagePath('foo/bar/baz')).toEqual(['foo', 'bar', 'baz']);
  expect(parsePackagePath('@foo/bar/baz')).toEqual(['@foo/bar', 'baz']);
  expect(parsePackagePath('@foo/bar/@foo/baz')).toEqual(['@foo/bar', '@foo/baz']);
  expect(parsePackagePath('invalidname/')).toEqual(['invalidname']);
});

test('isValidPackagePath', () => {
  expect(isValidPackagePath('foo/bar/baz')).toEqual(true);
  expect(isValidPackagePath('@foo/bar/baz')).toEqual(true);
  expect(isValidPackagePath('@foo/bar/@foo/baz')).toEqual(true);
  expect(isValidPackagePath('invalidname/')).toEqual(false);
  expect(isValidPackagePath('invalidname//invalidname')).toEqual(false);
  expect(isValidPackagePath('invalidname/invalidname/*')).toEqual(false);
});