-
-
Notifications
You must be signed in to change notification settings - Fork 174
/
KeyboardShortcutsTests.swift
30 lines (22 loc) · 1.04 KB
/
KeyboardShortcutsTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import XCTest
import KeyboardShortcuts
final class KeyboardShortcutsTests: XCTestCase {
// TODO: Add more tests.
override func setUpWithError() throws {
UserDefaults.standard.removeAll()
}
func testSetShortcutAndReset() throws {
let defaultShortcut = KeyboardShortcuts.Shortcut(.c)
let shortcut1 = KeyboardShortcuts.Shortcut(.a)
let shortcut2 = KeyboardShortcuts.Shortcut(.b)
let shortcutName1 = KeyboardShortcuts.Name("testSetShortcutAndReset1")
let shortcutName2 = KeyboardShortcuts.Name("testSetShortcutAndReset2", default: defaultShortcut)
KeyboardShortcuts.setShortcut(shortcut1, for: shortcutName1)
KeyboardShortcuts.setShortcut(shortcut2, for: shortcutName2)
XCTAssertEqual(KeyboardShortcuts.getShortcut(for: shortcutName1), shortcut1)
XCTAssertEqual(KeyboardShortcuts.getShortcut(for: shortcutName2), shortcut2)
KeyboardShortcuts.reset(shortcutName1, shortcutName2)
XCTAssertNil(KeyboardShortcuts.getShortcut(for: shortcutName1))
XCTAssertEqual(KeyboardShortcuts.getShortcut(for: shortcutName2), defaultShortcut)
}
}