Skip to content

Commit

Permalink
add deno docs, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
circa10a committed Apr 25, 2020
1 parent 3d2af83 commit 7741647
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
"sourceType": "module",
"ecmaVersion": 9
},
"ignorePatterns": ["**/*.d.js"],
"rules": {
"quote-props": "warn"
},
"globals": {
"fetch": false
"fetch": false,
"Deno": false
}
}
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ sudo: false

language: node_js

services:
- docker

node_js:
- lts/*

Expand All @@ -11,6 +14,7 @@ install:
script:
- npm run lint
- npm test
- npm run test-deno
- npm run coverage
- npm run bundle

Expand Down
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# 3.3.0(2020-04-25)

## Added

### Deno support

- [#36] https://github.com/circa10a/easy-soap-request/issues/36)

# 3.2.2(2020-04-08)

## Updated

Update dependencies

# 3.2.1 (2020-03-13)

## Fixed
## Fixed

- [#32] (https://github.com/circa10a/easy-soap-request/pull/32)

# 3.2.0 (2019-10-19)

## Fixed
## Fixed

- [#29] (https://github.com/circa10a/easy-soap-request/issues/29)

Expand Down
1 change: 1 addition & 0 deletions index.d.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* Deno module for easy-soap-request
* @author Caleb Lemoine
* @param {object} opts easy-soap-request options
* @param {string} opts.url endpoint URL
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
"bundle": "webpack --config ./webpack.config.js",
"clean": "rm -rf node_modules/",
"coverage": "export NODE_ENV=test; nyc report --reporter=text-lcov | coveralls",
"lint": "eslint '*.js' 'test/*.js'",
"lint-fix": "eslint **/*.js --fix",
"lint": "eslint .",
"lint-fix": "eslint . --fix",
"serve": "npm run bundle && webpack-dev-server --config ./webpack.config.js",
"test": "nyc mocha"
"test": "nyc mocha **/*test.js",
"test-deno": "docker run --rm -it -v $PWD:/tmp -w /tmp hayd/alpine-deno test --allow-read --allow-net test/*.d.js"
},
"repository": {
"type": "git",
Expand Down
57 changes: 57 additions & 0 deletions test/retrieve-lng-lat-test.d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { readFileStr } from 'https://deno.land/std/fs/mod.ts';
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts';
import soapRequest from '../index.d.js';


const url = 'https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php';
const urlFail = 'https://graphical.weather.gov:80/xml/SOAP_server/ndfdXMLserver.php';
const headers = {
'user-agent': 'easy-soap-request-test',
'Content-Type': 'text/xml;charset=UTF-8',
SOAPAction: 'https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#LatLonListZipCode',
};

const coordinates = '32.9612,-96.8372';

Deno.test({
name: `Zip Code 75001 should return ${coordinates}`,
fn: async () => {
const xml = await readFileStr('test/zip-code-envelope.xml');
const { response } = await soapRequest({ url, headers, xml });
const { body, statusCode } = response;
assertEquals(body.includes(coordinates), true);
assertEquals(statusCode, 200);
},
});

Deno.test({
name: 'Should catch Promise Rejection',
fn: async () => {
try {
const xmlFail = await readFileStr('test/zip-code-envelope-fail.xml');
const { response } = await soapRequest({ url, headers, xmlFail });
const { statusCode } = response;
assertEquals(statusCode, 200);
} catch (e) {
// Test promise rejection for coverage
}
},
});

Deno.test({
name: 'Should catch connection error Promise Rejection',
fn: async () => {
try {
const xmlFail = await readFileStr('test/zip-code-envelope-fail.xml');
const { response } = await soapRequest({
url: urlFail,
headers,
xml: xmlFail,
});
const { statusCode } = response;
assertEquals(statusCode, 200);
} catch (e) {
// Test promise rejection for coverage
}
},
});

0 comments on commit 7741647

Please sign in to comment.