Name: js-handler/node_modules/restify/node_modules/negotiator/test/charset.js 
1:
(function() {
2:
  var configuration, preferredCharsets, testConfigurations, testCorrectCharset, _i, _len,
3:
    _this = this;
4:
 
5:
  preferredCharsets = require('../lib/charset').preferredCharsets;
6:
 
7:
  this["Should not return a charset when no charset is provided"] = function(test) {
8:
    test.deepEqual(preferredCharsets('*', []), []);
9:
    return test.done();
10:
  };
11:
 
12:
  this["Should not return a charset when no charset is acceptable"] = function(test) {
13:
    test.deepEqual(preferredCharsets('ISO-8859-1', ['utf-8']), []);
14:
    return test.done();
15:
  };
16:
 
17:
  this["Should not return a charset with q = 0"] = function(test) {
18:
    test.deepEqual(preferredCharsets('utf-8;q=0', ['utf-8']), []);
19:
    return test.done();
20:
  };
21:
 
22:
  testCorrectCharset = function(c) {
23:
    return _this["Should return " + c.selected + " for accept-charset header " + c.accept + " with provided charset " + c.provided] = function(test) {
24:
      test.deepEqual(preferredCharsets(c.accept, c.provided), c.selected);
25:
      return test.done();
26:
    };
27:
  };
28:
 
29:
  testConfigurations = [
30:
    {
31:
      accept: 'utf-8',
32:
      provided: ['utf-8'],
33:
      selected: ['utf-8']
34:
    }, {
35:
      accept: '*',
36:
      provided: ['utf-8'],
37:
      selected: ['utf-8']
38:
    }, {
39:
      accept: 'utf-8',
40:
      provided: ['utf-8', 'ISO-8859-1'],
41:
      selected: ['utf-8']
42:
    }, {
43:
      accept: 'utf-8, ISO-8859-1',
44:
      provided: ['utf-8'],
45:
      selected: ['utf-8']
46:
    }, {
47:
      accept: 'utf-8;q=0.8, ISO-8859-1',
48:
      provided: ['utf-8', 'ISO-8859-1'],
49:
      selected: ['ISO-8859-1', 'utf-8']
50:
    }
51:
  ];
52:
 
53:
  for (_i = 0, _len = testConfigurations.length; _i < _len; _i++) {
54:
    configuration = testConfigurations[_i];
55:
    testCorrectCharset(configuration);
56:
  }
57:
 
58:
}).call(this);