|
1 | | -/** |
2 | | - Licensed to the Apache Software Foundation (ASF) under one |
3 | | - or more contributor license agreements. See the NOTICE file |
4 | | - distributed with this work for additional information |
5 | | - regarding copyright ownership. The ASF licenses this file |
6 | | - to you under the Apache License, Version 2.0 (the |
7 | | - "License"); you may not use this file except in compliance |
8 | | - with the License. You may obtain a copy of the License at |
9 | | -
|
10 | | - http://www.apache.org/licenses/LICENSE-2.0 |
11 | | -
|
12 | | - Unless required by applicable law or agreed to in writing, |
13 | | - software distributed under the License is distributed on an |
14 | | - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
15 | | - KIND, either express or implied. See the License for the |
16 | | - specific language governing permissions and limitations |
17 | | - under the License. |
18 | | -*/ |
19 | | -/* eslint-env jasmine */ |
20 | | - |
21 | | -var pluginSpec = require('../../../src/cordova/plugin/plugin_spec_parser'); |
22 | | - |
23 | | -describe('methods for parsing npm plugin packages', function () { |
24 | | - function checkPluginSpecParsing (testString, scope, id, version) { |
25 | | - var parsedSpec = pluginSpec.parse(testString); |
26 | | - expect(parsedSpec.scope).toEqual(scope); |
27 | | - expect(parsedSpec.id).toEqual(id || testString); |
28 | | - expect(parsedSpec.version).toEqual(version); |
29 | | - expect(parsedSpec.package).toEqual(scope ? scope + id : id); |
30 | | - } |
31 | | - |
32 | | - it('Test 001 : should handle package names with no scope or version', function () { |
33 | | - checkPluginSpecParsing('test-plugin', null, 'test-plugin', null); |
34 | | - }); |
35 | | - it('Test 002 : should handle package names with a version', function () { |
36 | | - checkPluginSpecParsing('[email protected]', null, 'test-plugin', '1.0.0'); |
37 | | - checkPluginSpecParsing('test-plugin@latest', null, 'test-plugin', 'latest'); |
38 | | - }); |
39 | | - it('Test 003 : should handle package names with a scope', function () { |
40 | | - checkPluginSpecParsing('@test/test-plugin', '@test/', 'test-plugin', null); |
41 | | - }); |
42 | | - it('Test 004 : should handle package names with a scope and a version', function () { |
43 | | - checkPluginSpecParsing('@test/[email protected]', '@test/', 'test-plugin', '1.0.0'); |
44 | | - checkPluginSpecParsing('@test/test-plugin@latest', '@test/', 'test-plugin', 'latest'); |
45 | | - }); |
46 | | - it('Test 005 : should handle invalid package specs', function () { |
47 | | - checkPluginSpecParsing('@nonsense', null, null, null); |
48 | | - checkPluginSpecParsing('@/nonsense', null, null, null); |
49 | | - checkPluginSpecParsing('@', null, null, null); |
50 | | - checkPluginSpecParsing('@nonsense@latest', null, null, null); |
51 | | - checkPluginSpecParsing('@/@', null, null, null); |
52 | | - checkPluginSpecParsing('/', null, null, null); |
53 | | - checkPluginSpecParsing('../../@directory', null, null, null); |
54 | | - checkPluginSpecParsing('@directory/../@directory', null, null, null); |
55 | | - checkPluginSpecParsing('./directory', null, null, null); |
56 | | - checkPluginSpecParsing('directory/directory', null, null, null); |
57 | | - checkPluginSpecParsing('http://cordova.apache.org', null, null, null); |
58 | | - }); |
59 | | -}); |
| 1 | +/** |
| 2 | + Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + "License"); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, |
| 13 | + software distributed under the License is distributed on an |
| 14 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + KIND, either express or implied. See the License for the |
| 16 | + specific language governing permissions and limitations |
| 17 | + under the License. |
| 18 | +*/ |
| 19 | +/* eslint-env jasmine */ |
| 20 | + |
| 21 | +var pluginSpec = require('../../../src/cordova/plugin/plugin_spec_parser'); |
| 22 | + |
| 23 | +describe('methods for parsing npm plugin packages', function () { |
| 24 | + function checkPluginSpecParsing (testString, scope, id, version) { |
| 25 | + var parsedSpec = pluginSpec.parse(testString); |
| 26 | + expect(parsedSpec.scope).toEqual(scope); |
| 27 | + expect(parsedSpec.id).toEqual(id || testString); |
| 28 | + expect(parsedSpec.version).toEqual(version); |
| 29 | + expect(parsedSpec.package).toEqual(scope ? scope + id : id); |
| 30 | + } |
| 31 | + |
| 32 | + it('Test 001 : should handle package names with no scope or version', function () { |
| 33 | + checkPluginSpecParsing('test-plugin', null, 'test-plugin', null); |
| 34 | + }); |
| 35 | + it('Test 002 : should handle package names with a version', function () { |
| 36 | + checkPluginSpecParsing('[email protected]', null, 'test-plugin', '1.0.0'); |
| 37 | + checkPluginSpecParsing('test-plugin@latest', null, 'test-plugin', 'latest'); |
| 38 | + }); |
| 39 | + it('Test 003 : should handle package names with a scope', function () { |
| 40 | + checkPluginSpecParsing('@test/test-plugin', '@test/', 'test-plugin', null); |
| 41 | + }); |
| 42 | + it('Test 004 : should handle package names with a scope and a version', function () { |
| 43 | + checkPluginSpecParsing('@test/[email protected]', '@test/', 'test-plugin', '1.0.0'); |
| 44 | + checkPluginSpecParsing('@test/test-plugin@latest', '@test/', 'test-plugin', 'latest'); |
| 45 | + }); |
| 46 | + it('Test 005 : should handle invalid package specs', function () { |
| 47 | + checkPluginSpecParsing('@nonsense', null, null, null); |
| 48 | + checkPluginSpecParsing('@/nonsense', null, null, null); |
| 49 | + checkPluginSpecParsing('@', null, null, null); |
| 50 | + checkPluginSpecParsing('@nonsense@latest', null, null, null); |
| 51 | + checkPluginSpecParsing('@/@', null, null, null); |
| 52 | + checkPluginSpecParsing('/', null, null, null); |
| 53 | + checkPluginSpecParsing('../../@directory', null, null, null); |
| 54 | + checkPluginSpecParsing('@directory/../@directory', null, null, null); |
| 55 | + checkPluginSpecParsing('./directory', null, null, null); |
| 56 | + checkPluginSpecParsing('directory/directory', null, null, null); |
| 57 | + checkPluginSpecParsing('http://cordova.apache.org', null, null, null); |
| 58 | + }); |
| 59 | +}); |
0 commit comments