Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: simplified example tests #868

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/TEMPLATE/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to render TEMPLATE', () => {
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/TEMPLATE/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/adapting-input-and-output/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ describe('Should be able to generate a model with custom input and output ', ()

test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/adapting-input-and-output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/asyncapi-from-object/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ describe('Should be able to process a pure AsyncAPI object', () => {
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/asyncapi-from-object/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ export async function generate(): Promise<void> {
}
}

generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/asyncapi-from-parser/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to process AsyncAPI object from parser', () => {
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/asyncapi-from-parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/change-type-mapping/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to render models with custom naming formatter', () => {
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/change-type-mapping/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/csharp-auto-implemented-properties/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to render auto-implemented properties in CSharp', () =>
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/csharp-auto-implemented-properties/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ export async function generate(): Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/csharp-change-collection-type/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to render collections in C# as IEnumerable', () => {
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/csharp-change-collection-type/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/csharp-generate-equals-and-hashcode/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to generate a model to overwrite the Equal and GetHashC
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/csharp-generate-equals-and-hashcode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/csharp-generate-required-properties/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to render required properties without the question mark
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/csharp-generate-required-properties/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ export async function generate(): Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/csharp-generate-serializer/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ describe('Should be able to generate a model with functions to serialize the dat

test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/csharp-generate-serializer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/csharp-overwrite-enum-naming/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ describe('Should be able to generate enums with custom value names', () => {

test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/csharp-overwrite-enum-naming/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/csharp-use-inheritance/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to render inheritance', () => {
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/csharp-use-inheritance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
4 changes: 2 additions & 2 deletions examples/custom-logging/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Should be able to use custom logging interface', () => {

test('and should log expected output to console', async () => {
await generate();
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/custom-logging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ export async function generate(): Promise<void> {
}
}

generate();
if (require.main === module) {
generate();
}
4 changes: 2 additions & 2 deletions examples/dart-generate-json-annotation/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Should be able to render Dart Models', () => {
});
test('and should log expected output to console', async () => {
await generate();
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/dart-generate-json-annotation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}

5 changes: 2 additions & 3 deletions examples/generate-csharp-models/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to render C# models ', () => {
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/generate-csharp-models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
4 changes: 2 additions & 2 deletions examples/generate-dart-models/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Should be able to render Dart Models', () => {
});
test('and should log expected output to console', async () => {
await generate();
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/generate-dart-models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
3 changes: 1 addition & 2 deletions examples/generate-go-enums/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to render Go Enums', () => {
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 3 model (root and three different enums type), we double it
expect(spy.mock.calls.length).toEqual(6);
expect(spy.mock.calls.length).toEqual(3);
expect(spy.mock.calls[0]).toMatchSnapshot();
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls[2]).toMatchSnapshot();
Expand Down
4 changes: 3 additions & 1 deletion examples/generate-go-enums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
4 changes: 2 additions & 2 deletions examples/generate-go-models/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Should be able to render Go Models', () => {
});
test('and should log expected output to console', async () => {
await generate();
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/generate-go-models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
4 changes: 2 additions & 2 deletions examples/generate-java-models/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Should be able to render Java Models', () => {
});
test('and should log expected output to console', async () => {
await generate();
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/generate-java-models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
5 changes: 2 additions & 3 deletions examples/generate-javascript-models/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ describe('Should be able to render Javascript models', () => {
});
test('and should log expected output to console', async () => {
await generate();
//Generate is called 2x, so even though we expect 1 model, we double it
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
4 changes: 3 additions & 1 deletion examples/generate-javascript-models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
4 changes: 3 additions & 1 deletion examples/generate-to-files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ export async function generate() : Promise<void> {
console.log(model.result);
}
}
generate();
if (require.main === module) {
generate();
}
4 changes: 2 additions & 2 deletions examples/generate-typescript-models/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Should be able to render TypeScript Models', () => {
});
test('and should log expected output to console', async () => {
await generate();
expect(spy.mock.calls.length).toEqual(2);
expect(spy.mock.calls[1]).toMatchSnapshot();
expect(spy.mock.calls.length).toEqual(1);
expect(spy.mock.calls[0]).toMatchSnapshot();
});
});
Loading