vitess.io/vitess@v0.16.2/web/vtadmin/src/util/tablets.test.ts (about)

     1  /**
     2   * Copyright 2022 The Vitess Authors.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  import * as tablets from './tablets';
    18  
    19  describe('formatPaddedAlias', () => {
    20      it('pads with leading zeroes', () => {
    21          expect(
    22              tablets.formatPaddedAlias({
    23                  cell: 'zone1',
    24                  uid: 100,
    25              })
    26          ).toEqual('zone1-0000000100');
    27      });
    28  
    29      it('handles null input', () => {
    30          expect(tablets.formatPaddedAlias(null)).toEqual(null);
    31      });
    32  
    33      it('handles invalid cell', () => {
    34          expect(
    35              tablets.formatPaddedAlias({
    36                  cell: null,
    37                  uid: 100,
    38              })
    39          ).toEqual(null);
    40      });
    41  
    42      it('handles invalid uid', () => {
    43          expect(
    44              tablets.formatPaddedAlias({
    45                  cell: 'zone1',
    46                  uid: null,
    47              })
    48          ).toEqual(null);
    49      });
    50  });