Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// aws_url
test('should respect aws_url if presented without cloudfront', (t) => {
return testAwsUrl(t, { awsRegion: 'eu-central-1', aws_url: 'https://s3.dualstack.us-east-1.amazonaws.com' })
.then(function (url) {
expect(url).to.match(new RegExp('https://s3.dualstack.us-east-1.amazonaws.com/bucket/'))
})
})
test('should respect aws_url if presented with cloudfront', (t) => {
return testAwsUrl(t, { awsRegion: 'eu-central-1', aws_url: 'https://s3.dualstack.us-east-1.amazonaws.com', cloudfront: true })
.then(function (url) {
expect(url).to.match(new RegExp('https://s3.dualstack.us-east-1.amazonaws.com'))
})
})
test.only('should allow the aws_url to be overriddden on add', (t) => {
return testAwsUrl(t, { awsRegion: 'eu-central-1', aws_url: 'https://s3.dualstack.us-east-1.amazonaws.com', cloudfront: true },
{ configOverrides: { aws_url: 'https://s3.dualstack.us-east-3.amazonaws.com'} })
.then(function (url) {
expect(url).to.match(new RegExp('https://s3.dualstack.us-east-3.amazonaws.com'))
})
})
// S3 Transfer Acceleration
test('should respect s3Acceleration with defaults', (t) => {
return testAwsUrl(t, { s3Acceleration: true })
.then(function (url) {
expect(url).to.match(new RegExp('https://bucket.s3-accelerate.amazonaws.com/'))
})
})
const test = require('ava')
const FP = require('../')
test.only('FP.get(keys) static "partial app" pattern', t => {
const result = FP.get('foo')
t.true(typeof result === 'function', 'result should be a Function')
t.is(result({foo: 'bar'}), 'bar', 'getter Function should return correct string')
})
test('fp.resolve(obj).get(...keyNames)', t => FP
.resolve({foo: 'bar', baz: 'woo'})
.get('foo', 'baz')
.then(obj => t.is(obj.foo, 'bar'))
)
test('fp.resolve(obj).get(key, key2)', t => {
return FP
.resolve({foo: 'bar', baz: 'woo'})
.get('foo', 'baz')
.then(obj => t.is(obj.foo, 'bar'))
function testWithContainer(
name: string,
run: (container: DependencyContainer, decorators: { inject: (token: InjectionToken) => any, injectable: () => any, registry: (...args: any[]) => any }) => GenericTest>,
only: boolean = false) {
const container = requireUncached("../../dist/DependencyContainer").default;
const {injectable, inject, registry} = proxyquire("../../dist/decorators", {
"./DependencyContainer": {default: container}
})
if(!only) {
test(name, run(container, {injectable, inject, registry}));
} else {
test.only(name, run(container, {injectable, inject, registry}));
}
}
Object.keys(fixtures).forEach(key => {
const {syntax, ast, debug} = fixtures[key];
if (debug) {
return test.only(key, macro, syntax, ast, debug);
}
test(key, macro, syntax, ast);
});
only (name) {
Ava.only(name, async t => this[name](t))
}
only (name) {
Ava.only(name, async t => this.test[name](t))
}
let server = new WebSocket.Server({ port })
server.on('connection', ws => {
ws.on('message', () => server.clients.forEach(client => client.send('test')))
})
test.after.always('cleanup', () => {
return new Promise(resolve => {
server.close(() => {
resolve()
})
})
})
test.only('[WS] reconnect when server is restarted', t => {
return new Promise((resolve, reject) => {
try {
let isReconnect = false
const url = () => `ws://localhost:${port}`
const ws = openWebSocket(url)
ws.addEventListener('open', () => {
if (isReconnect) {
ws.close(1000, undefined, { keepClosed: true })
t.pass()
resolve()
} else {
server.close()
server = new WebSocket.Server({ port })
}