This commit upgrades TypeScript to the latest version 5.3 and introduces `verbatimModuleSyntax` in line with the official Vue guide recommendatinos (vuejs/docs#2592). By enforcing `import type` for type-only imports, this commit improves code clarity and supports tooling optimization, ensuring imports are only bundled when necessary for runtime. Changes: - Bump TypeScript to 5.3.3 across the project. - Adjust import statements to utilize `import type` where applicable, promoting cleaner and more efficient code.
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { type INodeDataErrorContext, NodeDataError } from '@/application/Parser/NodeValidation/NodeDataError';
|
|
import { NodeDataErrorContextStub } from '@tests/unit/shared/Stubs/NodeDataErrorContextStub';
|
|
import { NodeType } from '@/application/Parser/NodeValidation/NodeType';
|
|
import { CustomError } from '@/application/Common/CustomError';
|
|
|
|
describe('NodeDataError', () => {
|
|
it('sets message as expected', () => {
|
|
// arrange
|
|
const message = 'message';
|
|
const context = new NodeDataErrorContextStub();
|
|
const expected = `[${NodeType[context.type]}] ${message}`;
|
|
// act
|
|
const sut = new NodeDataErrorBuilder()
|
|
.withContext(context)
|
|
.withMessage(expected)
|
|
.build();
|
|
// assert
|
|
expect(sut.message).to.include(expected);
|
|
});
|
|
it('sets context as expected', () => {
|
|
// arrange
|
|
const expected = new NodeDataErrorContextStub();
|
|
// act
|
|
const sut = new NodeDataErrorBuilder()
|
|
.withContext(expected)
|
|
.build();
|
|
// assert
|
|
expect(sut.context).to.equal(expected);
|
|
});
|
|
it('extends CustomError', () => {
|
|
// arrange
|
|
const expected = CustomError;
|
|
// act
|
|
const sut = new NodeDataErrorBuilder()
|
|
.build();
|
|
// assert
|
|
expect(sut).to.be.an.instanceof(expected);
|
|
});
|
|
});
|
|
|
|
class NodeDataErrorBuilder {
|
|
private message = 'error';
|
|
|
|
private context: INodeDataErrorContext = new NodeDataErrorContextStub();
|
|
|
|
public withContext(context: INodeDataErrorContext) {
|
|
this.context = context;
|
|
return this;
|
|
}
|
|
|
|
public withMessage(message: string) {
|
|
this.message = message;
|
|
return this;
|
|
}
|
|
|
|
public build(): NodeDataError {
|
|
return new NodeDataError(this.message, this.context);
|
|
}
|
|
}
|