1// Copyright (c) 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5'use strict';
6
7base.require('cc.util');
8
9base.unittest.testSuite('cc.util', function() {
10  test('nameConvert', function() {
11    assertEquals('_foo', cc.convertNameToJSConvention('_foo'));
12    assertEquals('foo_', cc.convertNameToJSConvention('foo_'));
13    assertEquals('foo', cc.convertNameToJSConvention('foo'));
14    assertEquals('fooBar', cc.convertNameToJSConvention('foo_bar'));
15    assertEquals('fooBarBaz', cc.convertNameToJSConvention('foo_bar_baz'));
16  });
17
18  test('objectConvertNested', function() {
19    var object = {
20      un_disturbed: true,
21      args: {
22        foo_bar: {
23          a_field: 7
24        }
25      }
26    };
27    var expected = {
28      un_disturbed: true,
29      args: {
30        fooBar: {
31          aField: 7
32        }
33      }
34    };
35    cc.preInitializeObject(object);
36    assertObjectEquals(expected, object);
37  });
38
39  test('arrayConvert', function() {
40    var object = {
41      un_disturbed: true,
42      args: [
43        {foo_bar: 7},
44        {foo_bar: 8}
45      ]
46    };
47    var expected = {
48      un_disturbed: true,
49      args: [
50        {fooBar: 7},
51        {fooBar: 8}
52      ]
53    };
54    cc.preInitializeObject(object);
55    assertObjectEquals(expected, object);
56  });
57});
58