mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
test(axios): update tests with respect to new changes
This commit is contained in:
@ -8,22 +8,19 @@ void main() {
|
||||
|
||||
group('GET Request', () {
|
||||
test('GET 1', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev',
|
||||
method: 'get'
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet1, "https"),
|
||||
@ -31,7 +28,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 2', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev/country/data',
|
||||
method: 'get',
|
||||
params: {
|
||||
@ -40,16 +37,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet2, "https"),
|
||||
@ -57,7 +51,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 3', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev/country/data',
|
||||
method: 'get',
|
||||
params: {
|
||||
@ -66,16 +60,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet3, "https"),
|
||||
@ -83,7 +74,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 4', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev/humanize/social',
|
||||
method: 'get',
|
||||
params: {
|
||||
@ -96,16 +87,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet4, "https"),
|
||||
@ -113,7 +101,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 5', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.github.com/repos/foss42/apidash',
|
||||
method: 'get',
|
||||
headers: {
|
||||
@ -122,16 +110,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet5, "https"),
|
||||
@ -139,7 +124,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 6', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.github.com/repos/foss42/apidash',
|
||||
method: 'get',
|
||||
params: {
|
||||
@ -151,16 +136,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet6, "https"),
|
||||
@ -168,22 +150,19 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 7', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev',
|
||||
method: 'get'
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet7, "https"),
|
||||
@ -191,7 +170,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 8', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.github.com/repos/foss42/apidash',
|
||||
method: 'get',
|
||||
params: {
|
||||
@ -203,16 +182,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet8, "https"),
|
||||
@ -220,7 +196,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 9', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev/humanize/social',
|
||||
method: 'get',
|
||||
params: {
|
||||
@ -230,16 +206,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet9, "https"),
|
||||
@ -247,7 +220,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 10', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev/humanize/social',
|
||||
method: 'get',
|
||||
headers: {
|
||||
@ -256,16 +229,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(
|
||||
@ -277,7 +247,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 11', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev/humanize/social',
|
||||
method: 'get',
|
||||
params: {
|
||||
@ -290,16 +260,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet11, "https"),
|
||||
@ -307,22 +274,19 @@ axios(config)
|
||||
});
|
||||
|
||||
test('GET 12', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev/humanize/social',
|
||||
method: 'get'
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelGet12, "https"),
|
||||
@ -332,22 +296,19 @@ axios(config)
|
||||
|
||||
group('HEAD Request', () {
|
||||
test('HEAD 1', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev',
|
||||
method: 'head'
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelHead1, "https"),
|
||||
@ -355,22 +316,19 @@ axios(config)
|
||||
});
|
||||
|
||||
test('HEAD 2', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'http://api.apidash.dev',
|
||||
method: 'head'
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelHead2, "http"),
|
||||
@ -380,7 +338,7 @@ axios(config)
|
||||
|
||||
group('POST Request', () {
|
||||
test('POST 1', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev/case/lower',
|
||||
method: 'post',
|
||||
headers: {
|
||||
@ -390,16 +348,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPost1, "https"),
|
||||
@ -407,7 +362,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('POST 2', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev/case/lower',
|
||||
method: 'post',
|
||||
headers: {
|
||||
@ -417,16 +372,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPost2, "https"),
|
||||
@ -434,7 +386,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('POST 3', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://api.apidash.dev/case/lower',
|
||||
method: 'post',
|
||||
headers: {
|
||||
@ -445,26 +397,236 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPost3, "https"),
|
||||
expectedCode);
|
||||
});
|
||||
test('POST 4', () {
|
||||
const expectedCode =
|
||||
r"""// refer https://github.com/foss42/apidash/issues/293#issuecomment-1997568083 for details regarding integration
|
||||
|
||||
const config = {
|
||||
url: 'https://api.apidash.dev/io/form',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
},
|
||||
data: {
|
||||
"text": "API",
|
||||
"sep": "|",
|
||||
"times": "3"
|
||||
}
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(
|
||||
CodegenLanguage.jsAxios,
|
||||
requestModelPost4,
|
||||
"https",
|
||||
),
|
||||
expectedCode);
|
||||
});
|
||||
|
||||
test('POST 5', () {
|
||||
const expectedCode =
|
||||
r"""// refer https://github.com/foss42/apidash/issues/293#issuecomment-1997568083 for details regarding integration
|
||||
|
||||
const config = {
|
||||
url: 'https://api.apidash.dev/io/form',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
"User-Agent": "Test Agent"
|
||||
},
|
||||
data: {
|
||||
"text": "API",
|
||||
"sep": "|",
|
||||
"times": "3"
|
||||
}
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(
|
||||
CodegenLanguage.jsAxios,
|
||||
requestModelPost5,
|
||||
"https",
|
||||
),
|
||||
expectedCode);
|
||||
});
|
||||
test('POST 6', () {
|
||||
const expectedCode =
|
||||
r"""// refer https://github.com/foss42/apidash/issues/293#issuecomment-1997568083 for details regarding integration
|
||||
|
||||
const config = {
|
||||
url: 'https://api.apidash.dev/io/img',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
},
|
||||
data: {
|
||||
"token": "xyz",
|
||||
"imfile": fileInput1.files[0]
|
||||
}
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(
|
||||
CodegenLanguage.jsAxios,
|
||||
requestModelPost6,
|
||||
"https",
|
||||
),
|
||||
expectedCode);
|
||||
});
|
||||
test('POST 7', () {
|
||||
const expectedCode =
|
||||
r"""// refer https://github.com/foss42/apidash/issues/293#issuecomment-1997568083 for details regarding integration
|
||||
|
||||
const config = {
|
||||
url: 'https://api.apidash.dev/io/img',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
},
|
||||
data: {
|
||||
"token": "xyz",
|
||||
"imfile": fileInput1.files[0]
|
||||
}
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(
|
||||
CodegenLanguage.jsAxios,
|
||||
requestModelPost7,
|
||||
"https",
|
||||
),
|
||||
expectedCode);
|
||||
});
|
||||
test('POST 8', () {
|
||||
const expectedCode =
|
||||
r"""// refer https://github.com/foss42/apidash/issues/293#issuecomment-1997568083 for details regarding integration
|
||||
|
||||
const config = {
|
||||
url: 'https://api.apidash.dev/io/form',
|
||||
method: 'post',
|
||||
params: {
|
||||
"size": "2",
|
||||
"len": "3"
|
||||
},
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
},
|
||||
data: {
|
||||
"text": "API",
|
||||
"sep": "|",
|
||||
"times": "3"
|
||||
}
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(
|
||||
CodegenLanguage.jsAxios,
|
||||
requestModelPost8,
|
||||
"https",
|
||||
),
|
||||
expectedCode);
|
||||
});
|
||||
test('POST 9', () {
|
||||
const expectedCode =
|
||||
r"""// refer https://github.com/foss42/apidash/issues/293#issuecomment-1997568083 for details regarding integration
|
||||
|
||||
const config = {
|
||||
url: 'https://api.apidash.dev/io/img',
|
||||
method: 'post',
|
||||
params: {
|
||||
"size": "2",
|
||||
"len": "3"
|
||||
},
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
"User-Agent": "Test Agent",
|
||||
"Keep-Alive": "true"
|
||||
},
|
||||
data: {
|
||||
"token": "xyz",
|
||||
"imfile": fileInput1.files[0]
|
||||
}
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(
|
||||
CodegenLanguage.jsAxios,
|
||||
requestModelPost9,
|
||||
"https",
|
||||
),
|
||||
expectedCode);
|
||||
});
|
||||
});
|
||||
|
||||
group('PUT Request', () {
|
||||
test('PUT 1', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://reqres.in/api/users/2',
|
||||
method: 'put',
|
||||
headers: {
|
||||
@ -474,16 +636,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPut1, "https"),
|
||||
@ -493,7 +652,7 @@ axios(config)
|
||||
|
||||
group('PATCH Request', () {
|
||||
test('PATCH 1', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://reqres.in/api/users/2',
|
||||
method: 'patch',
|
||||
headers: {
|
||||
@ -503,16 +662,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(CodegenLanguage.jsAxios, requestModelPatch1, "https"),
|
||||
@ -522,22 +678,19 @@ axios(config)
|
||||
|
||||
group('DELETE Request', () {
|
||||
test('DELETE 1', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://reqres.in/api/users/2',
|
||||
method: 'delete'
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(
|
||||
@ -546,7 +699,7 @@ axios(config)
|
||||
});
|
||||
|
||||
test('DELETE 2', () {
|
||||
const expectedCode = r"""let config = {
|
||||
const expectedCode = r"""const config = {
|
||||
url: 'https://reqres.in/api/users/2',
|
||||
method: 'delete',
|
||||
headers: {
|
||||
@ -556,16 +709,13 @@ axios(config)
|
||||
};
|
||||
|
||||
axios(config)
|
||||
.then(function (response) {
|
||||
// handle success
|
||||
console.log(response.status);
|
||||
console.log(response.data);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error.response.status);
|
||||
console.log(error);
|
||||
});
|
||||
.then(res => {
|
||||
console.log(res.status);
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
""";
|
||||
expect(
|
||||
codeGen.getCode(
|
||||
|
Reference in New Issue
Block a user