@@ -4,15 +4,20 @@ import { generateSnippetsJSON } from '../snippets.ts';
44import type { CodeSamples } from '../types.ts' ;
55
66describe ( 'init' , ( ) => {
7- it ( 'parses a multi line import ' , ( ) => {
7+ it ( 'parses a multi line init ' , ( ) => {
88 expect (
99 JSON . stringify (
1010 generateSnippetsJSON ( {
11- foo : {
12- default : `
11+ csharp : {
12+ ope : {
13+ default : `
1314 // Initialize the client
1415var client = new QuerySuggestionsClient(
15- new QuerySuggestionsConfig("YOUR_APP_ID", "YOUR_API_KEY", "YOUR_APP_ID_REGION")
16+ new QuerySuggestionsConfig(
17+ "ALGOLIA_APPLICATION_ID",
18+ "ALGOLIA_API_KEY",
19+ "ALGOLIA_APPLICATION_REGION"
20+ )
1621);
1722
1823// Call the API
@@ -38,63 +43,60 @@ var response = await client.CreateConfigAsync(
3843 }
3944);
4045// >LOG
46+ // print the response
47+ Console.WriteLine(response);
4148 ` ,
49+ } ,
4250 } ,
4351 } as unknown as CodeSamples ) ,
4452 null ,
4553 2 ,
4654 ) ,
4755 ) . toMatchInlineSnapshot ( `
4856 "{
49- "foo": {
50- "default": "\\n // Initialize the client\\nvar client = new QuerySuggestionsClient(\\n new QuerySuggestionsConfig(\\"YOUR_APP_ID\\", \\"YOUR_API_KEY\\", \\"YOUR_APP_ID_REGION\\")\\n);\\n\\n// Call the API\\nvar response = await client.CreateConfigAsync(\\n new ConfigurationWithIndex\\n {\\n IndexName = \\"<YOUR_INDEX_NAME>\\",\\n SourceIndices = new List<SourceIndex>\\n {\\n new SourceIndex\\n {\\n IndexName = \\"<YOUR_INDEX_NAME>\\",\\n Facets = new List<Facet> { new Facet { Attribute = \\"test\\" } },\\n Generate = new List<List<string>>\\n {\\n new List<string> { \\"facetA\\", \\"facetB\\" },\\n new List<string> { \\"facetC\\" },\\n },\\n },\\n },\\n Languages = new Languages(new List<string> { \\"french\\" }),\\n Exclude = new List<string> { \\"test\\" },\\n }\\n);\\n// >LOG\\n "
57+ "csharp": {
58+ "ope": {
59+ "default": "var response = await client.CreateConfigAsync(\\n new ConfigurationWithIndex\\n {\\n IndexName = \\"<YOUR_INDEX_NAME>\\",\\n SourceIndices = new List<SourceIndex>\\n {\\n new SourceIndex\\n {\\n IndexName = \\"<YOUR_INDEX_NAME>\\",\\n Facets = new List<Facet> { new Facet { Attribute = \\"test\\" } },\\n Generate = new List<List<string>>\\n {\\n new List<string> { \\"facetA\\", \\"facetB\\" },\\n new List<string> { \\"facetC\\" },\\n },\\n },\\n },\\n Languages = new Languages(new List<string> { \\"french\\" }),\\n Exclude = new List<string> { \\"test\\" },\\n }\\n);"
60+ },
61+ "init": {
62+ "default": "var client = new QuerySuggestionsClient(\\n new QuerySuggestionsConfig(\\n \\"ALGOLIA_APPLICATION_ID\\",\\n \\"ALGOLIA_API_KEY\\",\\n \\"ALGOLIA_APPLICATION_REGION\\"\\n )\\n);"
63+ }
5164 }
5265 }"
5366 ` ) ;
5467 } ) ;
5568
56- it ( 'parses a single line import ' , ( ) => {
69+ it ( 'parses a single line init ' , ( ) => {
5770 expect (
5871 JSON . stringify (
5972 generateSnippetsJSON ( {
60- foo : {
61- default : `
73+ csharp : {
74+ ope : {
75+ default : `
6276 // Initialize the client
63- var client = new QuerySuggestionsClient(new Client("YOUR_APP_ID ", "YOUR_API_KEY ", "YOUR_APP_ID_REGION "));
77+ var client = new QuerySuggestionsClient(new QuerySuggestionsConfig("ALGOLIA_APPLICATION_ID ", "ALGOLIA_API_KEY ", "ALGOLIA_APPLICATION_REGION "));
6478
6579// Call the API
66- var response = await client.CreateConfigAsync(
67- new ConfigurationWithIndex
68- {
69- IndexName = "<YOUR_INDEX_NAME>",
70- SourceIndices = new List<SourceIndex>
71- {
72- new SourceIndex
73- {
74- IndexName = "<YOUR_INDEX_NAME>",
75- Facets = new List<Facet> { new Facet { Attribute = "test" } },
76- Generate = new List<List<string>>
77- {
78- new List<string> { "facetA", "facetB" },
79- new List<string> { "facetC" },
80- },
81- },
82- },
83- Languages = new Languages(new List<string> { "french" }),
84- Exclude = new List<string> { "test" },
85- }
86- );
80+ var response = await client.CreateConfigAsync();
8781// >LOG
82+ // print the response
83+ Console.WriteLine(response);
8884 ` ,
85+ } ,
8986 } ,
9087 } as unknown as CodeSamples ) ,
9188 null ,
9289 2 ,
9390 ) ,
9491 ) . toMatchInlineSnapshot ( `
9592 "{
96- "foo": {
97- "default": "\\n // Initialize the client\\nvar client = new QuerySuggestionsClient(new Client(\\"YOUR_APP_ID\\", \\"YOUR_API_KEY\\", \\"YOUR_APP_ID_REGION\\"));\\n\\n// Call the API\\nvar response = await client.CreateConfigAsync(\\n new ConfigurationWithIndex\\n {\\n IndexName = \\"<YOUR_INDEX_NAME>\\",\\n SourceIndices = new List<SourceIndex>\\n {\\n new SourceIndex\\n {\\n IndexName = \\"<YOUR_INDEX_NAME>\\",\\n Facets = new List<Facet> { new Facet { Attribute = \\"test\\" } },\\n Generate = new List<List<string>>\\n {\\n new List<string> { \\"facetA\\", \\"facetB\\" },\\n new List<string> { \\"facetC\\" },\\n },\\n },\\n },\\n Languages = new Languages(new List<string> { \\"french\\" }),\\n Exclude = new List<string> { \\"test\\" },\\n }\\n);\\n// >LOG\\n "
93+ "csharp": {
94+ "ope": {
95+ "default": "var response = await client.CreateConfigAsync();"
96+ },
97+ "init": {
98+ "default": "var client = new QuerySuggestionsClient(new QuerySuggestionsConfig(\\"ALGOLIA_APPLICATION_ID\\", \\"ALGOLIA_API_KEY\\", \\"ALGOLIA_APPLICATION_REGION\\"));"
99+ }
98100 }
99101 }"
100102 ` ) ;
@@ -106,46 +108,35 @@ describe('initialize', () => {
106108 expect (
107109 JSON . stringify (
108110 generateSnippetsJSON ( {
109- foo : {
110- default : `
111+ csharp : {
112+ ope : {
113+ default : `
111114 // Initialize the client foo bar BAAAAAAAAAAAAAAAAAAAAAZ
112115var client = new QuerySuggestionsClient(
113116 new QuerySuggestionsConfig("YOUR_APP_ID", "YOUR_API_KEY", "YOUR_APP_ID_REGION")
114117);
115118
116119// Call the API
117- var response = await client.CreateConfigAsync(
118- new ConfigurationWithIndex
119- {
120- IndexName = "<YOUR_INDEX_NAME>",
121- SourceIndices = new List<SourceIndex>
122- {
123- new SourceIndex
124- {
125- IndexName = "<YOUR_INDEX_NAME>",
126- Facets = new List<Facet> { new Facet { Attribute = "test" } },
127- Generate = new List<List<string>>
128- {
129- new List<string> { "facetA", "facetB" },
130- new List<string> { "facetC" },
131- },
132- },
133- },
134- Languages = new Languages(new List<string> { "french" }),
135- Exclude = new List<string> { "test" },
136- }
137- );
120+ var response = await client.CreateConfigAsync();
138121// >LOG
122+ // print the response
123+ Console.WriteLine(response);
139124 ` ,
125+ } ,
140126 } ,
141127 } as unknown as CodeSamples ) ,
142128 null ,
143129 2 ,
144130 ) ,
145131 ) . toMatchInlineSnapshot ( `
146132 "{
147- "foo": {
148- "default": "\\n // Initialize the client foo bar BAAAAAAAAAAAAAAAAAAAAAZ\\nvar client = new QuerySuggestionsClient(\\n new QuerySuggestionsConfig(\\"YOUR_APP_ID\\", \\"YOUR_API_KEY\\", \\"YOUR_APP_ID_REGION\\")\\n);\\n\\n// Call the API\\nvar response = await client.CreateConfigAsync(\\n new ConfigurationWithIndex\\n {\\n IndexName = \\"<YOUR_INDEX_NAME>\\",\\n SourceIndices = new List<SourceIndex>\\n {\\n new SourceIndex\\n {\\n IndexName = \\"<YOUR_INDEX_NAME>\\",\\n Facets = new List<Facet> { new Facet { Attribute = \\"test\\" } },\\n Generate = new List<List<string>>\\n {\\n new List<string> { \\"facetA\\", \\"facetB\\" },\\n new List<string> { \\"facetC\\" },\\n },\\n },\\n },\\n Languages = new Languages(new List<string> { \\"french\\" }),\\n Exclude = new List<string> { \\"test\\" },\\n }\\n);\\n// >LOG\\n "
133+ "csharp": {
134+ "ope": {
135+ "default": "var response = await client.CreateConfigAsync();"
136+ },
137+ "init": {
138+ "default": "var client = new QuerySuggestionsClient(\\n new QuerySuggestionsConfig(\\"YOUR_APP_ID\\", \\"YOUR_API_KEY\\", \\"YOUR_APP_ID_REGION\\")\\n);"
139+ }
149140 }
150141 }"
151142 ` ) ;
0 commit comments