• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2021 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7//     https://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, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14
15/* eslint-env browser, jasmine */
16import 'jasmine';
17
18import {Message} from 'test_protos_tspb/test_protos_tspb_pb/pw_protobuf_compiler/pw_protobuf_compiler_protos/nested/more_nesting/test_pb';
19
20import {ProtoCollection} from 'test_proto_collection/generated/ts_proto_collection';
21
22describe('ProtoCollection', () => {
23  it('getMessageType returns message', () => {
24    const lib = new ProtoCollection();
25
26    const fetched = lib.getMessageCreator('pw.protobuf_compiler.test.Message');
27    expect(fetched).toEqual(Message);
28  });
29
30  it('getMessageType for invalid identifier returns undefined', () => {
31    const lib = new ProtoCollection();
32
33    let fetched = lib.getMessageCreator('pw');
34    expect(fetched).toBeUndefined();
35    fetched = lib.getMessageCreator('pw.test1.Garbage');
36    expect(fetched).toBeUndefined();
37  });
38});
39