Skip to content

Commit

Permalink
fix: container and eval unit-test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Codeneos committed Aug 6, 2024
1 parent 29c135e commit 3762d16
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/__tests__/container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ describe('container', () => {
it('should resolve circular references without creating duplicate service instances', () => {
// Arrange
const testContainer = new Container(Logger.null);
testContainer.registerType(ServiceImplCircular, [ServiceImplCircular]);
testContainer.registerType(CircularRef, [CircularRef]);
testContainer.registerType(ServiceImplCircular, [ServiceImplCircular], { lifecycle: LifecyclePolicy.singleton });
testContainer.registerType(CircularRef, [CircularRef], { lifecycle: LifecyclePolicy.singleton });

// Act
const result = testContainer.resolve(ServiceImplCircular)!;
Expand Down
2 changes: 1 addition & 1 deletion packages/util/src/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('util', () => {
expect(string.evalExpr('\'Foo \' + bar', { bar: 'bar'})).toEqual('Foo bar');
});
it('complex expression should return evaluated result as string', () => {
expect(string.evalExpr('\'Foo \' + (i == 0 ? (bar || foo) : \'bla\')', { i: 0, foo: 'bar'})).toEqual('Foo bar');
expect(string.evalExpr('\'Foo \' + (i == 0 ? (bar || foo) : \'bla\')', { i: 0, foo: 'bar', bar: undefined})).toEqual('Foo bar');
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/util/src/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function format(formatStr: string, ...args: any[]) {
* @param contextValues context values supplied
*/
export function evalExpr(expr: string, contextValues: any) : string {
const fn = compileFunction(`return ${expr};`);
const fn = compileFunction(`return ${expr}`);
return fn(contextValues, false);
}

Expand All @@ -86,7 +86,7 @@ export function evalExpr(expr: string, contextValues: any) : string {
* @param contextValues context values supplied
*/
export function evalTemplate(expr: string, contextValues: any) : string {
const fn = compileFunction(`return \`${expr}\`;`);
const fn = compileFunction(`return \`${expr}\``);
return fn(contextValues, false);
}

Expand Down

0 comments on commit 3762d16

Please sign in to comment.