Skip to content

Commit

Permalink
upd: v1.3.14
Browse files Browse the repository at this point in the history
  • Loading branch information
nitinmittal23 committed Aug 24, 2024
1 parent 043a50f commit 14165cf
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 81 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/release.yml

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@maticnetwork/chain-indexer-framework",
"version": "1.3.13",
"version": "1.3.14",
"description": "blockchain data indexer",
"type": "module",
"exports": {
Expand Down
78 changes: 39 additions & 39 deletions tests/logger/logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jest.mock("winston", () => {
},
transports: {
Console: jest.fn().mockImplementation(() => {
return {console: true};
return { console: true };
}),
Http: jest.fn().mockImplementation(() => {
return {datadog: true};
return { datadog: true };
})
},
createLogger: jest.fn()
Expand All @@ -40,42 +40,42 @@ describe("Logger", () => {
mockedSentry: jest.MockedObject<typeof Sentry>;

let mockedLogger: jest.MockedObject<WinstonLogger> = {
info: jest.fn(),
debug: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
log: jest.fn()
} as jest.MockedObject<WinstonLogger>;

beforeAll(()=>{
Logger.create({
info: jest.fn(),
debug: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
log: jest.fn()
} as jest.MockedObject<WinstonLogger>;

beforeAll(() => {
Logger.create({
winston: {
level: "error"
},
sentry: {
dsn: 'test_dsn',
level: 'error',
dsn: 'test_dsn',
level: 'error',
environment: 'staging'
},
},
datadog: {
api_key: 'test_api_key',
service_name: 'test_app_key'
api_key: 'test_api_key',
service_name: 'test_app_key'
}
});
})

beforeEach(() => {
beforeEach(() => {
mockedWinston = winston as jest.Mocked<typeof winston>;
mockedWinstonFormat = winston.format as jest.MockedObject<typeof winston.format>;
mockedWinstonTransports = winston.transports;
mockedWinstonTransports = winston.transports;
mockedSentryClass = Sentry as jest.MockedClass<typeof Sentry>;
});

test("create - should create logger with passed config or default config otherwise", () => {
const colorizer = { addColors: (colors) => { } } as winston.Logform.Colorizer;

mockedWinstonFormat.combine.mockReturnValueOnce({format: true} as unknown as winston.Logform.Format);
mockedWinstonFormat.combine.mockReturnValueOnce({ format: true } as unknown as winston.Logform.Format);

mockedWinston.createLogger.mockReturnValueOnce(mockedLogger);

mockedWinstonFormat.timestamp.mockReturnValueOnce(
Expand All @@ -86,23 +86,23 @@ describe("Logger", () => {
{} as winston.Logform.Format
);

Logger.create({
Logger.create({
winston: {
level: "error"
},
sentry: {
dsn: 'test_dsn',
level: 'error',
dsn: 'test_dsn',
level: 'error',
environment: 'staging'
},
},
datadog: {
api_key: 'test_api_key',
service_name: 'test_app_key'
api_key: 'test_api_key',
service_name: 'test_app_key'
}
});

mockedSentry = mockedSentryClass.mock.instances[0] as unknown as jest.MockedObject<typeof Sentry>;

expect(mockedWinstonFormat.combine).toHaveBeenNthCalledWith(
1,
{ options: {} },
Expand All @@ -116,11 +116,11 @@ describe("Logger", () => {
expect(mockedWinston.createLogger).toHaveBeenCalledWith(
{
level: 'error',
format: {format: true},
format: { format: true },
transports: [
{console: true},
{ console: true },
mockedSentry,
{datadog: true}
{ datadog: true }
]
}
);
Expand Down Expand Up @@ -152,8 +152,8 @@ describe("Logger", () => {
{
level: 'error',
sentry: {
dsn: 'test_dsn',
environment: 'staging'
dsn: 'test_dsn',
// environment: 'staging'
}
}
);
Expand All @@ -172,26 +172,26 @@ describe("Logger", () => {

test('Logger is a singleton', () => {
// Create an instance of Logger
Logger.create({
Logger.create({
winston: {
level: "error"
},
sentry: {
dsn: 'test_dsn2',
level: 'error' ,
dsn: 'test_dsn2',
level: 'error',
environment: 'staging'
},
},
datadog: {
api_key: 'test_api_key2',
service_name: 'test_app_key'
api_key: 'test_api_key2',
service_name: 'test_app_key'
}
});

//Since the test "create - should create logger with passed config or default config otherwise" has already been executed before this test,
//calling Logger create method will not call the createLogger of mockedWinston. Verifying this will serve as our test for Singleton.
expect(mockedWinston.createLogger).toHaveBeenCalledTimes(0);
});

test("info must call logger.info with the message passed", () => {
Logger.info("mock");

Expand Down

0 comments on commit 14165cf

Please sign in to comment.