-
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 9c5c7af
Showing
9 changed files
with
110 additions
and
26 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,47 @@ | ||
/* 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"); | ||
}); | ||
}); | ||
}); |
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