Skip to content

Commit

Permalink
fixed workflow format issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-raj committed Sep 25, 2024
1 parent f8e413b commit 0f16b06
Show file tree
Hide file tree
Showing 3 changed files with 5,425 additions and 5,529 deletions.
85 changes: 53 additions & 32 deletions test/unit/commands/tsgen.test.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,69 @@
import { test } from '@oclif/test'
import { configHandler } from '@contentstack/cli-utilities'
import * as mock from '../mock/common.mock.json'
import { mock_data } from '../mock/mock2';
import {test} from "@oclif/test";

Check warning on line 1 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Definition for rule 'unicorn/prefer-module' was not found

Check failure on line 1 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote

Check failure on line 1 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Extra semicolon

Check warning on line 1 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Definition for rule 'unicorn/prefer-module' was not found

Check failure on line 1 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Strings must use singlequote

Check failure on line 1 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Extra semicolon
import {configHandler} from "@contentstack/cli-utilities";

Check failure on line 2 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote

Check failure on line 2 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Extra semicolon

Check failure on line 2 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Strings must use singlequote

Check failure on line 2 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Extra semicolon
import * as mock from "../mock/common.mock.json";

Check failure on line 3 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote

Check failure on line 3 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Extra semicolon

Check failure on line 3 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Strings must use singlequote

Check failure on line 3 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Extra semicolon
const GRAPHQL_REGION_URL_MAPPING = {
na: 'https://graphql.contentstack.com',
us: 'https://graphql.contentstack.com',
eu: 'https://eu-graphql.contentstack.com/stacks',
'azure-na': 'https://azure-na-graphql.contentstack.com/stacks',
'azure-eu': 'https://azure-eu-graphql.contentstack.com/stacks',
}
na: "https://graphql.contentstack.com",

Check failure on line 5 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote

Check failure on line 5 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Strings must use singlequote
us: "https://graphql.contentstack.com",

Check failure on line 6 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote

Check failure on line 6 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Strings must use singlequote
eu: "https://eu-graphql.contentstack.com/stacks",

Check failure on line 7 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote

Check failure on line 7 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Strings must use singlequote
"azure-na": "https://azure-na-graphql.contentstack.com/stacks",

Check failure on line 8 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote

Check failure on line 8 in test/unit/commands/tsgen.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Strings must use singlequote
"azure-eu": "https://azure-eu-graphql.contentstack.com/stacks"
};

const region: { cma: string; name: string; cda: string } = configHandler.get('region')
const graphqlUrl: string = region?.name && GRAPHQL_REGION_URL_MAPPING[region.name.toLowerCase() as keyof typeof GRAPHQL_REGION_URL_MAPPING]
const alias = 'token1'
configHandler.set(`tokens.${alias}`, mock.tokens[alias])
const filePath = './generate1.d.ts'
const region: { cma: string; name: string; cda: string } =
configHandler.get("region");
const graphqlUrl: string =
region?.name &&
GRAPHQL_REGION_URL_MAPPING[
region.name.toLowerCase() as keyof typeof GRAPHQL_REGION_URL_MAPPING
];
const alias = "token1";
configHandler.set(`tokens.${alias}`, mock.tokens[alias]);
const filePath = "./generate1.d.ts";


describe('Tsgen command', () => {
describe('Graphql type generator', () => {
describe("Tsgen command", () => {
describe("Graphql type generator", () => {
test
.stdout({ print: process.env.PRINT === 'true' || false })
.nock(graphqlUrl, api =>
.stdout({ print: process.env.PRINT === "true" || false })
.nock(graphqlUrl, (api) =>
api
.post(`/stacks/${mock.tokens[alias].apiKey}?environment=development`)
.reply(200, {
data: mock_data,
data: mock.mock_data
})
)
.command(['tsgen', '--token-alias', alias, '--output', filePath, '--api-type', 'graphql'])
.it('should generate a type def for graphql query')
})
.command([
"tsgen",
"--token-alias",
alias,
"--output",
filePath,
"--api-type",
"graphql"
])
.it("should generate a type def for graphql query");
});

describe('Graphql type generator with namespace', () => {
describe("Graphql type generator with namespace", () => {
test
.stdout({ print: process.env.PRINT === 'true' || false })
.nock(graphqlUrl, api =>
.stdout({ print: process.env.PRINT === "true" || false })
.nock(graphqlUrl, (api) =>
api
.post(`/stacks/${mock.tokens[alias].apiKey}?environment=development`)
.reply(200, {
data: mock_data,
data: mock.mock_data
})
)
.command(['tsgen', '--api-type', 'graphql', '-a', alias, '--output', filePath, '--namespace', 'GraphQL'])
.it('should generate a type def for graphql query with namespace')
})
})
.command([
"tsgen",
"--api-type",
"graphql",
"-a",
alias,
"--output",
filePath,
"--namespace",
"GraphQL"
])
.it("should generate a type def for graphql query with namespace");
});
});
Loading

0 comments on commit 0f16b06

Please sign in to comment.