-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
extract.spec.ts
134 lines (132 loc) · 4.03 KB
/
extract.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { loadFixture } from '../../../test/util';
import { ClojureDatasource } from '../../datasource/clojure';
import {
extractFromVectors,
extractPackageFile,
extractVariables,
trimAtKey,
} from './extract';
const leinProjectClj = loadFixture(`project.clj`);
describe('manager/leiningen/extract', () => {
it('trimAtKey', () => {
expect(trimAtKey('foo', 'bar')).toBeNull();
expect(trimAtKey(':dependencies ', 'dependencies')).toBeNull();
expect(trimAtKey(':dependencies \nfoobar', 'dependencies')).toEqual(
'foobar'
);
});
it('extractFromVectors', () => {
expect(extractFromVectors('')).toEqual([]);
expect(extractFromVectors('[]')).toEqual([]);
expect(extractFromVectors('[[]]')).toEqual([]);
expect(extractFromVectors('[[foo/bar "1.2.3"]]')).toEqual([
{
datasource: ClojureDatasource.id,
depName: 'foo:bar',
currentValue: '1.2.3',
},
]);
expect(
extractFromVectors('[[foo/bar ~baz]]', {}, { baz: '1.2.3' })
).toEqual([
{
datasource: ClojureDatasource.id,
depName: 'foo:bar',
currentValue: '1.2.3',
},
]);
expect(
extractFromVectors('[\t[foo/bar "1.2.3"]\n["foo/baz" "4.5.6"] ]')
).toEqual([
{
datasource: ClojureDatasource.id,
depName: 'foo:bar',
currentValue: '1.2.3',
},
{
datasource: ClojureDatasource.id,
depName: 'foo:baz',
currentValue: '4.5.6',
},
]);
});
it('extractPackageFile', () => {
expect(extractPackageFile(leinProjectClj)).toMatchSnapshot({
deps: [
{ depName: 'org.clojure:clojure', currentValue: '1.3.0' },
{ depName: 'org.jclouds:jclouds', currentValue: '1.0' },
{ depName: 'net.sf.ehcache:ehcache', currentValue: '2.3.1' },
{ depName: 'log4j:log4j', currentValue: '1.2.15' },
{ depName: 'net.3scale:3scale-api', currentValue: '3.0.2' },
{ depName: 'org.lwjgl.lwjgl:lwjgl', currentValue: '2.8.5' },
{ depName: 'org.lwjgl.lwjgl:lwjgl-platform', currentValue: '2.8.5' },
{ depName: 'org.clojure:clojure', currentValue: '1.4.0' },
{ depName: 'org.clojure:clojure', currentValue: '1.5.0' },
{ depName: 'clj-stacktrace:clj-stacktrace', currentValue: '0.2.4' },
{
depName: 'clj-time:clj-time',
currentValue: '0.12.0',
depType: 'managed-dependencies',
},
{
depName: 'me.raynes:fs',
currentValue: '1.4.6',
depType: 'managed-dependencies',
},
{
depName: 'lein-pprint:lein-pprint',
currentValue: '1.1.1',
depType: 'plugins',
},
{
depName: 'lein-assoc:lein-assoc',
currentValue: '0.1.0',
depType: 'plugins',
},
{
depName: 's3-wagon-private:s3-wagon-private',
currentValue: '1.1.1',
depType: 'plugins',
},
{
depName: 'lein-foo:lein-foo',
currentValue: '0.0.1',
depType: 'plugins',
},
{
depName: 'lein-bar:lein-bar',
currentValue: '0.0.1',
depType: 'plugins',
},
{
depName: 'cider:cider-nrepl',
currentValue: '0.7.1',
depType: 'plugins',
},
{
depName: 'com.theoryinpractise:clojure-maven-plugin',
currentValue: '1.3.13',
depType: 'pom-plugins',
},
{
depName: 'org.apache.tomcat.maven:tomcat7-maven-plugin',
currentValue: '2.1',
depType: 'pom-plugins',
},
{
depName: 'com.google.appengine:appengine-maven-plugin',
currentValue: '1.9.68',
depType: 'pom-plugins',
},
],
});
});
it('extractVariables', () => {
expect(extractVariables('(def foo "1")')).toEqual({ foo: '1' });
expect(extractVariables('(def foo"2")')).toEqual({ foo: '2' });
expect(extractVariables('(def foo "3")\n(def bar "4")')).toEqual({
foo: '3',
bar: '4',
});
});
});