Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from TypedProject/fix-coveralls
- Loading branch information
Showing
26 changed files
with
321 additions
and
126 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
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,8 +1,11 @@ | ||
import "@tsed/core"; | ||
import {getGPhoto2Driver} from "./GPhoto2Driver"; | ||
|
||
export * from "./modules"; | ||
export * from "./types"; | ||
export * from "./GPhoto2Driver"; | ||
export * from "./utils/GPUtils"; | ||
export * from "./utils/GPPointer"; | ||
export * from "./utils/GPPointerRef"; | ||
|
||
getGPhoto2Driver(); |
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,84 @@ | ||
import {alloc, allocCString} from "ref-napi"; | ||
import {GPPointer, GPPointerFloat, GPPointerInt, GPPointerString} from "./GPPointer"; | ||
|
||
jest.mock("ref-napi"); | ||
|
||
describe("GPPointer", () => { | ||
describe("GPPointer()", () => { | ||
it("should return a pointer", () => { | ||
(alloc as any).mockReturnValue("alloc"); | ||
|
||
const pointer = GPPointer<string>("string"); | ||
|
||
expect(alloc).toHaveBeenCalledWith("string"); | ||
expect(pointer).toEqual("alloc"); | ||
}); | ||
it("should return a pointer (void)", () => { | ||
(alloc as any).mockReturnValue("alloc"); | ||
|
||
const pointer = GPPointer<string>(); | ||
|
||
expect(alloc).toHaveBeenCalledWith("void"); | ||
expect(pointer).toEqual("alloc"); | ||
}); | ||
}); | ||
|
||
describe("GPPointerString()", () => { | ||
it("should return a pointer from value", () => { | ||
(alloc as any).mockReturnValue("alloc"); | ||
(allocCString as any).mockReturnValue("allocCString"); | ||
|
||
const pointer = GPPointerString("value"); | ||
|
||
expect(allocCString).toHaveBeenCalledWith("value"); | ||
expect(pointer).toEqual("allocCString"); | ||
}); | ||
it("should return a pointer from undefined", () => { | ||
(alloc as any).mockReturnValue("alloc"); | ||
(allocCString as any).mockReturnValue("allocCString"); | ||
|
||
const pointer = GPPointerString(); | ||
|
||
expect(alloc).toHaveBeenCalledWith("string"); | ||
expect(pointer).toEqual("alloc"); | ||
}); | ||
}); | ||
|
||
describe("GPPointerInt()", () => { | ||
it("should return a pointer", () => { | ||
(alloc as any).mockReturnValue("alloc"); | ||
|
||
const pointer = GPPointerInt(1); | ||
|
||
expect(alloc).toHaveBeenCalledWith("int", 1); | ||
expect(pointer).toEqual("alloc"); | ||
}); | ||
it("should return a pointer (undefined)", () => { | ||
(alloc as any).mockReturnValue("alloc"); | ||
|
||
const pointer = GPPointerInt(); | ||
|
||
expect(alloc).toHaveBeenCalledWith("int", undefined); | ||
expect(pointer).toEqual("alloc"); | ||
}); | ||
}); | ||
|
||
describe("GPPointerFloat()", () => { | ||
it("should return a pointer", () => { | ||
(alloc as any).mockReturnValue("alloc"); | ||
|
||
const pointer = GPPointerFloat(1.0); | ||
|
||
expect(alloc).toHaveBeenCalledWith("float", 1.0); | ||
expect(pointer).toEqual("alloc"); | ||
}); | ||
it("should return a pointer (undefined)", () => { | ||
(alloc as any).mockReturnValue("alloc"); | ||
|
||
const pointer = GPPointerFloat(); | ||
|
||
expect(alloc).toHaveBeenCalledWith("float", undefined); | ||
expect(pointer).toEqual("alloc"); | ||
}); | ||
}); | ||
}); |
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,38 @@ | ||
import {getGPhoto2Driver} from "../GPhoto2Driver"; | ||
import {GPPointerRef, GPPointerRefOf} from "./GPPointerRef"; | ||
import {checkCode} from "./GPUtils"; | ||
|
||
jest.mock("../GPhoto2Driver"); | ||
jest.mock("./GPUtils"); | ||
|
||
describe("GPPointerRef", () => { | ||
describe("GPPointerRef()", () => { | ||
it("should return a pointerRef", () => { | ||
const ref = GPPointerRef("string"); | ||
|
||
expect(ref.type?.name).toEqual("CString*"); | ||
}); | ||
it("should return a pointerRef (void)", () => { | ||
const ref = GPPointerRef(); | ||
|
||
expect(ref.type?.name).toEqual("void*"); | ||
}); | ||
}); | ||
describe("GPPointerRefOf()", () => { | ||
it("should a pointer of", () => { | ||
const driver = { | ||
method: jest.fn().mockReturnValue(1) | ||
}; | ||
|
||
(getGPhoto2Driver as any).mockReturnValue(driver); | ||
|
||
const result = GPPointerRefOf("method"); | ||
|
||
expect(result.type).toEqual({ | ||
indirection: 2, | ||
name: "void*" | ||
}); | ||
expect(checkCode).toHaveBeenCalledWith(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
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
Oops, something went wrong.