hs2-mock 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,59 +23,59 @@ Reading a member the mock lacks throws `hs2-mock: hs.x.y is not mocked`. Tests c
23
23
 
24
24
  ## Mocked
25
25
 
26
- | Module | Members |
27
- |---|---|
28
- | `hs.appinfo` | `pid` |
29
- | `hs.application` | `frontmost`, `fromPID`, `launchOrFocus`, `matchingBundleID`, `on`, `off` |
30
- | `hs.audiodevice` | `allInputDevices`, `allOutputDevices`, `defaultInputDevice`, `defaultOutputDevice`, `on`, `off` |
31
- | `hs.ax` | `applicationElement`, `windowElement` |
32
- | `hs.distributednotifications` | `on`, `off` |
33
- | `hs.fs` (in memory) | `exists`, `homeDirectory`, `mkdir`, `read`, `urlFromPath`, `write` |
34
- | `hs.hotkey` | `bind`, `create` |
35
- | `hs.menubar` | `create` (`title`, `setIcon`, `setMenu`, `destroy`) |
36
- | `hs.notify` | `show`, `create` (`send`) |
37
- | `hs.permissions` | `checkAccessibility`, `checkLocation`, `requestLocation`, `requestNotifications` |
38
- | `hs.power` | `on`, `off` |
39
- | `hs.screen` | `main` |
40
- | `hs.task` | `create`, `runAsync` |
41
- | `hs.timer` | `absoluteTime`, `doAfter`, `doEvery`, `secondsSinceEpoch` |
42
- | `hs.ui` | `alert`, `dialog`, `webview`, `window` |
43
- | `hs.urlevent` | `openURL` |
44
- | `hs.wifi` | `currentNetwork`, `on`, `off` |
45
- | `HSImage`, `HSSize` globals | `fromName`, `fromSymbol` |
26
+ | Module | Members |
27
+ | ----------------------------- | ----------------------------------------------------------------------------------------------- |
28
+ | `hs.appinfo` | `pid` |
29
+ | `hs.application` | `frontmost`, `fromPID`, `launchOrFocus`, `matchingBundleID`, `on`, `off` |
30
+ | `hs.audiodevice` | `allInputDevices`, `allOutputDevices`, `defaultInputDevice`, `defaultOutputDevice`, `on`, `off` |
31
+ | `hs.ax` | `applicationElement`, `windowElement` |
32
+ | `hs.distributednotifications` | `on`, `off` |
33
+ | `hs.fs` (in memory) | `exists`, `homeDirectory`, `mkdir`, `read`, `urlFromPath`, `write` |
34
+ | `hs.hotkey` | `bind`, `create` |
35
+ | `hs.menubar` | `create` (`title`, `setIcon`, `setMenu`, `destroy`) |
36
+ | `hs.notify` | `show`, `create` (`send`) |
37
+ | `hs.permissions` | `checkAccessibility`, `checkLocation`, `requestLocation`, `requestNotifications` |
38
+ | `hs.power` | `on`, `off` |
39
+ | `hs.screen` | `main` |
40
+ | `hs.task` | `create`, `runAsync` |
41
+ | `hs.timer` | `absoluteTime`, `doAfter`, `doEvery`, `secondsSinceEpoch` |
42
+ | `hs.ui` | `alert`, `dialog`, `webview`, `window` |
43
+ | `hs.urlevent` | `openURL` |
44
+ | `hs.wifi` | `currentNetwork`, `on`, `off` |
45
+ | `HSImage`, `HSSize` globals | `fromName`, `fromSymbol` |
46
46
 
47
47
  ## Controls (`ctl`)
48
48
 
49
- | Control | Does |
50
- |---|---|
51
- | `advance(seconds)` | Moves the clock, firing timers and settling promises between them |
52
- | `flush()` | Settles pending promises |
53
- | `addApp({ bundleID, name, allWindows, focusedWindow, mainWindow })` | Adds a running app and returns it |
54
- | `activate(bundleID)` | Brings an app to the front and emits `didActivate`; `null` for one without a bundle ID |
55
- | `killed`, `launched`, `activations`, `raised` | Apps killed, launched and activated, and windows raised |
56
- | `frontmostRequests` | Times Hammerspoon asked to be frontmost |
57
- | `element({ role, children, attributes })` | An accessibility element |
58
- | `window(element)` | A window whose element it is |
59
- | `url(text)` | A URL attribute value, as `hs.ax` returns it |
60
- | `hotkeys` | Created hotkeys that have not been destroyed |
61
- | `tasks` | Started tasks: `launchPath`, `args`, `environment`, `running`, `terminated`, `inputClosed`, `finish({ stdout, exitCode, reason, error })` |
62
- | `respondToTasks(handler)` | Answers each task as it starts with what `finish()` takes, or `undefined` to leave it running |
63
- | `menubarItems` | Menu bar items: `item`, `icon`, `menu`, `destroyed` |
64
- | `notifications` | `title`, `body`; `click()` for `show()` ones, `options` for `create()` ones |
65
- | `dialogs` | `message`, `informativeText`, `buttons`, `open`, `press(label)` |
66
- | `windows` | `rect`, `title`, `view.html`, `view.post(name, body)`, `shown`, `userClose()` |
67
- | `alerts`, `openedURLs` | What was shown and opened |
68
- | `files`, `dirs`, `home`, `writeFails` | The in-memory file system |
69
- | `power(event)`, `notify(name)` | Emits an `hs.power` event or a distributed notification |
70
- | `ssid`, `wifi(event)` | The current Wi-Fi network, and its events |
71
- | `addAudioDevice({ name, uid, input })` | Adds an audio device (emits `dev+`) and returns it |
72
- | `removeAudioDevice(device)` | Removes it (emits `dev-`) |
73
- | `setDefaultAudioDevice(direction, device)` | Sets the default and emits `dOut` or `dIn` |
74
- | `updateAudioDevice(device, changes)` | Sets `volume` or `muted` and emits the device event |
75
- | `audioListeners()` | Number of audio listeners registered |
76
- | `images` | Add the names `HSImage.fromName` can load |
77
- | `accessibility`, `location`, `notificationPermission` | Whether each permission is granted |
78
- | `locationRequests` | How often location permission was requested |
49
+ | Control | Does |
50
+ | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
51
+ | `advance(seconds)` | Moves the clock, firing timers and settling promises between them |
52
+ | `flush()` | Settles pending promises |
53
+ | `addApp({ bundleID, name, allWindows, focusedWindow, mainWindow })` | Adds a running app and returns it |
54
+ | `activate(bundleID)` | Brings an app to the front and emits `didActivate`; `null` for one without a bundle ID |
55
+ | `killed`, `launched`, `activations`, `raised` | Apps killed, launched and activated, and windows raised |
56
+ | `frontmostRequests` | Times Hammerspoon asked to be frontmost |
57
+ | `element({ role, children, attributes })` | An accessibility element |
58
+ | `window(element)` | A window whose element it is |
59
+ | `url(text)` | A URL attribute value, as `hs.ax` returns it |
60
+ | `hotkeys` | Created hotkeys that have not been destroyed |
61
+ | `tasks` | Started tasks: `launchPath`, `args`, `environment`, `running`, `terminated`, `inputClosed`, `finish({ stdout, exitCode, reason, error })` |
62
+ | `respondToTasks(handler)` | Answers each task as it starts with what `finish()` takes, or `undefined` to leave it running |
63
+ | `menubarItems` | Menu bar items: `item`, `icon`, `menu`, `destroyed` |
64
+ | `notifications` | `title`, `body`; `click()` for `show()` ones, `options` for `create()` ones |
65
+ | `dialogs` | `message`, `informativeText`, `buttons`, `open`, `press(label)` |
66
+ | `windows` | `rect`, `title`, `view.html`, `view.post(name, body)`, `shown`, `userClose()` |
67
+ | `alerts`, `openedURLs` | What was shown and opened |
68
+ | `files`, `dirs`, `home`, `writeFails` | The in-memory file system |
69
+ | `power(event)`, `notify(name)` | Emits an `hs.power` event or a distributed notification |
70
+ | `ssid`, `wifi(event)` | The current Wi-Fi network, and its events |
71
+ | `addAudioDevice({ name, uid, input })` | Adds an audio device (emits `dev+`) and returns it |
72
+ | `removeAudioDevice(device)` | Removes it (emits `dev-`) |
73
+ | `setDefaultAudioDevice(direction, device)` | Sets the default and emits `dOut` or `dIn` |
74
+ | `updateAudioDevice(device, changes)` | Sets `volume` or `muted` and emits the device event |
75
+ | `audioListeners()` | Number of audio listeners registered |
76
+ | `images` | Add the names `HSImage.fromName` can load |
77
+ | `accessibility`, `location`, `notificationPermission` | Whether each permission is granted |
78
+ | `locationRequests` | How often location permission was requested |
79
79
 
80
80
  ## Types
81
81
 
package/lib/menubar.js CHANGED
@@ -5,8 +5,15 @@ function createMenubar() {
5
5
  const module = {
6
6
  create() {
7
7
  const record = { icon: null, menu: null, destroyed: false };
8
+ let title = null;
8
9
  record.item = strict("HSMenuBarItem", {
9
- title: null,
10
+ get title() {
11
+ return title;
12
+ },
13
+ // HS2 1.0.0-beta.4 shows a null title as the text "null".
14
+ set title(value) {
15
+ title = String(value);
16
+ },
10
17
  setIcon(icon) {
11
18
  record.icon = icon;
12
19
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hs2-mock",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Strict mock of the Hammerspoon 2 hs global for testing Spoons under node:test",
5
5
  "license": "MIT",
6
6
  "repository": {