Skip to content

Commit a1344bd

Browse files
committed
add endpoint to get realm filters
1 parent 554ba9d commit a1344bd

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

examples/realm.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ const config = {
77
};
88

99
zulip(config).then((z) => {
10-
z.realm.retrieve().then(console.log);
10+
z.realm.emoji().then(console.log);
11+
}).catch(err => console.log(err.message));
12+
13+
zulip(config).then((z) => {
14+
z.realm.filters().then(console.log);
1115
}).catch(err => console.log(err.message));

src/resources/realm.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ const api = require('../api');
22

33
function realm(config) {
44
return {
5-
retrieve: (params) => {
5+
emoji: (params) => {
66
const url = `${config.apiURL}/realm/emoji`;
77
return api(url, config, 'GET', params);
88
},
9+
filters: (params) => {
10+
const url = `${config.apiURL}/realm/filters`;
11+
return api(url, config, 'GET', params);
12+
},
913
};
1014
}
1115

test/resources/realm.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,31 @@ describe('Realm', () => {
2626
result: 'success',
2727
};
2828
const stubs = common.getStubs(validator, output);
29-
realm(common.config).retrieve()
29+
realm(common.config).emoji()
30+
.then((data) => {
31+
data.should.have.property('result', 'success');
32+
common.restoreStubs(stubs);
33+
done();
34+
}).catch(done);
35+
});
36+
37+
it('should fetch realm filters', (done) => {
38+
const validator = (url, options) => {
39+
url.should.equal(`${common.config.apiURL}/realm/filters`);
40+
options.should.not.have.property('body');
41+
options.method.should.be.equal('GET');
42+
};
43+
const output = {
44+
filters: [
45+
['#(?P<id>[0-9]{2,8})',
46+
'https://github.com/zulip/zulip/pull/%(id)s',
47+
1],
48+
],
49+
msg: '',
50+
result: 'success',
51+
};
52+
const stubs = common.getStubs(validator, output);
53+
realm(common.config).filters()
3054
.then((data) => {
3155
data.should.have.property('result', 'success');
3256
common.restoreStubs(stubs);

0 commit comments

Comments
 (0)