-
-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathtest.js
34 lines (25 loc) · 1.02 KB
/
test.js
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
31
32
33
34
import process from 'node:process';
import path from 'node:path';
import test from 'ava';
import {getWallpaper, setWallpaper, setSolidColorWallpaper, screens} from './index.js';
const MACOS_COLOR_PLACEHOLDER_PATH = '/System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane/Contents/Resources/DesktopPictures.prefPane/Contents/Resources/Transparent.tiff';
test('main', async t => {
const orignalImagePath = await getWallpaper();
await setWallpaper('fixture.jpg');
t.is(await getWallpaper(), path.resolve('fixture.jpg'));
await setWallpaper(orignalImagePath);
});
if (process.platform === 'darwin') {
test('screens()', async t => {
const screens_ = await screens();
console.log('Screens:', screens_);
t.true(Array.isArray(screens_));
t.true(screens_[0].length > 4);
});
test('setSolidColorWallpaper()', async t => {
const originalImagePath = await getWallpaper();
await setSolidColorWallpaper('000000');
t.is(await getWallpaper(), MACOS_COLOR_PLACEHOLDER_PATH);
await setWallpaper(originalImagePath);
});
}