Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable no-console */
import { serial as test } from 'ava'
import ioClient from 'socket.io-client'
import { ioServerInit, nuxtInit, nuxtClose } from '../utils'
test.before(ioServerInit)
test.before(nuxtInit)
test.after('Closing server and nuxt.js', nuxtClose)
test('Socket io client can connect', (t) => {
t.timeout(60000)
return new Promise((resolve) => {
console.log('attempting to connect')
const socket = ioClient('http://localhost:4000')
socket.on('connect', () => {
console.log('client connected!!', socket.id)
t.truthy(socket.id)
resolve()
})
})
})
/* eslint-disable no-console */
import { serial as test } from 'ava'
import ioClient from 'socket.io-client'
import { ioServerInit, nuxtInit, nuxtClose } from '../utils'
test.before(ioServerInit)
test.before(nuxtInit)
test.after('Closing server and nuxt.js', nuxtClose)
test('Socket io client can connect', (t) => {
t.timeout(60000)
return new Promise((resolve) => {
console.log('attempting to connect')
const socket = ioClient('http://localhost:4000')
socket.on('connect', () => {
console.log('client connected!!', socket.id)
t.truthy(socket.id)
resolve()
})
})
import request from 'supertest';
import express from 'express';
import bodyParser from 'body-parser';
import { serial as test } from 'ava';
import Playlist from '../../../server/models/user_playlist';
import Database from '../../../server/lib/Database';
import routes from '../../../server/app';
process.env.NODE_ENV = 'production'; // test the production api version
let app;
test.before(async () => {
await Database.init();
await Playlist.remove({});
app = express();
app.use(bodyParser.json());
routes(app);
});
test.after.always('clean up the database', async () => {
Playlist.collection.drop();
});
test('should get user playlist collection', async t => {
t.plan(2);
const res = await request(app).get('/api/playlist/zayn');
t.is(res.status, 200);
t.true(Array.isArray(res.body));
import{ serial as test }from'ava';
const {
runBefore,
g
} = require('../helper');
test.before(async () => {
await runBefore();
});
test('[Success] Create API key', async t => {
// Login
await g.request
.post('/admin/login_action')
.send({
email: g.users[0].userEmail,
password: 'test'
});
const res = await g.request
.post('/admin/createApiKey')
.expect(200);
g.users[0].apiKey = res.body.apiKey;
import{ serial as test }from'ava';
const {
runBefore,
g
} = require('../helper');
test.before(async () => {
await runBefore();
});
test('[Success] Get products JSON', async t => {
const res = await g.request
.get('?json=true')
.expect(200);
if(res.body.length < g.config.productsPerPage){
t.is(res.body.length, g.products.length);
}else{
t.is(res.body.length, g.config.productsPerPage);
}
});
test('[Success] Add subscripton product to cart', async t => {
const res = await g.request
import{ serial as test }from'ava';
const {
runBefore,
g
} = require('../helper');
test.before(async () => {
await runBefore();
});
test('[Success] Create a customer', async t => {
const customer = {
email: 'sarah.jones@test.com',
firstName: 'Sarah',
lastName: 'Jones',
address1: '1 Sydney Street',
address2: '',
country: 'Australia',
state: 'NSW',
postcode: '2000',
phone: '0400000000',
password: 'password'
};
const createH1Server = () => {
const server = http.createServer((request, response) => {
response.end('http/1.1');
});
server.listen = util.promisify(server.listen);
server.close = util.promisify(server.close);
return server;
};
let h1s;
let h2s;
test.before('setup', async () => {
h1s = createH1Server();
h2s = await createServer();
h2s.get('/', (request, response) => {
const session = request.httpVersion === '2.0' ? request.stream.session : request;
response.end(session.socket.alpnProtocol);
});
await h1s.listen();
await h2s.listen();
h1s.url = `http://localhost:${h1s.address().port}`;
});
test.after('cleanup', async () => {
await h1s.close();