Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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 modified .editorconfig
100644 → 100755
Empty file.
Empty file modified .eslintrc
100644 → 100755
Empty file.
43 changes: 0 additions & 43 deletions .github/workflows/CI.yml

This file was deleted.

76 changes: 0 additions & 76 deletions .github/workflows/Release.yml

This file was deleted.

Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .gitmodules
100644 → 100755
Empty file.
Empty file modified .npmignore
100644 → 100755
Empty file.
7 changes: 0 additions & 7 deletions .vscode/extensions.json

This file was deleted.

31 changes: 0 additions & 31 deletions .vscode/settings.json

This file was deleted.

Empty file modified CHANGELOG.md
100644 → 100755
Empty file.
105 changes: 98 additions & 7 deletions DOCUMENTATION.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
`wildcard`\
Used for comparing argument values and write values

#### roblox-ts wildcard helper
To avoid the need for something like `wildcard as unknown as MyType`, use `fitumi.ignore()` instead.

## Creating fakes
### Using `a`
`a.fake()`\
Expand All @@ -13,9 +16,10 @@ Creates a faked table - complete with call and write history logging
The faked table

## Checking for calls to a faked table
### Using `a`
### Using `a.callTo`
`a.callTo(fakedTable, ...)`\
Creates a set of methods for reading or handling calls to the given faked table with the provided arguments
Creates a new `CallMatchOptions` object associated with the given faked table and expected arguments;\
if multiple callTos qualify, the latest one to be added will take precedence, except when used with andThen
#### Parameters
- fakedTable\
The faked table that would be called\
Expand All @@ -24,24 +28,111 @@ Should only be created from [`a.fake()`](#Creating-fakes)
A vararg of expected arguments\
For every [`wildcard`](#wildcard) given here, any value at all will match
#### Returns
A table with a set of methods as described in [Result methods from callTo](#Result-methods-from-callTo)
A `CallMatchOptions` object, as described in [CallMatchOptions](#CallMatchOptions)

### Result methods from callTo
`a.callTo(...):didHappen()`\
### Using `a.methodCallTo`
`a.methodCallTo(fakedTable, methodKey, ...)`\
Creates a new `CallMatchOptions` object associated with the given faked table and expected arguments,\
injecting a reference to `fakedTable` as the first argument so as to make faking calls to methods look nicer in tests\
if multiple callTos qualify, the latest one to be added will take precedence, except when used with andThen
#### Parameters
- fakedTable\
The faked table that would be called\
Should only be created from [`a.fake()`](#Creating-fakes)
- methodKey\
The key of the method to fake in the fakedTable
- ...\
A vararg of expected arguments\
For every [`wildcard`](#wildcard) given here, any value at all will match
#### Returns
A `CallMatchOptions` object, as described in [CallMatchOptions](#CallMatchOptions)

### Matching arguments with `a.matchingArgValue`
`a.matchingArgValue(callback)`\
Creates a customizable argument value matching operator for `callTo` and `methodCallTo` call matching.
#### Parameters
- callback\
A simple callback function which is given the argument value in the same place in the parameter list and is expected to return a boolean result

### CallMatchOptions
`callMatchOptions:countNumberOfMatchingCalls()`\
Counts the number of matching calls that have been invoked against the source faked table with appropriate parameters as per the source callTo arguments
#### Returns
The number of matching calls

`callMatchOptions:didHappen()`\
Checks whether a call with the matching arguments did happen
#### Returns
A boolean indicating whether a call with the matching arguments did happen

`a.callTo(...):didNotHappen()`\
`callMatchOptions:didNotHappen()`\
Checks whether a call with the matching arguments did not happen
#### Returns
A boolean indicating whether a call with the matching arguments did not happen

`a.callTo(...):returns(...)`\
`callMatchOptions:executes(callback)`\
Sets calls with matching arguments to execute the given callback - the arguments to the call are passed to the callback
#### Parameters
- callback\
The callback to invoke with the given arguments
#### Returns
A `CallBehaviorOptions` object, as described in [CallBehaviorOptions](#CallBehaviorOptions)

`callMatchOptions:returns(...)`\
Sets calls with matching arguments to return the given values
#### Parameters
- ...\
The values to return; if there are multiple, will be returned as a tuple
#### Returns
A `CallResultOptions` object, as described in [CallResultOptions](#CallResultOptions)

`callMatchOptions:throws(...)`\
Sets calls with matching arguments to error with the given values
#### Parameters
- ...\
The values to error with
#### Returns
A `CallResultOptions` object, as described in [CallResultOptions](#CallResultOptions)

### CallBehaviorOptions
`callBehaviorOptions:once()`\
Sets this call behavior to only be used once, then discarded to make way for other matching call behaviors
#### Returns
A reference back to the same `CallBehaviorOptions` instance

`callBehaviorOptions:twice()`\
Sets this call behavior to only be used twice, then discarded to make way for other matching call behaviors
#### Returns
A reference back to the same `CallBehaviorOptions` instance

`callBehaviorOptions:numberOfTimes(numberOfTimes)`\
Sets this call behavior to only be used exactly the number of times specified, then discarded to make way for other matching call behaviors
#### Returns
A reference back to the same `CallBehaviorOptions` instance

`callBehaviorOptions.andThen`\
Points to clone of the source `CallMatchOptions` for this `CallBehaviorOptions` instance which will allow further call behaviors to be\
configured to have lower precedence than the current behavior being configured

### CallResultOptions
`callResultOptions:once()`\
Sets this call behavior to only be used once, then discarded to make way for other matching call behaviors
#### Returns
A reference back to the same `CallResultOptions` instance

`callResultOptions:twice()`\
Sets this call behavior to only be used twice, then discarded to make way for other matching call behaviors
#### Returns
A reference back to the same `CallResultOptions` instance

`callResultOptions:numberOfTimes(numberOfTimes)`\
Sets this call behavior to only be used exactly the number of times specified, then discarded to make way for other matching call behaviors
#### Returns
A reference back to the same `CallResultOptions` instance

`callResultOptions.andThen`\
Points to clone of the source `CallMatchOptions` for this `CallResultOptions` instance which will allow further call behaviors to be\
configured to have lower precedence than the current behavior being configured

## Checking for writes to a faked table
### Using `a`
Expand Down
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
36 changes: 14 additions & 22 deletions default.project.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
{
"name": "test-rojo-proj",
"tree": {
"$className": "DataModel",
"ReplicatedStorage": {
"$className": "ReplicatedStorage",
"rbxts_include": {
"$path": "include",
"node_modules": {
"$path": "./node_modules/@rbxts"
}
},
"out": {
"$path": "./out"
}
},
"ServerScriptService": {
"$className": "ServerScriptService",
"TestRunner": {
"$path": "./spec.server.lua"
}
}
}
"name": "fitumi",
"globIgnorePaths": [
"**/package.json",
"**/tsconfig.json"
],
"tree": {
"$path": "out",
"node_modules": {
"$className": "Folder",
"@rbxts": {
"$path": "node_modules/@rbxts"
}
}
}
}
2 changes: 1 addition & 1 deletion foreman.toml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[tools]
rojo = { source = "rojo-rbx/rojo", version = "6" }
rojo = { source = "rojo-rbx/rojo", version = "7.0.0" }
run-in-roblox = { source = "rojo-rbx/run-in-roblox", version = "0.3.0" }
wally = { source = "UpliftGames/wally", version = "0.2.1" }
Loading