-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathhomebrew.js
42 lines (34 loc) · 1.23 KB
/
homebrew.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
'use strict';
const Joi = require('joi');
const ServiceTester = require('./runner/service-tester');
const { isVPlusTripleDottedVersion } = require('./helpers/validators.js');
const { invalidJSON } = require('./helpers/response-fixtures');
const t = new ServiceTester({ id: 'homebrew', title: 'homebrew' });
module.exports = t;
t.create('homebrew (valid)')
.get('/v/cake.json')
.expectJSONTypes(Joi.object().keys({
name: 'homebrew',
value: isVPlusTripleDottedVersion,
}));
t.create('homebrew (valid, mocked response)')
.get('/v/cake.json')
.intercept(nock => nock('http://formulae.brew.sh')
.get('/formula/cake/version')
.reply(200, {stable: '0.23.0', devel: null, head: null})
)
.expectJSON({name: 'homebrew', value: 'v0.23.0'});
t.create('homebrew (invalid)')
.get('/v/not-a-package.json')
.expectJSON({name: 'homebrew', value: 'not found'});
t.create('homebrew (connection error)')
.get('/v/cake.json')
.networkOff()
.expectJSON({name: 'homebrew', value: 'inaccessible'});
t.create('homebrew (unexpected response)')
.get('/v/cake.json')
.intercept(nock => nock('http://formulae.brew.sh')
.get('/formula/cake/version')
.reply(invalidJSON)
)
.expectJSON({name: 'homebrew', value: 'invalid'});