Skip to content

Commit 0977a93

Browse files
committed
Add GitHub Actions workflow, assert in the test
1 parent bcf43c4 commit 0977a93

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build and test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
macos_test:
10+
runs-on: macos-11.0
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Run the test suite on macOS
15+
shell: bash
16+
run: |
17+
set -ex
18+
sudo xcode-select --switch /Applications/Xcode_12.3.app/Contents/Developer/
19+
20+
brew install swiftwasm/tap/carton
21+
22+
carton test --environment defaultBrowser

Tests/DOMKitTests/DOMKitTests.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import XCTest
2-
import JavaScriptKit
3-
@testable import DOMKit
2+
import DOMKit
43

54
final class DOMKitTests: XCTestCase {
65
func testExample() {
7-
let document = DOMKit.Document(from: JSObject.global.document)!
6+
let document = global.document
87
let button = document.createElement(localName: "button")
9-
button.textContent = "Hello, world"
8+
button.textContent = "Hello, world!"
109
button.addEventListener(type: "click") { event in
1110
(event.target as? HTMLElement)?.textContent = "Clicked!"
1211
}
1312
_ = document.querySelector(selectors: "body")?.appendChild(node: button)
13+
14+
let queriedButton = document.querySelector(selectors: "body button")
15+
XCTAssertEqual(button.textContent, "Hello, world!")
1416
}
1517
}

0 commit comments

Comments
 (0)