Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add test and testEach functions #46

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.DS_Store
.idea/
.vscode/
dazn-kopytko-unit-testing-framework-*

node_modules/
.env

dazn-kopytko-unit-testing-framework-*
25 changes: 25 additions & 0 deletions docs/api/KopytkoTestFunctions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# KopytkoTestFunctions API

- [Functions](#functions)
- [`test`](#test)
- [`testEach`](#testeach)
- [`it`](#it)
- [`itEach`](#iteach)
- [`beforeAll`](#beforeall)
Expand Down Expand Up @@ -31,6 +33,29 @@ end function)

## Functions

### `test`

This is a shorthand for the `ts.addTest`.

```brs
test("it should check if true is true", function (_ts as Object) as String
return expect(true).toBeTrue()
end function)
```

### `testEach`

This is a shorthand for the `ts.addParameterizedTests`.

```brs
testEach([
{ value: 2, expectedValue: 2 },
{ value: "asd", expectedValue: "asd" },
], "it should check if ${value} is ${expectedValue}", function (_ts as Object, params as Object) as String
return expect(params.value).toBe(params.expectedValue)
end function)
```

bchelkowski marked this conversation as resolved.
Show resolved Hide resolved
### `it`

This is a shorthand for the `ts.addTest`.
Expand Down
6 changes: 3 additions & 3 deletions example/app/components/_tests/expectExamples.test.brs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ function TestSuite__expectExamples() as Object
' ---------------------------------------------------------
' toBeInvalid()
' ---------------------------------------------------------
it("expect(Invalid).toBeInvalid()", function () as String
test("it expect(Invalid).toBeInvalid()", function () as String
' Given
value = Invalid

' Then
return expect(value).toBeInvalid()
end function)

itEach([
testEach([
4,
true,
"Test Value",
{ key: "value" },
[1, 2, 3],
CreateObject("roSGNode", "rectangle"),
], "expect(nonInvalidValue).not.toBeInvalid()", function (value as Object) as String
], "it expect(nonInvalidValue).not.toBeInvalid()", function (value as Object) as String

' Then
return expect(value).not.toBeInvalid()
Expand Down
Loading
Loading