Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sc 84853/fix broken tests in dependencies #8

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.eslintrc.js
node_modules
.idea
.DS_Store
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
package-lock=false
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org)

## [1.0.8] - 2025-01-14
### Fixed
- replace duplicated tests copied from custom module with wrapper-specific tests
- update dependencies ([sc-84853](https://app.shortcut.com/active-prospect/story/84853/fix-broken-tests-in-dependencies))

## [1.0.7] - 2021-02-25
### Fixed
- fix npm vulnerabilities
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "LeadConduit GET integration",
"main": "index.js",
"scripts": {
"test": "mocha"
"test": "mocha",
"fixlint": "eslint . --fix",
"lint": "eslint ."
},
"repository": {
"type": "git",
Expand All @@ -19,7 +21,6 @@
"leadconduit-custom": "^2.16.0"
},
"devDependencies": {
"chai": "^4.1.2",
"mocha": "^8.3.0"
"@activeprospect/integration-dev-dependencies": "^2.0.1"
}
}
180 changes: 19 additions & 161 deletions test/query-spec.js
Original file line number Diff line number Diff line change
@@ -1,168 +1,26 @@
// Generated by CoffeeScript 1.10.0
(function() {
var assert, integration, types;
const assert = require('chai').assert;
const integration = require('../lib/get');

assert = require('chai').assert;
describe('Wrap of custom integration', function() {

integration = require('../lib/get');
it('wraps request', () => {
assert.isFunction(integration.request);
assert.isArray(integration.request.variables());

types = require('leadconduit-types');

describe('Outbound GET Query request', function() {
it('should have url, method, and headers', function() {
var vars;
vars = {
url: 'http://foo.bar',
parameter: {
fname: 'Mel',
lname: 'Gibson'
},
header: {
Whatever: 'foo'
}
};
assert.equal(integration.request(vars).url, 'http://foo.bar?fname=Mel&lname=Gibson');
assert.equal(integration.request(vars).method, 'GET');
return assert.deepEqual(integration.request(vars).headers, {
'Accept': 'application/json;q=0.9,text/xml;q=0.8,application/xml;q=0.7,text/html;q=0.6,text/plain;q=0.5',
'Whatever': 'foo'
});
});
it('should send data as ASCII when told to', function() {
var vars;
vars = {
send_ascii: types.boolean.parse('true'),
url: 'http://foo.bar',
parameter: {
fname: 'Mêl',
lname: 'Gibson'
}
};
return assert.equal(integration.request(vars).url, 'http://foo.bar?fname=Mel&lname=Gibson');
});
it('should send data as original UTF-8 when told to', function() {
var vars;
vars = {
send_ascii: types.boolean.parse('false'),
url: 'http://foo.bar',
parameter: {
fname: 'Mêl',
lname: 'Gibson'
}
};
return assert.equal(integration.request(vars).url, 'http://foo.bar?fname=M%C3%AAl&lname=Gibson');
});
it('should support simple dot-notation', function() {
var vars;
vars = {
parameter: {
'foo.bar.baz': 'bip'
}
};
return assert.equal(integration.request(vars).url.split('?')[1], 'foo.bar.baz=bip');
});
it('should support dot-notation arrays', function() {
var vars;
vars = {
parameter: {
'foo.bar.baz.0': 'bip',
'foo.bar.baz.1': 'bap'
}
};
return assert.equal(integration.request(vars).url.split('?')[1], 'foo.bar.baz=bip&foo.bar.baz=bap');
});
it('should compact array', function() {
var vars;
vars = {
parameter: {
'foo.0': 'bip',
'foo.2': 'bap'
}
};
return assert.equal(integration.request(vars).url.split('?')[1], 'foo=bip&foo=bap');
});
it('should support dot-notation array reference', function() {
var vars;
vars = {
parameter: {
'foo.bar.baz': ['bip', 'bap']
}
};
return assert.equal(integration.request(vars).url.split('?')[1], 'foo.bar.baz=bip&foo.bar.baz=bap');
});
it('should normalize rich types', function() {
var vars;
vars = {
parameter: {
postal_code: types.postal_code.parse('78704'),
phone: types.phone.parse('512-789-1111 x123'),
boolean: types.boolean.parse('T'),
gender: types.gender.parse('F'),
number: types.number.parse('$100,000.00'),
range: types.range.parse('1,000-2,000')
}
};
return assert.equal(integration.request(vars).url.split('?')[1], 'postal_code=78704&phone=5127891111x123&boolean=true&gender=female&number=100000&range=1000-2000');
});
it('should normalize rich type array', function() {
var vars;
vars = {
parameter: {
phones: [types.phone.parse('512-789-1111 x123'), types.phone.parse('512-789-2222 x456')]
}
};
return assert.equal(integration.request(vars).url.split('?')[1], 'phones=5127891111x123&phones=5127892222x456');
});
return it('should use raw value for invalid rich types', function() {
var vars;
vars = {
parameter: {
number: types.number.parse('foo')
}
};
return assert.equal(integration.request(vars).url.split('?')[1], 'number=foo');
});
const req = integration.request({ url: 'https://example.com' });
assert.equal(req.url, 'https://example.com?');
assert.exists(req.method);
assert.isObject(req.headers);
});

describe('Outbound GET Query validation', function() {
it('should require valid URL', function() {
return assert.equal(integration.validate({}), 'URL is required');
});
it('should require valid search outcome', function() {
return assert.equal(integration.validate({
url: 'http://foo.com',
outcome_on_match: 'donkey'
}), "Outcome on match must be 'success', 'failure', or 'error'");
});
it('should pass validation', function() {
return assert.isUndefined(integration.validate({
url: 'http://foo.com'
}));
});
it('should not allow content-type header', function() {
return assert.equal(integration.validate({
url: 'http://foo.com',
header: {
'Content-Type': 'foo'
}
}), 'Invalid Content-Type header value');
});
it('should not allow content-length header', function() {
return assert.equal(integration.validate({
url: 'http://foo.com',
header: {
'Content-Length': '10'
}
}), 'Content-Length header is not allowed');
});
return it('should not allow accept header', function() {
return assert.equal(integration.validate({
url: 'http://foo.com',
header: {
'Accept': 'text/whatever'
}
}), 'Accept header is not allowed');
});
it('wraps validate', () => {
assert.isFunction(integration.validate);
assert.isNotEmpty(integration.validate({}));
});

}).call(this);
it('wraps response', () => {
assert.isFunction(integration.response);
assert.isArray(integration.response.variables());
assert.exists(integration.response({}, {}, { headers: [] }).outcome);
});
});
Loading