|
1 |
| -import { Ancestor1, GreetingRequest, TopLevelEnumExample, RepeatedThing } from "../../greeting_pb.mjs" |
| 1 | +import { Ancestor1, GreetingRequest, TopLevelEnumExample, RepeatedThing, MutuallyExclusiveThing } from "../../greeting_pb.mjs" |
2 | 2 | import { Position } from "../../location/location_pb.mjs"
|
3 | 3 | //import { GreetingRequest } from "../../greeting_pb";
|
4 | 4 |
|
@@ -54,6 +54,33 @@ describe("lib", () => {
|
54 | 54 | const thing = new RepeatedThing().setChildPositionsList([a, b]);
|
55 | 55 | expect(thing.getChildPositionsList().map(x => x.getLatitude())).toEqual([42, 43]);
|
56 | 56 | });
|
| 57 | + |
| 58 | + it("should return correct oneof case", () => { |
| 59 | + const thing = new MutuallyExclusiveThing().setMutexString("test"); |
| 60 | + expect(thing.getSomeValueCase()).toEqual(1); |
| 61 | + }); |
| 62 | + |
| 63 | + it("should return correct oneof case for nested message", () => { |
| 64 | + const thing = new MutuallyExclusiveThing() |
| 65 | + .setTheThing(new MutuallyExclusiveThing.NestedThing().setMutexString("test")); |
| 66 | + expect(thing.getTheThing().getSomeValueCase()).toEqual(1); |
| 67 | + }); |
| 68 | + |
| 69 | + it("should clear field", () => { |
| 70 | + const message = new GreetingRequest().setOrigin(new Position()); |
| 71 | + expect(message.getOrigin()).not.toBeUndefined(); |
| 72 | + |
| 73 | + message.clearOrigin(); |
| 74 | + expect(message.getOrigin()).toBeUndefined(); |
| 75 | + }); |
| 76 | + |
| 77 | + it("should be able to check if value set", () => { |
| 78 | + const message = new GreetingRequest(); |
| 79 | + expect(message.hasOrigin()).toBe(false); |
| 80 | + |
| 81 | + message.setOrigin(new Position()); |
| 82 | + expect(message.hasOrigin()).toBe(true); |
| 83 | + }) |
57 | 84 | });
|
58 | 85 |
|
59 | 86 | describe("TopLevelEnumExample", () => {
|
|
0 commit comments