Skip to content

Commit 3d0c79f

Browse files
authored
test(parse): remove import-from package from tests (#967)
1 parent 166cbb7 commit 3d0c79f

File tree

5 files changed

+17
-39
lines changed

5 files changed

+17
-39
lines changed

@commitlint/lint/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,8 @@
3434
},
3535
"license": "MIT",
3636
"devDependencies": {
37-
"@babel/cli": "^7.7.7",
38-
"@babel/core": "^7.7.7",
3937
"@commitlint/test": "8.2.0",
40-
"@commitlint/utils": "^8.3.4",
41-
"babel-preset-commitlint": "^8.2.0",
42-
"cross-env": "7.0.0"
38+
"@commitlint/utils": "^8.3.4"
4339
},
4440
"dependencies": {
4541
"@commitlint/is-ignored": "^8.3.5",

@commitlint/parse/fixtures/parser-preset/commitlint.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

@commitlint/parse/fixtures/parser-preset/conventional-changelog-custom.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

@commitlint/parse/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
"devDependencies": {
3737
"@commitlint/test": "8.2.0",
3838
"@commitlint/utils": "^8.3.4",
39-
"@types/lodash": "4.14.149",
40-
"import-from": "3.0.0"
39+
"@types/lodash": "4.14.149"
4140
},
4241
"dependencies": {
4342
"conventional-changelog-angular": "^5.0.0",

@commitlint/parse/src/index.test.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import importFrom from 'import-from';
21
import parse from '.';
32

43
test('throws when called without params', async () => {
@@ -81,10 +80,11 @@ test('uses angular grammar', async () => {
8180

8281
test('uses custom opts parser', async () => {
8382
const message = 'type(scope)-subject';
84-
const changelogOpts: any = await importFrom(
85-
__dirname,
86-
'../fixtures/parser-preset/conventional-changelog-custom.js'
87-
);
83+
const changelogOpts = {
84+
parserOpts: {
85+
headerPattern: /^(\w*)(?:\((.*)\))?-(.*)$/
86+
}
87+
};
8888
const actual = await parse(message, undefined, changelogOpts.parserOpts);
8989
const expected = {
9090
body: null,
@@ -145,13 +145,11 @@ test('supports scopes with / and empty parserOpts', async () => {
145145

146146
test('ignores comments', async () => {
147147
const message = 'type(some/scope): subject\n# some comment';
148-
const changelogOpts: any = await importFrom(
149-
process.cwd(),
150-
'conventional-changelog-angular'
151-
);
152-
const opts = Object.assign({}, changelogOpts.parserOpts, {
148+
const changelogOpts = await require('conventional-changelog-angular');
149+
const opts = {
150+
...changelogOpts.parserOpts,
153151
commentChar: '#'
154-
});
152+
};
155153
const actual = await parse(message, undefined, opts);
156154

157155
expect(actual.body).toBe(null);
@@ -162,13 +160,11 @@ test('ignores comments', async () => {
162160
test('registers inline #', async () => {
163161
const message =
164162
'type(some/scope): subject #reference\n# some comment\nthings #reference';
165-
const changelogOpts: any = await importFrom(
166-
process.cwd(),
167-
'conventional-changelog-angular'
168-
);
169-
const opts = Object.assign({}, changelogOpts.parserOpts, {
163+
const changelogOpts = await require('conventional-changelog-angular');
164+
const opts = {
165+
...changelogOpts.parserOpts,
170166
commentChar: '#'
171-
});
167+
};
172168
const actual = await parse(message, undefined, opts);
173169

174170
expect(actual.subject).toBe('subject #reference');
@@ -177,13 +173,10 @@ test('registers inline #', async () => {
177173

178174
test('parses references leading subject', async () => {
179175
const message = '#1 some subject';
180-
const opts = await importFrom(
181-
process.cwd(),
182-
'conventional-changelog-angular'
183-
);
176+
const opts = await require('conventional-changelog-angular');
184177
const {
185178
references: [actual]
186-
} = await parse(message, undefined, opts as any);
179+
} = await parse(message, undefined, opts);
187180

188181
expect(actual.issue).toBe('1');
189182
});

0 commit comments

Comments
 (0)