Skip to content

Commit 9f7ee4f

Browse files
committed
review fix
1 parent 84ac36e commit 9f7ee4f

10 files changed

+141
-9
lines changed

lib/error/error_notifier.spec.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2025, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import { describe, it, expect, vi } from 'vitest';
217

318
import { DefaultErrorNotifier } from './error_notifier';
@@ -21,7 +36,7 @@ describe('DefaultErrorNotifier', () => {
2136
expect(errorHandler.handleError).toHaveBeenCalledWith(error);
2237
});
2338

24-
it.only('should resolve the message of an OptimizelyError before calling the error handler', () => {
39+
it('should resolve the message of an OptimizelyError before calling the error handler', () => {
2540
const errorHandler = { handleError: vi.fn() };
2641
const messageResolver = mockMessageResolver('err');
2742
const errorNotifier = new DefaultErrorNotifier(errorHandler, messageResolver);

lib/error/error_notifier.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
/**
2+
* Copyright 2025, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import { MessageResolver } from "../message/message_resolver";
2-
import { sprintf } from "../utils/fns";
317
import { ErrorHandler } from "./error_handler";
418
import { OptimizelyError } from "./optimizly_error";
519

lib/error/error_notifier_factory.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2025, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import { errorResolver } from "../message/message_resolver";
217
import { ErrorHandler } from "./error_handler";
318
import { DefaultErrorNotifier } from "./error_notifier";

lib/error/error_reporter.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2025, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import { describe, it, expect, vi } from 'vitest';
217

318
import { ErrorReporter } from './error_reporter';

lib/error/error_reporter.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2025, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import { LoggerFacade } from "../logging/logger";
217
import { ErrorNotifier } from "./error_notifier";
318
import { OptimizelyError } from "./optimizly_error";

lib/error/optimizly_error.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2025, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import { MessageResolver } from "../message/message_resolver";
217
import { sprintf } from "../utils/fns";
318

lib/logging/logger.spec.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2025, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import { describe, beforeEach, afterEach, it, expect, vi, afterAll } from 'vitest';
217

318
import { ConsoleLogHandler, LogLevel, OptimizelyLogger } from './logger';
@@ -15,7 +30,7 @@ describe('ConsoleLogHandler', () => {
1530
debugSpy.mockClear();
1631
infoSpy.mockClear();
1732
warnSpy.mockClear();
18-
vi.useFakeTimers().setSystemTime((0));
33+
vi.useFakeTimers().setSystemTime(0);
1934
});
2035

2136
afterEach(() => {
@@ -69,7 +84,7 @@ describe('ConsoleLogHandler', () => {
6984
logger.log(LogLevel.Error, 'error message');
7085

7186
expect(infoSpy).toHaveBeenCalledWith('[OPTIMIZELY] - INFO 1970-01-01T00:00:00.000Z info message');
72-
expect(debugSpy).toHaveBeenCalledWith('[OPTIMIZELY] - DEGUB 1970-01-01T00:00:00.000Z debug message');
87+
expect(debugSpy).toHaveBeenCalledWith('[OPTIMIZELY] - DEBUG 1970-01-01T00:00:00.000Z debug message');
7388
expect(warnSpy).toHaveBeenCalledWith('[OPTIMIZELY] - WARN 1970-01-01T00:00:00.000Z warn message');
7489
expect(errorSpy).toHaveBeenCalledWith('[OPTIMIZELY] - ERROR 1970-01-01T00:00:00.000Z error message');
7590
});
@@ -82,7 +97,7 @@ describe('ConsoleLogHandler', () => {
8297
logger.log(LogLevel.Error, 'error message');
8398

8499
expect(infoSpy).toHaveBeenCalledWith('PREFIX - INFO 1970-01-01T00:00:00.000Z info message');
85-
expect(debugSpy).toHaveBeenCalledWith('PREFIX - DEGUB 1970-01-01T00:00:00.000Z debug message');
100+
expect(debugSpy).toHaveBeenCalledWith('PREFIX - DEBUG 1970-01-01T00:00:00.000Z debug message');
86101
expect(warnSpy).toHaveBeenCalledWith('PREFIX - WARN 1970-01-01T00:00:00.000Z warn message');
87102
expect(errorSpy).toHaveBeenCalledWith('PREFIX - ERROR 1970-01-01T00:00:00.000Z error message');
88103
});

lib/logging/logger.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019, 2024, Optimizely
2+
* Copyright 2019, 2024, 2025, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the License");
55
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ export enum LogLevel {
2525
}
2626

2727
export const LogLevelToUpper: Record<LogLevel, string> = {
28-
[LogLevel.Debug]: 'DEGUB',
28+
[LogLevel.Debug]: 'DEBUG',
2929
[LogLevel.Info]: 'INFO',
3030
[LogLevel.Warn]: 'WARN',
3131
[LogLevel.Error]: 'ERROR',
@@ -133,8 +133,6 @@ export class OptimizelyLogger implements LoggerFacade {
133133
}
134134

135135
private log(level: LogLevel, message: string | Error, args: any[]): void {
136-
console.log('level', level, 'this.level', this.level, message)
137-
138136
if (level < this.level) {
139137
return;
140138
}

lib/logging/logger_factory.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2025, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import { describe, it, expect, beforeEach, vi } from 'vitest';
217

318
vi.mock('./logger', async (importOriginal) => {

lib/logging/logger_factory.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2025, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import { ConsoleLogHandler, LogHandler, LogLevel, OptimizelyLogger } from './logger';
217
import { errorResolver, infoResolver, MessageResolver } from '../message/message_resolver';
318

0 commit comments

Comments
 (0)