summaryrefslogtreecommitdiff
path: root/tests/js/doctools.js
blob: 8533f71484356e2dd03a38f4354e1d78dfe3402f (plain)
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
var DOCUMENTATION_OPTIONS = {};

describe('urldecode', function() {

  it('should correctly decode URLs and replace `+`s with a spaces', function() {
    var test_encoded_string =
      '%D1%88%D0%B5%D0%BB%D0%BB%D1%8B+%D1%88%D0%B5%D0%BB%D0%BB%D1%8B';
    var test_decoded_string = 'шеллы шеллы';
    expect(jQuery.urldecode(test_encoded_string)).toEqual(test_decoded_string);
  });

});

describe('getQueryParameters', function() {
  var paramString = '?q=test+this&check_keywords=yes&area=default';
  var queryParamObject = {
    area: ['default'],
    check_keywords: ['yes'],
    q: ['test this']
  };

  it('should correctly create query parameter object from string', function() {
    expect(jQuery.getQueryParameters(paramString)).toEqual(queryParamObject);
  });

  it('should correctly create query param object from URL params', function() {
    history.pushState({}, '_', window.location + paramString);
    expect(jQuery.getQueryParameters()).toEqual(queryParamObject);
  });

});