Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added a.ts
Empty file.
7 changes: 6 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ export default defineConfig({
{ text: "Quick Start", link: "/quick-start.md" },
{
text: "API documents",
link: "/api-documents/index",
link: "/api-documents",
items: [
{ text: "Configuration", link: "/api-documents/configuration" },
{ text: "Matchers", link: "/api-documents/matchers" },
{ text: "Mock Function", link: "/api-documents/mock-function" },
{ text: "Report", link: "/api-documents/coverage-report" },
],
},
{
text: "Examples",
link: "/examples",
items: [{ text: "Mock Method", link: "/examples/mock-method" }],
},
{
text: "Technical Details",
items: [
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Examples

Here is some complex examples to show how to use assemblyscript-unittest-framework in a real projects.
17 changes: 17 additions & 0 deletions docs/examples/mock-method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Mock Method

Since AS doesn't fully support `this` as parameter in function type.
We can cast the method to a normal function type and mock it.

```typescript
type Fn = (self: MockClass) => i32;
test("class method mock", () => {
const mockClass = new MockClass();
mock<Fn>(changetype<Fn>(mockClass.method), (self: MockClass): i32 => {
self.v = 100;
return 1;
});
expect(mockClass.method()).equal(1);
expect(mockClass.v).equal(100);
});
```
2 changes: 1 addition & 1 deletion docs/quick-start.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Getting Started
## Getting Started

Install Assemblyscript Unittest Framework using npm

Expand Down