2
var configuration, preferredMediaTypes, testConfigurations, testCorrectType, _i, _len,
5
preferredMediaTypes = require('../lib/mediaType').preferredMediaTypes;
7
this["Should not return a media type when no media type provided"] = function(test) {
8
test.deepEqual(preferredMediaTypes('*/*', []), []);
12
this["Should not return a media type when no media type is acceptable"] = function(test) {
13
test.deepEqual(preferredMediaTypes('application/json', ['text/html']), []);
17
this["Should not return a media type with q = 0"] = function(test) {
18
test.deepEqual(preferredMediaTypes('text/html;q=0', ['text/html']), []);
22
testCorrectType = function(c) {
23
return _this["Should return " + c.selected + " for access header " + c.accept + " with provided types " + c.provided] = function(test) {
24
test.deepEqual(preferredMediaTypes(c.accept, c.provided), c.selected);
29
testConfigurations = [
32
provided: ['text/html'],
33
selected: ['text/html']
36
provided: ['text/html'],
37
selected: ['text/html']
40
provided: ['text/html'],
41
selected: ['text/html']
43
accept: 'application/json, text/html',
44
provided: ['text/html'],
45
selected: ['text/html']
47
accept: 'text/html;q=0.1',
48
provided: ['text/html'],
49
selected: ['text/html']
51
accept: 'application/json, text/html',
52
provided: ['application/json', 'text/html'],
53
selected: ['application/json', 'text/html']
55
accept: 'application/json;q=0.2, text/html',
56
provided: ['application/json', 'text/html'],
57
selected: ['text/html', 'application/json']
59
accept: 'application/json;q=0.2, text/html',
61
selected: ['text/html', 'application/json']
65
for (_i = 0, _len = testConfigurations.length; _i < _len; _i++) {
66
configuration = testConfigurations[_i];
67
testCorrectType(configuration);