Skip to content

Commit 3911b94

Browse files
committed
Add tests
1 parent a937d55 commit 3911b94

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

test/__snapshots__/cli.spec.js.snap

+28
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
exports[`prettier-formatter-gitlab cli should create a code quality report file with prettier -l 1`] = `
44
[
5+
{
6+
"check_name": "prettier",
7+
"description": "Delete ⏎",
8+
"fingerprint": "20c9ca526d0a43e3075a3e0f74135991",
9+
"location": {
10+
"lines": {
11+
"begin": 11,
12+
"end": 12,
13+
},
14+
"path": "test/__stubs__/.gitlab-ci.yml",
15+
},
16+
"severity": "minor",
17+
"type": "issue",
18+
},
519
{
620
"check_name": "prettier",
721
"description": "Replace ·arg·· with arg",
@@ -82,6 +96,20 @@ exports[`prettier-formatter-gitlab cli should create a code quality report file
8296
8397
exports[`prettier-formatter-gitlab cli should create a code quality report file with prettier -c 1`] = `
8498
[
99+
{
100+
"check_name": "prettier",
101+
"description": "Delete ⏎",
102+
"fingerprint": "20c9ca526d0a43e3075a3e0f74135991",
103+
"location": {
104+
"lines": {
105+
"begin": 11,
106+
"end": 12,
107+
},
108+
"path": "test/__stubs__/.gitlab-ci.yml",
109+
},
110+
"severity": "minor",
111+
"type": "issue",
112+
},
85113
{
86114
"check_name": "prettier",
87115
"description": "Replace ·arg·· with arg",

test/__stubs__/.gitlab-ci.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.ref:
2+
script:
3+
- npm run lint
4+
5+
prettier:
6+
script:
7+
- !reference [.ref, script]
8+
artifacts:
9+
reports:
10+
codequality: gl-codequality.json
11+

test/utils/get-output-path.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { describe, it, expect } from 'bun:test';
2+
import { resolve, join } from 'node:path';
3+
import { getOutputPath } from '../../src/utils/get-output-path.js';
4+
5+
describe('The getPrettierFileInfos function', () => {
6+
it('should return the output path defined in a .gitlab-ci.yml file', () => {
7+
process.env.CI_PROJECT_DIR = resolve(join(import.meta.dirname, '../__stubs__/'));
8+
process.env.CI_JOB_NAME = 'prettier';
9+
console.log(process.env.CI_PROJECT_DIR);
10+
expect(getOutputPath()).toBe(
11+
resolve(join(import.meta.dirname, '../__stubs__/gl-codequality.json')),
12+
);
13+
});
14+
});

0 commit comments

Comments
 (0)