Skip to content

Commit

Permalink
assert on swift end that values changed
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcotten committed Nov 3, 2022
1 parent 5951333 commit 3b2ab71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Tests/Sources/NAPITests/NAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ final class TestClass1: ClassConvertible {
testObject = TestObject(testString: "testString", optionalString: "optionalTestString", nested: .init(nestedTestString: "nestedTestString"), optionalNested: nil)
}

func assertTestString(_ string: String) throws {
try assertEqual(expected: string, actual: testString)
}

func assertTestNumber(_ number: Double) throws {
try assertEqual(expected: number, actual: testNumber)
}

func testThrowError() throws {
try throwError()
}
Expand All @@ -145,6 +153,8 @@ final class TestClass1: ClassConvertible {
static let jsInstanceMethods: [InstanceMethodDescriptor<TestClass1>] = [
.init("reset", TestClass1.reset),
.init("testThrowError", TestClass1.testThrowError),
.init("assertTestString", TestClass1.assertTestString),
.init("assertTestNumber", TestClass1.assertTestNumber)
]
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/test/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ describe('Classes', () => {

assert.strictEqual(object.testString, 'Cool')
object.testString = 'Changed'
assert.doesNotThrow(() => object.assertTestString('Changed'))
assert.strictEqual(object.testString, 'Changed')

assert.strictEqual(object.testNumber, 1234)
object.testNumber = 4567
assert.doesNotThrow(() => object.assertTestNumber(4567))
assert.strictEqual(object.testNumber, 4567)

assert.strictEqual(object.testObject.testString, 'testString')
Expand Down

0 comments on commit 3b2ab71

Please sign in to comment.