-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paths3-uri.spec.js
46 lines (39 loc) · 1.13 KB
/
s3-uri.spec.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
var _ = require('underscore');
var c = require('rho-contracts-fork');
var s3Uri = require('./s3-uri');
var should = require('should');
// For convenience and conciseness.
var good = should.doesNotThrow;
var bad = function (block) { should.throws(block, c.ContractError); };
describe('s3Uri', function () {
var goodUris = [
's3://foo/bar/baz',
's3://foo/bar',
's3://foo',
];
var badUris = [
'https://foo/bar/baz',
's3://fiz:buzz@foo/bar/baz',
's3://foo/bar/baz?bazinga',
's3://foo/bar/baz#bazinga',
'bogus',
[],
{},
undefined,
null,
];
context('invoked with a good s3 uri', function () {
it('does not raise a contract error', function () {
_(goodUris).each(function (uri) {
good(function () { s3Uri.check(uri); });
});
});
});
context('invoked with a bad s3 uri', function () {
it('raises a contract error', function () {
_(badUris).each(function (uri) {
bad(function () { s3Uri.check(uri); });
});
});
});
});