|
| 1 | +/* |
| 2 | + * Copyright 2021-Present The Serverless Workflow Specification Authors |
| 3 | + * <p> |
| 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 | + * <p> |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * <p> |
| 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 {MetadataBuilder} from '../src/model/metadata.builder'; |
| 18 | + |
| 19 | + |
| 20 | +describe("MetadataBuilder", () => { |
| 21 | + |
| 22 | + it("should create an empty object ", () => { |
| 23 | + |
| 24 | + expect(new MetadataBuilder().build()).toEqual({}); |
| 25 | + |
| 26 | + }); |
| 27 | + |
| 28 | + it("should create an object with key/value strings ", () => { |
| 29 | + |
| 30 | + expect(new MetadataBuilder() |
| 31 | + .withKeyValue("k1", "v1") |
| 32 | + .build()).toEqual( |
| 33 | + { |
| 34 | + "k1": "v1", |
| 35 | + }); |
| 36 | + |
| 37 | + |
| 38 | + expect(new MetadataBuilder() |
| 39 | + .withKeyValue("k2", "v2") |
| 40 | + .withKeyValue("k3", "v3") |
| 41 | + .build()).toEqual( |
| 42 | + { |
| 43 | + "k2": "v2", |
| 44 | + "k3": "v3", |
| 45 | + }); |
| 46 | + |
| 47 | + |
| 48 | + }); |
| 49 | + |
| 50 | + |
| 51 | + it("should allow to overwrite pairs of key/value ", () => { |
| 52 | + |
| 53 | + expect(new MetadataBuilder() |
| 54 | + .withKeyValue("k1", "v1") |
| 55 | + .withKeyValue("k1", "v2") |
| 56 | + .build()).toEqual( |
| 57 | + { |
| 58 | + "k1": "v2", |
| 59 | + }); |
| 60 | + |
| 61 | + |
| 62 | + }); |
| 63 | + |
| 64 | + |
| 65 | +}); |
| 66 | + |
| 67 | + |
| 68 | + |
0 commit comments