forked from wulkano/aperture-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
35 lines (30 loc) · 984 Bytes
/
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
35
import fs from 'fs';
import test from 'ava';
import delay from 'delay';
import readChunk from 'read-chunk';
import fileType from 'file-type';
import aperture from './index.js';
test('returns audio devices', async t => {
const devices = await aperture.audioDevices();
console.log('Audio devices:', devices);
t.true(Array.isArray(devices));
if (devices.length > 0) {
t.true(devices[0].id.length > 0);
t.true(devices[0].name.length > 0);
}
});
test('returns available video codecs', t => {
const codecs = aperture.videoCodecs;
console.log('Video codecs:', codecs);
t.true(codecs.has('h264'));
});
test('records screen', async t => {
const recorder = aperture();
await recorder.startRecording();
t.true(fs.existsSync(await recorder.isFileReady));
await delay(1000);
const videoPath = await recorder.stopRecording();
t.true(fs.existsSync(videoPath));
t.is(fileType(readChunk.sync(videoPath, 0, 4100)).ext, 'mov');
fs.unlinkSync(videoPath);
});