This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
/
macro.js
70 lines (63 loc) · 1.77 KB
/
macro.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var desk = require('../')
, should = require('should')
, replay = require('replay')
, macroHref
;
replay.fixtures = __dirname + '/fixtures';
replay.mode = 'record';
replay.request_headers = [/^accept/, /^content-type/, /^host/, /^if-/, /^x-/];
try {
config = require('../config/test');
} catch (err) {
config = {
subdomain: 'devel',
username: 'devel@example.com',
password: '12345'
}
}
function createClient() {
return desk.createClient({
subdomain: config.subdomain ,
username: config.username,
password: config.password
})
}
// check if the hack works
describe('Macro', function() {
describe('create', function() {
it('creates a new macro', function(done) {
var client = createClient();
client.macros().create({
name: 'Assign to Engineering',
description: 'It\'s raining fire!'
}, function(err, macro) {
macro.getName().should.equal('Assign to Engineering');
macro.getDescription().should.equal('It\'s raining fire!');
macroHref = macro.definition._links.self.href;
done();
});
})
})
describe('update', function() {
it('updates a macro', function(done) {
var client = createClient();
client.macros().byUrl(macroHref, function(err, macro) {
macro.update({ name: 'Assign to Engineering and Support' }, function(err, macro) {
macro.getName().should.equal('Assign to Engineering and Support');
done();
});
});
})
})
describe('delete', function() {
it('deletes a macro', function(done) {
var client = createClient();
client.macros().byUrl(macroHref, function(err, macro) {
macro.destroy(function(err) {
should.not.exist(err);
done();
});
});
})
})
})