1*61c4878aSAndroid Build Coastguard Worker/** 2*61c4878aSAndroid Build Coastguard Worker * @jest-environment jsdom 3*61c4878aSAndroid Build Coastguard Worker */ 4*61c4878aSAndroid Build Coastguard Worker 5*61c4878aSAndroid Build Coastguard Worker// Copyright 2022 The Pigweed Authors 6*61c4878aSAndroid Build Coastguard Worker// 7*61c4878aSAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); you may not 8*61c4878aSAndroid Build Coastguard Worker// use this file except in compliance with the License. You may obtain a copy of 9*61c4878aSAndroid Build Coastguard Worker// the License at 10*61c4878aSAndroid Build Coastguard Worker// 11*61c4878aSAndroid Build Coastguard Worker// https://www.apache.org/licenses/LICENSE-2.0 12*61c4878aSAndroid Build Coastguard Worker// 13*61c4878aSAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 14*61c4878aSAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15*61c4878aSAndroid Build Coastguard Worker// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 16*61c4878aSAndroid Build Coastguard Worker// License for the specific language governing permissions and limitations under 17*61c4878aSAndroid Build Coastguard Worker// the License. 18*61c4878aSAndroid Build Coastguard Worker 19*61c4878aSAndroid Build Coastguard Workerimport { 20*61c4878aSAndroid Build Coastguard Worker pw_status, 21*61c4878aSAndroid Build Coastguard Worker pw_hdlc, 22*61c4878aSAndroid Build Coastguard Worker pw_rpc, 23*61c4878aSAndroid Build Coastguard Worker pw_tokenizer, 24*61c4878aSAndroid Build Coastguard Worker pw_transfer, 25*61c4878aSAndroid Build Coastguard Worker WebSerial, 26*61c4878aSAndroid Build Coastguard Worker} from '../dist/index.umd'; 27*61c4878aSAndroid Build Coastguard Worker 28*61c4878aSAndroid Build Coastguard Workerimport { ProtoCollection } from '../dist/protos/collection.umd'; 29*61c4878aSAndroid Build Coastguard Workerimport { 30*61c4878aSAndroid Build Coastguard Worker createLogViewer, 31*61c4878aSAndroid Build Coastguard Worker MockLogSource, 32*61c4878aSAndroid Build Coastguard Worker PigweedRPCLogSource, 33*61c4878aSAndroid Build Coastguard Worker} from '../dist/logging.umd'; 34*61c4878aSAndroid Build Coastguard Workerimport * as fs from 'fs'; 35*61c4878aSAndroid Build Coastguard Worker 36*61c4878aSAndroid Build Coastguard Workerdescribe('Pigweed Bundle', () => { 37*61c4878aSAndroid Build Coastguard Worker it('proto collection has file list', () => { 38*61c4878aSAndroid Build Coastguard Worker const protoCollection = new ProtoCollection(); 39*61c4878aSAndroid Build Coastguard Worker const fd = protoCollection.fileDescriptorSet.getFileList(); 40*61c4878aSAndroid Build Coastguard Worker expect(fd.length).toBeGreaterThan(0); 41*61c4878aSAndroid Build Coastguard Worker }); 42*61c4878aSAndroid Build Coastguard Worker 43*61c4878aSAndroid Build Coastguard Worker it('has pw_status enum defined', () => { 44*61c4878aSAndroid Build Coastguard Worker const Status = pw_status.Status; 45*61c4878aSAndroid Build Coastguard Worker expect(Status[Status.OUT_OF_RANGE]).toBeDefined(); 46*61c4878aSAndroid Build Coastguard Worker }); 47*61c4878aSAndroid Build Coastguard Worker 48*61c4878aSAndroid Build Coastguard Worker it('has pw_hdlc frame, frame status, decoder and encoder defined', () => { 49*61c4878aSAndroid Build Coastguard Worker expect(pw_hdlc.Frame).toBeDefined(); 50*61c4878aSAndroid Build Coastguard Worker expect(pw_hdlc.FrameStatus).toBeDefined(); 51*61c4878aSAndroid Build Coastguard Worker expect(pw_hdlc.Decoder).toBeDefined(); 52*61c4878aSAndroid Build Coastguard Worker expect(pw_hdlc.Encoder).toBeDefined(); 53*61c4878aSAndroid Build Coastguard Worker }); 54*61c4878aSAndroid Build Coastguard Worker 55*61c4878aSAndroid Build Coastguard Worker it('has pw_rpc defined', () => { 56*61c4878aSAndroid Build Coastguard Worker expect(pw_rpc.Client).toBeDefined(); 57*61c4878aSAndroid Build Coastguard Worker expect(pw_rpc.Rpc).toBeDefined(); 58*61c4878aSAndroid Build Coastguard Worker expect(pw_rpc.Channel).toBeDefined(); 59*61c4878aSAndroid Build Coastguard Worker }); 60*61c4878aSAndroid Build Coastguard Worker 61*61c4878aSAndroid Build Coastguard Worker it('has pw_tokenizer defined', () => { 62*61c4878aSAndroid Build Coastguard Worker expect(pw_tokenizer.Detokenizer).toBeDefined(); 63*61c4878aSAndroid Build Coastguard Worker expect(pw_tokenizer.PrintfDecoder).toBeDefined(); 64*61c4878aSAndroid Build Coastguard Worker }); 65*61c4878aSAndroid Build Coastguard Worker 66*61c4878aSAndroid Build Coastguard Worker it('has pw_transfer defined', () => { 67*61c4878aSAndroid Build Coastguard Worker expect(pw_transfer.Manager).toBeDefined(); 68*61c4878aSAndroid Build Coastguard Worker }); 69*61c4878aSAndroid Build Coastguard Worker 70*61c4878aSAndroid Build Coastguard Worker it('has WebSerialTransport defined', () => { 71*61c4878aSAndroid Build Coastguard Worker expect(WebSerial.WebSerialTransport).toBeDefined(); 72*61c4878aSAndroid Build Coastguard Worker }); 73*61c4878aSAndroid Build Coastguard Worker 74*61c4878aSAndroid Build Coastguard Worker it('has ProgressStats defined', () => { 75*61c4878aSAndroid Build Coastguard Worker expect(pw_transfer.ProgressStats).toBeDefined(); 76*61c4878aSAndroid Build Coastguard Worker }); 77*61c4878aSAndroid Build Coastguard Worker 78*61c4878aSAndroid Build Coastguard Worker it('has log viewer exports defined', () => { 79*61c4878aSAndroid Build Coastguard Worker expect(createLogViewer).toBeDefined(); 80*61c4878aSAndroid Build Coastguard Worker expect(typeof createLogViewer).toBe('function'); 81*61c4878aSAndroid Build Coastguard Worker 82*61c4878aSAndroid Build Coastguard Worker expect(MockLogSource).toBeDefined(); 83*61c4878aSAndroid Build Coastguard Worker expect(typeof MockLogSource).toBe('function'); 84*61c4878aSAndroid Build Coastguard Worker expect(MockLogSource.name).toBe('MockLogSource'); 85*61c4878aSAndroid Build Coastguard Worker 86*61c4878aSAndroid Build Coastguard Worker expect(PigweedRPCLogSource).toBeDefined(); 87*61c4878aSAndroid Build Coastguard Worker expect(typeof PigweedRPCLogSource).toBe('function'); 88*61c4878aSAndroid Build Coastguard Worker expect(PigweedRPCLogSource.name).toBe('PigweedRPCLogSource'); 89*61c4878aSAndroid Build Coastguard Worker }); 90*61c4878aSAndroid Build Coastguard Worker 91*61c4878aSAndroid Build Coastguard Worker it('is not referring to any outside Pigweed modules', () => { 92*61c4878aSAndroid Build Coastguard Worker const requireString = "require('pigweedjs"; 93*61c4878aSAndroid Build Coastguard Worker const file = fs.readFileSync(require.resolve('../dist/index.umd')); 94*61c4878aSAndroid Build Coastguard Worker expect(file.indexOf(requireString)).toBe(-1); 95*61c4878aSAndroid Build Coastguard Worker }); 96*61c4878aSAndroid Build Coastguard Worker}); 97