Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
leoz committed May 1, 2024
1 parent 813a21f commit ada1579
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 148 deletions.
14 changes: 7 additions & 7 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ module.exports = {
browser: true,
es6: true,
node: true,
'jest/globals': true
"jest/globals": true,
},
extends: ['standard', 'prettier'],
extends: ["standard", "prettier"],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
Atomics: "readonly",
SharedArrayBuffer: "readonly",
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
sourceType: "module",
},
rules: {
semi: [2, 'always']
semi: [2, "always"],
},
plugins: ['jest']
plugins: ["jest"],
};
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ npm install xmlrpc-parser

```javascript
//
import fetch from 'cross-fetch';
import { XmlRpcMessage, XmlRpcResponse } from 'xmlrpc-parser';
import fetch from "cross-fetch";
import { XmlRpcMessage, XmlRpcResponse } from "xmlrpc-parser";
//
const method = 'examples.getStateName';
const method = "examples.getStateName";
const params = 23;
const message = new XmlRpcMessage(method, [params]);
const input = message.xml();
const URL = 'http://betty.userland.com/RPC2';
const URL = "http://betty.userland.com/RPC2";
//
const res = await fetch(URL, { method: 'post', body: input });
const res = await fetch(URL, { method: "post", body: input });
const xml = await res.text();
//
const response = new XmlRpcResponse();
Expand Down
16 changes: 8 additions & 8 deletions __tests__/fetchXml.spec.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//
import fetch from 'cross-fetch';
import { XmlRpcMessage, XmlRpcResponse } from '../src/index.js';
import fetch from "cross-fetch";
import { XmlRpcMessage, XmlRpcResponse } from "../src/index.js";

describe('Fetch and parse XML funtion', () => {
test('It should fetch and parse XML', async () => {
const method = 'examples.getStateName';
describe("Fetch and parse XML funtion", () => {
test("It should fetch and parse XML", async () => {
const method = "examples.getStateName";
const params = 23;
const message = new XmlRpcMessage(method, [params]);
const input = message.xml();
const URL = 'http://betty.userland.com/RPC2';
const URL = "http://betty.userland.com/RPC2";
//
const res = await fetch(URL, { method: 'post', body: input });
const res = await fetch(URL, { method: "post", body: input });
const xml = await res.text();
//
const response = new XmlRpcResponse();
const result = await response.parse(xml);
//
expect('Minnesota').toBe(result.params[0]);
expect("Minnesota").toBe(result.params[0]);
});
});
46 changes: 23 additions & 23 deletions __tests__/messageToXml.spec.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
//
import { XmlRpcMessage } from '../src/index.js';
import { XmlRpcMessage } from "../src/index.js";

describe('Fetch XML funtion', () => {
test('it should fetch XML', () => {
const method = 'MyCall';
describe("Fetch XML funtion", () => {
test("it should fetch XML", () => {
const method = "MyCall";
const params = {
a: 1,
b: 2
b: 2,
};
const message = new XmlRpcMessage(method, [params]);
const input = message.xml();

const output =
'<?xml version="1.0"?>\n' +
'<methodCall>\n' +
'<methodName>MyCall</methodName>\n' +
'<params>\n' +
'<param>\n' +
'<value><struct>\n' +
'<member>\n' +
'<name>a</name>\n' +
'<value><i4>1</i4></value>\n' +
'</member>\n' +
'<member>\n' +
'<name>b</name>\n' +
'<value><i4>2</i4></value>\n' +
'</member>\n' +
'</struct>\n' +
'</value>\n' +
'</param>\n' +
'</params>\n' +
'</methodCall>';
"<methodCall>\n" +
"<methodName>MyCall</methodName>\n" +
"<params>\n" +
"<param>\n" +
"<value><struct>\n" +
"<member>\n" +
"<name>a</name>\n" +
"<value><i4>1</i4></value>\n" +
"</member>\n" +
"<member>\n" +
"<name>b</name>\n" +
"<value><i4>2</i4></value>\n" +
"</member>\n" +
"</struct>\n" +
"</value>\n" +
"</param>\n" +
"</params>\n" +
"</methodCall>";

expect(input).toEqual(output);
});
Expand Down
12 changes: 6 additions & 6 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
module.exports = {
presets: [
[
'@babel/preset-env',
"@babel/preset-env",
{
targets: {
node: 'current'
}
}
]
]
node: "current",
},
},
],
],
};
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// jest.config.js

export default {
testEnvironment: 'node',
testEnvironment: "node",

transform: {
'^.+\\.jsx?$': 'babel-jest'
"^.+\\.jsx?$": "babel-jest",
},
verbose: true
verbose: true,
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
"eslint-plugin-standard": "^5.0.0",
"jest": "^29.3.1"
}
}
}
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* @license xrpc
* (c) 2016 - 2022 Leonid Zolotarev
* (c) 2016 - 2024 Leonid Zolotarev
* (c) 2012 - 2013 Nathan Cartwright
* License: MIT
*/

export { default as XmlRpcMessage } from './lib/xmlrpc-message.js';
export { default as XmlRpcResponse } from './lib/xmlrpc-response.js';
export { default as XmlRpcMessage } from "./lib/xmlrpc-message.js";
export { default as XmlRpcResponse } from "./lib/xmlrpc-response.js";
Loading

0 comments on commit ada1579

Please sign in to comment.