summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/md_downloads/action_service_unittest.gtestjs
blob: 9f850352f75ac9b204fad8f69be043897aefc448 (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
33
34
35
36
37
38
39
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * @param {!Array<string>} list
 * @return {string}
 */
function str(list) {
  return JSON.stringify(list);
}

/**
 * @extends {testing.Test}
 * @constructor
 */
function ActionServiceUnitTest() {}

ActionServiceUnitTest.prototype = {
  __proto__: testing.Test.prototype,

  /** @override */
  extraLibraries: [
    '../../../../ui/webui/resources/js/cr.js',
    'action_service.js',
  ],
};

TEST_F('ActionServiceUnitTest', 'splitTerms', function() {
  var ActionService = downloads.ActionService;
  assertEquals(str([]), str(ActionService.splitTerms('')));
  assertEquals(str([]), str(ActionService.splitTerms('  ')));
  assertEquals(str(['a']), str(ActionService.splitTerms('a')));
  assertEquals(str(['a b']), str(ActionService.splitTerms('a b')));
  assertEquals(str(['a', 'b']), str(ActionService.splitTerms('a "b"')));
  assertEquals(str(['a', 'b', 'c']), str(ActionService.splitTerms('a "b" c')));
  assertEquals(str(['a', 'b b', 'c']),
               str(ActionService.splitTerms('a "b b" c')));
});