Skip to content

Commit 50d84fc

Browse files
committed
Added improved tests
1 parent d8caaee commit 50d84fc

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/common/errors.test.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { describe, expect, it } from 'vitest';
2-
import { ajv } from '../utils/ajv';
3-
import { AjvValidationError } from './errors';
2+
import { ajv } from '../utils/ajv.js';
3+
import { AjvValidationError } from './errors.js';
44
import { ResourceSchema } from 'codify-schemas';
5-
import { SourceMapCache } from '../parser/source-maps';
6-
import { JsonParser } from '../parser/json/json-parser';
7-
import { FileType } from '../parser/entities';
5+
import { SourceMapCache } from '../parser/source-maps.js';
6+
import { JsonParser } from '../parser/json/json-parser.js';
7+
import { FileType } from '../parser/entities.js';
88
import stripAnsi from 'strip-ansi';
99

1010
describe('AjvValidationError tests', () => {
@@ -62,15 +62,17 @@ describe('AjvValidationError tests', () => {
6262

6363
console.log(error.formattedMessage())
6464
expect(stripAnsi(error.formattedMessage())).to.eq(
65-
`Validation error: resource is not valid
65+
`Validation error: resource is not valid.
6666

67-
"/dependsOn" must be array
68-
69-
7| {
70-
8| "type": "resourceType",
71-
9| "name": "something",
72-
> 10| "dependsOn": "supposed to be an array"
73-
11| }
74-
12| ]`)
67+
1. Validation error: "dependsOn" must be array
68+
File: /test/path/to/test.json
69+
7 | {
70+
8 | "type": "resourceType",
71+
9 | "name": "something",
72+
> 10 | "dependsOn": "supposed to be an array"
73+
11 | }
74+
12 | ]
75+
76+
`)
7577
})
7678
})

src/parser/source-maps.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect } from 'vitest';
2-
import { FileType, InMemoryFile } from './entities';
3-
import { YamlSourceMapAdapter, YamlSourceMapBTree } from './source-maps';
2+
import { FileType, InMemoryFile } from './entities.js';
3+
import { YamlSourceMapAdapter, YamlSourceMapBTree } from './source-maps.js';
44
import SourceMap from 'js-yaml-source-map';
55
import * as yaml from 'js-yaml';
66
import { exec } from 'child_process';

0 commit comments

Comments
 (0)