mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-10-29 01:38:35 +00:00
initial json parsing
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// MTMRTests.swift
|
||||
// MTMRTests
|
||||
//
|
||||
// Created by Anton Palgunov on 16/03/2018.
|
||||
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import MTMR
|
||||
|
||||
class MTMRTests: XCTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testExample() {
|
||||
// This is an example of a functional test case.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
}
|
||||
|
||||
func testPerformanceExample() {
|
||||
// This is an example of a performance test case.
|
||||
self.measure {
|
||||
// Put the code you want to measure the time of here.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import XCTest
|
||||
@testable import MTMR
|
||||
|
||||
class ParseConfig: XCTestCase {
|
||||
|
||||
func testButtonNoAction() {
|
||||
let buttonNoActionFixture = """
|
||||
[ { "type": "staticButton", "title": "Pew" } ]
|
||||
""".data(using: .utf8)!
|
||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonNoActionFixture)
|
||||
XCTAssertEqual(result?.first?.type, .staticButton(title: "Pew"))
|
||||
XCTAssertEqual(result?.first?.action, .some(.none))
|
||||
}
|
||||
|
||||
func testButtonKeyCodeAction() {
|
||||
let buttonKeycodeFixture = """
|
||||
[ { "type": "staticButton", "title": "Pew", "action": "hidKey", "keycode": 123} ]
|
||||
""".data(using: .utf8)!
|
||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonKeycodeFixture)
|
||||
XCTAssertEqual(result?.first?.type, .staticButton(title: "Pew"))
|
||||
XCTAssertEqual(result?.first?.action, .hidKey(keycode: 123))
|
||||
}
|
||||
|
||||
func testPredefinedItem() {
|
||||
let buttonKeycodeFixture = """
|
||||
[ { "type": "brightnessUp" } ]
|
||||
""".data(using: .utf8)!
|
||||
let result = try? JSONDecoder().decode([BarItemDefinition].self, from: buttonKeycodeFixture)
|
||||
XCTAssertEqual(result?.first?.type, .staticButton(title: "🔆"))
|
||||
XCTAssertEqual(result?.first?.action, .keyPress(keycode: 113))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user