|
| 1 | +/* Copyright 2020 Mozilla Foundation |
| 2 | + * |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. |
| 5 | + * You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software |
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + * See the License for the specific language governing permissions and |
| 13 | + * limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +import { AnnotationStorage } from "../../src/display/annotation_storage.js"; |
| 17 | + |
| 18 | +describe("AnnotationStorage", function () { |
| 19 | + describe("GetOrCreateValue", function () { |
| 20 | + it("should get and set a new value in the annotation storage", function (done) { |
| 21 | + const annotationStorage = new AnnotationStorage(); |
| 22 | + let value = annotationStorage.getOrCreateValue("123A", "hello world"); |
| 23 | + expect(value).toEqual("hello world"); |
| 24 | + |
| 25 | + // the second argument is the default value to use |
| 26 | + // if the key isn't in the storage |
| 27 | + value = annotationStorage.getOrCreateValue("123A", "an other string"); |
| 28 | + expect(value).toEqual("hello world"); |
| 29 | + done(); |
| 30 | + }); |
| 31 | + }); |
| 32 | + |
| 33 | + describe("SetValue", function () { |
| 34 | + it("should set a new value in the annotation storage", function (done) { |
| 35 | + const annotationStorage = new AnnotationStorage(); |
| 36 | + annotationStorage.setValue("123A", "an other string"); |
| 37 | + const value = annotationStorage.getAll()["123A"]; |
| 38 | + expect(value).toEqual("an other string"); |
| 39 | + done(); |
| 40 | + }); |
| 41 | + }); |
| 42 | +}); |
0 commit comments