forked from cujojs/rest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmime-test.js
66 lines (57 loc) · 2.04 KB
/
mime-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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright 2014 the original author or authors
* @license MIT, see LICENSE.txt for details
*
* @author Scott Andrews
*/
(function (buster, define) {
'use strict';
var assert, refute, fail;
assert = buster.assertions.assert;
refute = buster.assertions.refute;
fail = buster.assertions.fail;
define('rest-test/mime-test', function (require) {
var mime;
mime = require('rest/mime');
buster.testCase('rest/mime', {
'should parse plain mime types': function () {
var parsed = mime.parse('text/plain');
assert.equals(parsed.raw, 'text/plain');
assert.equals(parsed.type, 'text/plain');
assert.equals(parsed.suffix, '');
assert.equals(parsed.params, {});
},
'should parse suffixed mime types': function () {
var parsed = mime.parse('application/hal+json');
assert.equals(parsed.raw, 'application/hal+json');
assert.equals(parsed.type, 'application/hal');
assert.equals(parsed.suffix, '+json');
assert.equals(parsed.params, {});
},
'should parse paramerters from mime types': function () {
var parsed = mime.parse('text/plain; charset=ascii; foo=bar');
assert.equals(parsed.raw, 'text/plain; charset=ascii; foo=bar');
assert.equals(parsed.type, 'text/plain');
assert.equals(parsed.suffix, '');
assert.equals(parsed.params, { charset: 'ascii', foo: 'bar' });
},
'should parse a naked mime suffix': function () {
var parsed = mime.parse('+json');
assert.equals(parsed.raw, '+json');
assert.equals(parsed.type, '');
assert.equals(parsed.suffix, '+json');
assert.equals(parsed.params, {});
}
});
});
}(
this.buster || require('buster'),
typeof define === 'function' && define.amd ? define : function (id, factory) {
var packageName = id.split(/[\/\-]/)[0], pathToRoot = id.replace(/[^\/]+/g, '..');
pathToRoot = pathToRoot.length > 2 ? pathToRoot.substr(3) : pathToRoot;
factory(function (moduleId) {
return require(moduleId.indexOf(packageName) === 0 ? pathToRoot + moduleId.substr(packageName.length) : moduleId);
});
}
// Boilerplate for AMD and Node
));