|
| 1 | +/* |
| 2 | + * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved |
| 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 { assert } from "chai"; |
| 18 | +import { MPQEditorProvider } from "../../MPQEditor/MPQEditor"; |
| 19 | +import { TestBuilder } from "../TestBuilder"; |
| 20 | + |
| 21 | +suite("MPQEditor", function () { |
| 22 | + suite("MPQEditorProvider", function () { |
| 23 | + let testBuilder: TestBuilder; |
| 24 | + |
| 25 | + setup(() => { |
| 26 | + testBuilder = new TestBuilder(this); |
| 27 | + testBuilder.setUp(); |
| 28 | + }); |
| 29 | + |
| 30 | + teardown(() => { |
| 31 | + testBuilder.tearDown(); |
| 32 | + }); |
| 33 | + |
| 34 | + suite("#validateMPQName", function () { |
| 35 | + test("test validateMPQName", function () { |
| 36 | + const dirPath: string = testBuilder.dirInTemp; |
| 37 | + const mpqName: string = "model-test-validateMPQName.mpq.json"; |
| 38 | + |
| 39 | + const retValue = MPQEditorProvider.validateMPQName(dirPath, mpqName); |
| 40 | + assert.isUndefined(retValue); |
| 41 | + }); |
| 42 | + |
| 43 | + test("NEG: test validateMPQName which exists", function () { |
| 44 | + const dirPath: string = testBuilder.dirInTemp; |
| 45 | + const mpqName: string = |
| 46 | + "model-test-validateMPQName_NEG_EXISTS.mpq.json"; |
| 47 | + const content = `empty content`; |
| 48 | + |
| 49 | + testBuilder.writeFileSync(mpqName, content); |
| 50 | + const retValue = MPQEditorProvider.validateMPQName(dirPath, mpqName); |
| 51 | + assert.isDefined(retValue); |
| 52 | + }); |
| 53 | + |
| 54 | + test("NEG: test validateMPQName with wrong extension", function () { |
| 55 | + const dirPath: string = testBuilder.dirInTemp; |
| 56 | + const mpqName: string = "model-test-validateMPQName_NEG_EXT.json"; |
| 57 | + |
| 58 | + const retValue = MPQEditorProvider.validateMPQName(dirPath, mpqName); |
| 59 | + assert.isDefined(retValue); |
| 60 | + }); |
| 61 | + }); |
| 62 | + }); |
| 63 | +}); |
0 commit comments