Skip to content

Commit c0ea733

Browse files
Dobromir Hristovmportiz08
authored andcommitted
fix tests
1 parent a6d0d74 commit c0ea733

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/utils/schema-version-check.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export const CURRENT_SUPPORTED_SCHEMA = {
1414
patch: 0,
1515
};
1616

17-
function combineVersions({ major, minor, patch }) {
17+
export function combineVersions({ major, minor, patch }) {
1818
return [major, minor, patch].join('.');
1919
}
2020

21-
const CURRENT_SCHEMA_STRING = combineVersions(CURRENT_SUPPORTED_SCHEMA);
21+
export const CURRENT_SCHEMA_STRING = combineVersions(CURRENT_SUPPORTED_SCHEMA);
2222

2323
function constructMinorVersionMessage(current) {
2424
return `[Swift-DocC-Render] The render node version for this page has a higher minor version (${current}) than Swift-DocC-Render supports (${CURRENT_SCHEMA_STRING}). Compatibility is not guaranteed.`;

tests/unit/utils/schema-version-check.spec.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
*/
1010

11-
import emitWarningForSchemaVersionMismatch, { CURRENT_SUPPORTED_SCHEMA } from 'docc-render/utils/schema-version-check';
11+
import emitWarningForSchemaVersionMismatch, { CURRENT_SUPPORTED_SCHEMA, combineVersions, CURRENT_SCHEMA_STRING } from 'docc-render/utils/schema-version-check';
1212

1313
const warnSpy = jest.spyOn(console, 'warn').mockReturnValue('');
1414

@@ -23,33 +23,36 @@ describe('schema-version-check', () => {
2323
});
2424

2525
it('emits a warning if the major version is higher than the supported', () => {
26-
emitWarningForSchemaVersionMismatch({
26+
const newVersion = {
2727
...CURRENT_SUPPORTED_SCHEMA,
2828
major: CURRENT_SUPPORTED_SCHEMA.major + 1,
29-
});
29+
};
30+
emitWarningForSchemaVersionMismatch(newVersion);
3031
expect(warnSpy).toHaveBeenCalledTimes(1);
3132
expect(warnSpy)
32-
.toHaveBeenCalledWith('[Swift-DocC-Render] The render node version for this page (1.1.0) has a different major version component than Swift-DocC-Render supports (0.1.0). Compatibility is not guaranteed.');
33+
.toHaveBeenCalledWith(`[Swift-DocC-Render] The render node version for this page (${combineVersions(newVersion)}) has a different major version component than Swift-DocC-Render supports (${CURRENT_SCHEMA_STRING}). Compatibility is not guaranteed.`);
3334
});
3435

3536
it('emits a warning if the major version is lower than the supported', () => {
36-
emitWarningForSchemaVersionMismatch({
37+
const newVersion = {
3738
...CURRENT_SUPPORTED_SCHEMA,
3839
major: CURRENT_SUPPORTED_SCHEMA.major - 1,
39-
});
40+
};
41+
emitWarningForSchemaVersionMismatch(newVersion);
4042
expect(warnSpy).toHaveBeenCalledTimes(1);
4143
expect(warnSpy)
42-
.toHaveBeenCalledWith('[Swift-DocC-Render] The render node version for this page (-1.1.0) has a different major version component than Swift-DocC-Render supports (0.1.0). Compatibility is not guaranteed.');
44+
.toHaveBeenCalledWith(`[Swift-DocC-Render] The render node version for this page (${combineVersions(newVersion)}) has a different major version component than Swift-DocC-Render supports (${CURRENT_SCHEMA_STRING}). Compatibility is not guaranteed.`);
4345
});
4446

4547
it('emits a warning if the minor version is higher than the supported', () => {
46-
emitWarningForSchemaVersionMismatch({
48+
const newVersion = {
4749
...CURRENT_SUPPORTED_SCHEMA,
4850
minor: CURRENT_SUPPORTED_SCHEMA.minor + 1,
49-
});
51+
};
52+
emitWarningForSchemaVersionMismatch(newVersion);
5053
expect(warnSpy).toHaveBeenCalledTimes(1);
5154
expect(warnSpy)
52-
.toHaveBeenCalledWith('[Swift-DocC-Render] The render node version for this page has a higher minor version (0.2.0) than Swift-DocC-Render supports (0.1.0). Compatibility is not guaranteed.');
55+
.toHaveBeenCalledWith(`[Swift-DocC-Render] The render node version for this page has a higher minor version (${combineVersions(newVersion)}) than Swift-DocC-Render supports (${CURRENT_SCHEMA_STRING}). Compatibility is not guaranteed.`);
5356
});
5457

5558
it('does not emit a warning, if the minor version is lower than the supported', () => {

0 commit comments

Comments
 (0)