-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat: remove all tests related files (#2)"
This reverts commit 7cb60d8.
- Loading branch information
1 parent
7cb60d8
commit 140a37e
Showing
8 changed files
with
200 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
collectCoverage: true, | ||
coverageDirectory: "coverage", | ||
collectCoverageFrom: ["src/**/*.{ts,js}"], | ||
coverageReporters: ["json", "text"], | ||
coveragePathIgnorePatterns: ["jest.config.js", "/node_modules/", "/dist/"], | ||
globals: { | ||
"ts-jest": { | ||
tsconfig: "tsconfig.tests.json" | ||
}, | ||
}, | ||
roots: [ | ||
"<rootDir>" | ||
], | ||
modulePaths: [ | ||
"<rootDir>" | ||
], | ||
moduleDirectories: [ | ||
"node_modules" | ||
] | ||
}; |
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,5 @@ | ||
import { BosonXmtpClient } from "../src/index"; | ||
|
||
test("Import BosonXmtpClient", () => { | ||
expect(BosonXmtpClient).toBeTruthy(); | ||
}); |
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,19 @@ | ||
import { ThreadId } from "../src/util/definitions"; | ||
|
||
export function mockThreadId(): ThreadId { | ||
const threadId: ThreadId = { | ||
exchangeId: randomId(), | ||
buyerId: randomId(), | ||
sellerId: randomId() | ||
}; | ||
|
||
return threadId; | ||
} | ||
|
||
function randomId(): string { | ||
return Math.floor(Math.random() * 100).toString(); | ||
} | ||
|
||
export function validJsonString(): string { | ||
return '{"valid":"value"}'; | ||
} |
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,9 @@ | ||
import { | ||
MessageType, | ||
SupportedImageMimeTypes | ||
} from "../../src/util/definitions"; | ||
|
||
test("Import enum definitions", () => { | ||
expect(MessageType).toBeTruthy(); | ||
expect(SupportedImageMimeTypes).toBeTruthy(); | ||
}); |
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,77 @@ | ||
import { | ||
isJsonString, | ||
isValidMessageType, | ||
matchThreadIds, | ||
validThreadId | ||
} from "../../src/util/functions"; | ||
import { MessageType, ThreadId } from "../../src/util/definitions"; | ||
import { mockThreadId, validJsonString } from "../mocks"; | ||
|
||
describe("functions", () => { | ||
test("isJsonString: Fail on invalid input", () => { | ||
const shouldBeJson: string = "not valid json"; | ||
expect(isJsonString(shouldBeJson)).toBe(false); | ||
}); | ||
|
||
test("isJsonString: Pass on valid input", () => { | ||
const shouldBeJson: string = validJsonString(); | ||
expect(isJsonString(shouldBeJson)).toBe(true); | ||
}); | ||
|
||
test("isValidMessageType: Fail on invalid input", () => { | ||
const shouldBeMessageType: MessageType = | ||
"not a valid message type" as MessageType; | ||
expect(isValidMessageType(shouldBeMessageType)).toBe(false); | ||
}); | ||
|
||
test("isValidMessageType: Pass on valid types", () => { | ||
for (const validType of Object.values(MessageType)) { | ||
expect(isValidMessageType(validType)).toBe(true); | ||
} | ||
}); | ||
|
||
test("matchThreadId: Fail on invalid param type", () => { | ||
const notAThreadId: ThreadId = | ||
"not a valid thread id" as unknown as ThreadId; | ||
const threadId: ThreadId = mockThreadId(); | ||
|
||
expect(matchThreadIds(notAThreadId, threadId)).toBe(false); | ||
}); | ||
|
||
test("matchThreadId: Fail on matching but invalid params", () => { | ||
const notAThreadId: ThreadId = | ||
"not a valid thread id" as unknown as ThreadId; | ||
const threadId: ThreadId = mockThreadId(); | ||
|
||
expect(matchThreadIds(notAThreadId, notAThreadId)).toBe(false); | ||
}); | ||
|
||
test("matchThreadId: Fail on no match", () => { | ||
const threadId1: ThreadId = mockThreadId(); | ||
const threadId2: ThreadId = mockThreadId(); | ||
threadId1.exchangeId = "0"; | ||
threadId2.exchangeId = "1"; | ||
|
||
expect(matchThreadIds(threadId1, threadId2)).toBe(false); | ||
}); | ||
|
||
test("matchThreadId: Pass on match", () => { | ||
const threadId1: ThreadId = mockThreadId(); | ||
const threadId2: ThreadId = threadId1; | ||
|
||
expect(matchThreadIds(threadId1, threadId2)).toBe(true); | ||
}); | ||
|
||
test("validThreadId: Fail on invalid type", () => { | ||
const notAThreadId: ThreadId = | ||
"not a valid thread id" as unknown as ThreadId; | ||
|
||
expect(validThreadId(notAThreadId)).toBe(false); | ||
}); | ||
|
||
test("validThreadId: Pass on match", () => { | ||
const threadId: ThreadId = mockThreadId(); | ||
|
||
expect(validThreadId(threadId)).toBe(true); | ||
}); | ||
}); |
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,40 @@ | ||
import { ContentTypeId, EncodedContent } from "@xmtp/xmtp-js"; | ||
import { | ||
BosonCodec, | ||
ContentTypeBoson, | ||
Encoding | ||
} from "../../../src/xmtp/codec/boson-codec"; | ||
import { validJsonString } from "../../mocks"; | ||
|
||
describe("", () => { | ||
const envName: string = "test"; | ||
test("Import enum definitions", () => { | ||
expect(Encoding).toBeTruthy(); | ||
}); | ||
|
||
test("ContentTypeBoson: Pass on valid input", () => { | ||
const contentType: ContentTypeId = ContentTypeBoson(envName); | ||
expect(contentType instanceof ContentTypeId).toBe(true); | ||
expect(contentType.authorityId).toBe(`bosonprotocol-${envName}`); | ||
}); | ||
|
||
test("BosonCodec: Pass on valid construction", () => { | ||
const bosonCodec: BosonCodec = new BosonCodec(envName); | ||
expect(bosonCodec instanceof BosonCodec).toBe(true); | ||
expect(bosonCodec.contentType instanceof ContentTypeId).toBe(true); | ||
expect(bosonCodec.contentType.authorityId).toBe(`bosonprotocol-${envName}`); | ||
}); | ||
|
||
test("BosonCodec encode(): Pass on valid input", () => { | ||
const bosonCodec: BosonCodec = new BosonCodec(envName); | ||
const validContent: string = validJsonString(); | ||
const encodedContent: EncodedContent = bosonCodec.encode(validContent); | ||
expect(encodedContent.type).toBe(true); | ||
expect(encodedContent.parameters).toBe(true); | ||
expect(encodedContent.content).toBe(true); | ||
}); | ||
|
||
test.skip("BosonCodec decode(): Pass on valid input", () => { | ||
// TODO: implement | ||
}); | ||
}); |
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,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationMap": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"lib": ["esnext", "es5", "dom"], | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noEmitOnError": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"preserveSymlinks": true, | ||
"preserveWatchOutput": true, | ||
"pretty": false, | ||
"sourceMap": true, | ||
"skipLibCheck": true, | ||
"target": "es5", | ||
"outDir": "dist", | ||
"resolveJsonModule": true | ||
}, | ||
"exclude": ["node_modules", "tests/**", "dist/**", "**/*.test.ts", "dist"] | ||
} |