17c804472Sopenharmony_ci/*
27c804472Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
37c804472Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
47c804472Sopenharmony_ci * you may not use this file except in compliance with the License.
57c804472Sopenharmony_ci * You may obtain a copy of the License at
67c804472Sopenharmony_ci *
77c804472Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
87c804472Sopenharmony_ci *
97c804472Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
107c804472Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
117c804472Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127c804472Sopenharmony_ci * See the License for the specific language governing permissions and
137c804472Sopenharmony_ci * limitations under the License.
147c804472Sopenharmony_ci */
157c804472Sopenharmony_ci
167c804472Sopenharmony_ciimport { describe, expect, test } from '@jest/globals';
177c804472Sopenharmony_ciimport { generateVariableStatementDelcatation } from '../generate/generateVariableStatementDeclaration';
187c804472Sopenharmony_ci
197c804472Sopenharmony_cidescribe('generateVariableStatementDeclaration.ts file test', () => {
207c804472Sopenharmony_ci  test('Test statementEntity.typeKind is SyntaxKind.TypeReference', () => {
217c804472Sopenharmony_ci    const statementEntity = {
227c804472Sopenharmony_ci      statementName: 'daltonizationState',
237c804472Sopenharmony_ci      typeName: 'Config<boolean>',
247c804472Sopenharmony_ci      typeKind: 173,
257c804472Sopenharmony_ci      initializer: ''
267c804472Sopenharmony_ci    };
277c804472Sopenharmony_ci    const isInnerModule = false;
287c804472Sopenharmony_ci    const result = generateVariableStatementDelcatation(statementEntity, isInnerModule);
297c804472Sopenharmony_ci    expect(result).toBe('daltonizationState: Config,');
307c804472Sopenharmony_ci  });
317c804472Sopenharmony_ci
327c804472Sopenharmony_ci  test('Test statementEntity.typeKind is SyntaxKind.NumberKeyword', () => {
337c804472Sopenharmony_ci    const statementEntity = {
347c804472Sopenharmony_ci      statementName: 'batteryTemperature',
357c804472Sopenharmony_ci      typeName: 'number',
367c804472Sopenharmony_ci      typeKind: 144,
377c804472Sopenharmony_ci      initializer: ''
387c804472Sopenharmony_ci    };
397c804472Sopenharmony_ci    const isInnerModule = false;
407c804472Sopenharmony_ci    const result = generateVariableStatementDelcatation(statementEntity, isInnerModule);
417c804472Sopenharmony_ci    expect(result).toBe('batteryTemperature: 0,');
427c804472Sopenharmony_ci  });
437c804472Sopenharmony_ci
447c804472Sopenharmony_ci  test('Test statementEntity.typeKind is SyntaxKind.StringKeyword', () => {
457c804472Sopenharmony_ci    const statementEntity = {
467c804472Sopenharmony_ci      statementName: 'technology',
477c804472Sopenharmony_ci      typeName: 'string',
487c804472Sopenharmony_ci      typeKind: 147,
497c804472Sopenharmony_ci      initializer: ''
507c804472Sopenharmony_ci    };
517c804472Sopenharmony_ci    const isInnerModule = false;
527c804472Sopenharmony_ci    const result = generateVariableStatementDelcatation(statementEntity, isInnerModule);
537c804472Sopenharmony_ci    expect(result).toBe('technology: \'\',');
547c804472Sopenharmony_ci  });
557c804472Sopenharmony_ci
567c804472Sopenharmony_ci  test('Test statementEntity.typeKind is SyntaxKind.BooleanKeyword', () => {
577c804472Sopenharmony_ci    const statementEntity = {
587c804472Sopenharmony_ci      statementName: 'isBatteryPresent',
597c804472Sopenharmony_ci      typeName: 'boolean',
607c804472Sopenharmony_ci      typeKind: 131,
617c804472Sopenharmony_ci      initializer: ''
627c804472Sopenharmony_ci    };
637c804472Sopenharmony_ci    const isInnerModule = false;
647c804472Sopenharmony_ci    const result = generateVariableStatementDelcatation(statementEntity, isInnerModule);
657c804472Sopenharmony_ci    expect(result).toBe('isBatteryPresent: true,');
667c804472Sopenharmony_ci  });
677c804472Sopenharmony_ci
687c804472Sopenharmony_ci  test('Test statementEntity.typeKind is SyntaxKind.StringLiteral', () => {
697c804472Sopenharmony_ci    const statementEntity = {
707c804472Sopenharmony_ci      statementName: 'DATA_CHANGE_EVENT_ID',
717c804472Sopenharmony_ci      typeName: '',
727c804472Sopenharmony_ci      typeKind: 10,
737c804472Sopenharmony_ci      initializer: 'cloud_data_change'
747c804472Sopenharmony_ci    };
757c804472Sopenharmony_ci    const isInnerModule = false;
767c804472Sopenharmony_ci    const result = generateVariableStatementDelcatation(statementEntity, isInnerModule);
777c804472Sopenharmony_ci    expect(result).toBe('DATA_CHANGE_EVENT_ID: cloud_data_change,');
787c804472Sopenharmony_ci  });
797c804472Sopenharmony_ci
807c804472Sopenharmony_ci  test('Test statementEntity.typeKind is SyntaxKind.NumericLiteral', () => {
817c804472Sopenharmony_ci    const statementEntity = {
827c804472Sopenharmony_ci      statementName: 'MAX_KEY_LENGTH',
837c804472Sopenharmony_ci      typeName: '',
847c804472Sopenharmony_ci      typeKind: 8,
857c804472Sopenharmony_ci      initializer: '1024'
867c804472Sopenharmony_ci    };
877c804472Sopenharmony_ci    const isInnerModule = false;
887c804472Sopenharmony_ci    const result = generateVariableStatementDelcatation(statementEntity, isInnerModule);
897c804472Sopenharmony_ci    expect(result).toBe('MAX_KEY_LENGTH: 1024,');
907c804472Sopenharmony_ci  });
917c804472Sopenharmony_ci
927c804472Sopenharmony_ci  test('Test statementEntity.typeKind is SyntaxKind.LiteralType', () => {
937c804472Sopenharmony_ci    const statementEntity = {
947c804472Sopenharmony_ci      statementName: 'MAX_KEY_LENGTH',
957c804472Sopenharmony_ci      typeName: '80',
967c804472Sopenharmony_ci      typeKind: 191,
977c804472Sopenharmony_ci      initializer: ''
987c804472Sopenharmony_ci    };
997c804472Sopenharmony_ci    const isInnerModule = false;
1007c804472Sopenharmony_ci    const result = generateVariableStatementDelcatation(statementEntity, isInnerModule);
1017c804472Sopenharmony_ci    expect(result).toBe('MAX_KEY_LENGTH: 80,');
1027c804472Sopenharmony_ci  });
1037c804472Sopenharmony_ci});
104