rev: reverted changes in js code gen

This commit is contained in:
Vidya Sagar
2024-01-07 20:21:37 +05:30
parent 9d8379e9ac
commit fe3bea31bd
5 changed files with 48 additions and 13 deletions

View File

@ -11,6 +11,7 @@ class AxiosCodeGen {
final bool isNodeJs;
String kStringImportNode = """{% if isNodeJs %}import axios from 'axios';
{% endif %}{% if isFormDataRequest and isNodeJs %}const fs = require('fs');{% endif %}
""";

View File

@ -27,7 +27,8 @@ let options = {
""";
String kTemplateBody = """,
body: {{body}}
body:
{{body}}
""";
String kMultiPartBodyTemplate = r'''

View File

@ -398,7 +398,8 @@ let options = {
headers: {
"Content-Type": "text/plain"
},
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
body:
"{\n\"text\": \"I LOVE Flutter\"\n}"
};
let status;
@ -427,7 +428,8 @@ let options = {
headers: {
"Content-Type": "application/json"
},
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
body:
"{\n\"text\": \"I LOVE Flutter\"\n}"
};
let status;
@ -457,7 +459,8 @@ let options = {
"Content-Type": "application/json",
"User-Agent": "Test Agent"
},
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
body:
"{\n\"text\": \"I LOVE Flutter\"\n}"
};
let status;
@ -488,7 +491,8 @@ let options = {
headers: {
"Content-Type": "application/json"
},
body: "{\n\"name\": \"morpheus\",\n\"job\": \"zion resident\"\n}"
body:
"{\n\"name\": \"morpheus\",\n\"job\": \"zion resident\"\n}"
};
let status;
@ -519,7 +523,8 @@ let options = {
headers: {
"Content-Type": "application/json"
},
body: "{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
body:
"{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
};
let status;
@ -575,7 +580,8 @@ let options = {
headers: {
"Content-Type": "application/json"
},
body: "{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
body:
"{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
};
let status;

View File

@ -8,6 +8,7 @@ void main() {
group('GET Request', () {
test('GET 1', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com',
method: 'get'
@ -30,6 +31,7 @@ axios(config)
test('GET 2', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com/country/data',
method: 'get',
@ -55,6 +57,7 @@ axios(config)
test('GET 3', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com/country/data',
method: 'get',
@ -80,6 +83,7 @@ axios(config)
test('GET 4', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com/humanize/social',
method: 'get',
@ -109,6 +113,7 @@ axios(config)
test('GET 5', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.github.com/repos/foss42/apidash',
method: 'get',
@ -134,6 +139,7 @@ axios(config)
test('GET 6', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.github.com/repos/foss42/apidash',
method: 'get',
@ -162,6 +168,7 @@ axios(config)
test('GET 7', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com',
method: 'get'
@ -184,6 +191,7 @@ axios(config)
test('GET 8', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.github.com/repos/foss42/apidash',
method: 'get',
@ -212,6 +220,7 @@ axios(config)
test('GET 9', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com/humanize/social',
method: 'get',
@ -238,6 +247,7 @@ axios(config)
test('GET 10', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com/humanize/social',
method: 'get',
@ -268,6 +278,7 @@ axios(config)
test('GET 11', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com/humanize/social',
method: 'get',
@ -297,6 +308,7 @@ axios(config)
test('GET 12', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com/humanize/social',
method: 'get'
@ -321,6 +333,7 @@ axios(config)
group('HEAD Request', () {
test('HEAD 1', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com',
method: 'head'
@ -343,6 +356,7 @@ axios(config)
test('HEAD 2', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'http://api.foss42.com',
method: 'head'
@ -367,6 +381,7 @@ axios(config)
group('POST Request', () {
test('POST 1', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com/case/lower',
method: 'post',
@ -393,6 +408,7 @@ axios(config)
test('POST 2', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com/case/lower',
method: 'post',
@ -419,6 +435,7 @@ axios(config)
test('POST 3', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://api.foss42.com/case/lower',
method: 'post',
@ -448,6 +465,7 @@ axios(config)
group('PUT Request', () {
test('PUT 1', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://reqres.in/api/users/2',
method: 'put',
@ -476,6 +494,7 @@ axios(config)
group('PATCH Request', () {
test('PATCH 1', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://reqres.in/api/users/2',
method: 'patch',
@ -504,6 +523,7 @@ axios(config)
group('DELETE Request', () {
test('DELETE 1', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://reqres.in/api/users/2',
method: 'delete'
@ -526,6 +546,7 @@ axios(config)
test('DELETE 2', () {
const expectedCode = r"""import axios from 'axios';
let config = {
url: 'https://reqres.in/api/users/2',
method: 'delete',

View File

@ -418,7 +418,8 @@ let options = {
headers: {
"Content-Type": "text/plain"
},
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
body:
"{\n\"text\": \"I LOVE Flutter\"\n}"
};
let status;
@ -449,7 +450,8 @@ let options = {
headers: {
"Content-Type": "application/json"
},
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
body:
"{\n\"text\": \"I LOVE Flutter\"\n}"
};
let status;
@ -481,7 +483,8 @@ let options = {
"Content-Type": "application/json",
"User-Agent": "Test Agent"
},
body: "{\n\"text\": \"I LOVE Flutter\"\n}"
body:
"{\n\"text\": \"I LOVE Flutter\"\n}"
};
let status;
@ -514,7 +517,8 @@ let options = {
headers: {
"Content-Type": "application/json"
},
body: "{\n\"name\": \"morpheus\",\n\"job\": \"zion resident\"\n}"
body:
"{\n\"name\": \"morpheus\",\n\"job\": \"zion resident\"\n}"
};
let status;
@ -547,7 +551,8 @@ let options = {
headers: {
"Content-Type": "application/json"
},
body: "{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
body:
"{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
};
let status;
@ -607,7 +612,8 @@ let options = {
headers: {
"Content-Type": "application/json"
},
body: "{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
body:
"{\n\"name\": \"marfeus\",\n\"job\": \"accountant\"\n}"
};
let status;