-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
46 lines (30 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
35
36
37
38
39
40
41
42
43
44
45
46
/* eslint-env node, mocha */
/*eslint func-names: "off"*/
/*eslint prefer-arrow-callback: "off"*/
/*eslint no-unused-expressions: "off"*/
const expect = require('chai').expect;
const escape = require('./dist/remote-exec.js').escq;
const execSync = require('./dist/remote-exec.js').sync;
describe('single quote escaping', function () {
it('replaces each single quotes with the sequence: single quote, backslash, single quote, single quote, and wraps the whole string with single quotes.', function () {
expect(escape("'")).to.equal("''\\'''");
expect(escape("-'-")).to.equal("'-'\\''-'");
});
});
describe('sync execution', function () {
it('can connect to remote server or report error.', function () {
const result = execSync({
host: 'localhost',
user: 'guest'
}, [
'ls -al'
]);
if (result.status) {
// Errored.
expect(result.stderr).to.not.be.empty;
} else {
expect(result.stdout).to.not.be.empty;
expect(result.stderr).to.be.empty;
}
});
});