~ubuntu-branches/ubuntu/utopic/node-negotiator/utopic

« back to all changes in this revision

Viewing changes to test/mediaType.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2014-04-27 17:11:18 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140427171118-yemum1gkn7agxx4b
Tags: 0.4.3-1
* New upstream release.
* Bump Standards-Version to 3.9.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    return test.done();
20
20
  };
21
21
 
 
22
  this["Should handle extra slashes on query params"] = function(test) {
 
23
    var type = 'application/xhtml+xml;profile="http://www.wapforum.org/xhtml"'
 
24
    test.deepEqual(preferredMediaTypes(type, ['application/xhtml+xml;profile="http://www.wapforum.org/xhtml"']), ['application/xhtml+xml;profile="http://www.wapforum.org/xhtml"']);
 
25
 
 
26
    return test.done();
 
27
  };
 
28
 
22
29
  testCorrectType = function(c) {
23
30
    return _this["Should return " + c.selected + " for access header " + c.accept + " with provided types " + c.provided] = function(test) {
24
31
      test.deepEqual(preferredMediaTypes(c.accept, c.provided), c.selected);
59
66
      accept: 'application/json;q=0.2, text/html',
60
67
      provided: null,
61
68
      selected: ['text/html', 'application/json']
 
69
    }, {
 
70
      accept: 'text/*, text/html;q=0',
 
71
      provided: ['text/html', 'text/plain'],
 
72
      selected: ['text/plain']
 
73
    }, {
 
74
      accept: 'text/*, text/html;q=0.5',
 
75
      provided: ['text/html', 'text/plain'],
 
76
      selected: ['text/plain', 'text/html']
 
77
    }, {
 
78
      accept: 'application/json, */*; q=0.01',
 
79
      provided: ['text/html', 'application/json'],
 
80
      selected: ['application/json', 'text/html']
 
81
    }, {
 
82
      accept: 'application/vnd.example;attribute=value',
 
83
      provided: ['application/vnd.example;attribute=other', 'application/vnd.example;attribute=value'],
 
84
      selected: ['application/vnd.example;attribute=value']
 
85
    }, {
 
86
      accept: 'application/vnd.example;attribute=other',
 
87
      provided: ['application/vnd.example', 'application/vnd.example;attribute=other'],
 
88
      selected: ['application/vnd.example;attribute=other']
 
89
    }, {
 
90
      accept: 'text/html;level=1',
 
91
      provided: ['text/html;level=1;foo=bar'],
 
92
      selected: ['text/html;level=1;foo=bar']
 
93
    }, {
 
94
      accept: 'text/html;level=1;foo=bar',
 
95
      provided: ['text/html;level=1'],
 
96
      selected: []
 
97
    }, {
 
98
      accept: 'text/html;level=2',
 
99
      provided: ['text/html;level=1'],
 
100
      selected: []
 
101
    }, {
 
102
      accept : 'text/html, text/html;level=1;q=0.1',
 
103
      provided : ['text/html', 'text/html;level=1'],
 
104
      selected : ['text/html', 'text/html;level=1']
 
105
    }, {
 
106
      accept : 'text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5',
 
107
      provided : ['text/html;level=1', 'text/html', 'text/html;level=3', 'image/jpeg', 'text/html;level=2', 'text/plain'],
 
108
      selected : ['text/html;level=1', 'text/html', 'text/html;level=3', 'image/jpeg', 'text/html;level=2', 'text/plain']
62
109
    }
 
110
 
63
111
  ];
64
112
 
65
113
  for (_i = 0, _len = testConfigurations.length; _i < _len; _i++) {