-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(test): add tests to existing files
- Loading branch information
1 parent
14f1b4c
commit c2b475d
Showing
17 changed files
with
161 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* eslint-disable no-restricted-imports */ | ||
import pkg from "../../package.json"; | ||
import { DeviceSdk } from "./DeviceSdk"; | ||
|
||
let sdk: DeviceSdk; | ||
const logger = { | ||
log: jest.fn(), | ||
}; | ||
describe("DeviceSdk", () => { | ||
describe("clean", () => { | ||
beforeEach(() => { | ||
sdk = new DeviceSdk({ stub: false, loggers: [logger] }); | ||
}); | ||
|
||
it("should create an instance", () => { | ||
expect(sdk).toBeDefined(); | ||
expect(sdk).toBeInstanceOf(DeviceSdk); | ||
}); | ||
|
||
it("should return a clean `version`", async () => { | ||
expect(await sdk.getVersion()).toBe(pkg.version); | ||
}); | ||
|
||
it("startScan should ....", () => { | ||
expect(sdk.startScan()).toBeFalsy(); | ||
}); | ||
|
||
it("stopScan should ....", () => { | ||
expect(sdk.stopScan()).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe("stubbed", () => { | ||
beforeEach(() => { | ||
sdk = new DeviceSdk({ stub: true, loggers: [] }); | ||
}); | ||
|
||
it("should create a stubbed version", () => { | ||
expect(sdk).toBeDefined(); | ||
expect(sdk).toBeInstanceOf(DeviceSdk); | ||
}); | ||
|
||
it("should return a stubbed `version`", async () => { | ||
expect(await sdk.getVersion()).toBe("0.0.0-stub.1"); | ||
}); | ||
}); | ||
|
||
describe("without args", () => { | ||
beforeEach(() => { | ||
sdk = new DeviceSdk(); | ||
}); | ||
|
||
it("should create an instance", () => { | ||
expect(sdk).toBeDefined(); | ||
expect(sdk).toBeInstanceOf(DeviceSdk); | ||
}); | ||
|
||
it("should return a clean `version`", async () => { | ||
expect(await sdk.getVersion()).toBe(pkg.version); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { DeviceSdk } from "./DeviceSdk"; | ||
import { LedgerDeviceSdkBuilder } from "./DeviceSdkBuilder"; | ||
|
||
let builder: LedgerDeviceSdkBuilder; | ||
const logger = { | ||
log: jest.fn(), | ||
}; | ||
|
||
describe("LedgerDeviceSdkBuilder", () => { | ||
beforeEach(() => { | ||
builder = new LedgerDeviceSdkBuilder(); | ||
}); | ||
|
||
it("should build a DeviceSdk instance", () => { | ||
const sdk: DeviceSdk = builder.build(); | ||
expect(sdk).toBeInstanceOf(DeviceSdk); | ||
}); | ||
|
||
it("should set the stub flag", () => { | ||
builder.setStub(true); | ||
expect(builder.stub).toBe(true); | ||
}); | ||
|
||
it("should add a logger", () => { | ||
builder.addLogger(logger); | ||
expect(builder.loggers).toContain(logger); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export enum LogLevel { | ||
Fatal = -1, | ||
Error = 0, | ||
Warning = 1, | ||
Info = 2, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 3 additions & 10 deletions
13
packages/core/src/internal/logger/service/LoggerService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
import { Log, LoggerSubscriber } from "./Log"; | ||
/** | ||
* [IDEAS] | ||
* a data object in looger | ||
* context in logger (object || string ?) context.tag / context.type / context.id / context.os ... | ||
* message (string[]) in logger | ||
* | ||
* EXPOSE TO OUSTIDE => MOVE OUT OF INTERNAL | ||
*/ | ||
|
||
export interface LoggerService { | ||
subscribers: LoggerSubscriber[]; | ||
|
||
info(log: Log): void; | ||
fatal(log: Log): void; | ||
error(log: Log): void; | ||
warn(log: Log): void; | ||
info(log: Log): void; | ||
debug(log: Log): void; | ||
error(log: Log): void; | ||
} |