Skip to content

Commit

Permalink
Add test coverage for create()
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm committed Sep 7, 2021
1 parent e0287d7 commit 1f6771f
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion packages/runtime/spec/message-type.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {MessageType, RepeatType, ScalarType} from "../src";
import {containsMessageType, MESSAGE_TYPE, MessageType, RepeatType, ScalarType} from "../src";


describe('MessageType', () => {
Expand Down Expand Up @@ -71,5 +71,33 @@ describe('MessageType', () => {
expect(copy.repeatedInt32Field).not.toBe(msg.repeatedInt32Field);
})

it('create() adds message type', () => {
const msg = MyMessage.create({
stringField: "hello world",
});
expect(containsMessageType(msg)).toBeTrue();
if (containsMessageType(msg)) {
expect(msg[MESSAGE_TYPE]).toBe(MyMessage);
} else {
fail("containsMessageType() must return true");
}
})

it('create() creates expected object', () => {
const msg = MyMessage.create({
stringField: "hello world",
});
const exp: MyMessage = {
boolField: false,
messageMap: {},
stringField: "hello world",
repeatedInt32Field: [],
result: {
oneofKind: undefined
},
}
expect(msg).toEqual(exp);
})

});

0 comments on commit 1f6771f

Please sign in to comment.