Skip to content

Commit

Permalink
feat: add test and testEach functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bchelkowski committed Nov 28, 2023
1 parent ca29c34 commit a9720c0
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 1,278 deletions.
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)
```

### `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

0 comments on commit a9720c0

Please sign in to comment.