Add test libs, update dependencies
parent
089668ed10
commit
767d39586c
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
|||||||
|
import { configure } from 'enzyme';
|
||||||
|
import Adapter from 'enzyme-adapter-react-16';
|
||||||
|
|
||||||
|
import 'jest-enzyme';
|
||||||
|
|
||||||
|
configure({ adapter: new Adapter() });
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { isLocalId } from './local-id';
|
||||||
|
|
||||||
|
describe('isLocalId', () => {
|
||||||
|
test('is valid', () => {
|
||||||
|
expect(isLocalId('local:1234567890')).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('is invalid', () => {
|
||||||
|
expect(isLocalId('1234567890')).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* Test environment settings
|
||||||
|
* (sails.config.*)
|
||||||
|
*
|
||||||
|
* What you see below is a quick outline of the built-in settings you need
|
||||||
|
* to configure your Sails app for test. The configuration in this file
|
||||||
|
* is only used in your test environment, i.e. when you lift your app using:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* NODE_ENV=test node app
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* > If you're using git as a version control solution for your Sails app,
|
||||||
|
* > this file WILL BE COMMITTED to your repository by default, unless you add
|
||||||
|
* > it to your .gitignore file. If your repository will be publicly viewable,
|
||||||
|
* > don't add private/sensitive data (like API secrets / db passwords) to this file!
|
||||||
|
*
|
||||||
|
* For more best practices and tips, see:
|
||||||
|
* https://sailsjs.com/docs/concepts/deployment
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Tell Sails what database(s) it should use in test.
|
||||||
|
*
|
||||||
|
* (https://sailsjs.com/config/datastores)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
datastores: {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Configure your default test database.
|
||||||
|
*
|
||||||
|
* 1. Choose an adapter:
|
||||||
|
* https://sailsjs.com/plugins/databases
|
||||||
|
*
|
||||||
|
* 2. Install it as a dependency of your Sails app.
|
||||||
|
* (For example: npm install sails-mysql --save)
|
||||||
|
*
|
||||||
|
* 3. Then set it here (`adapter`), along with a connection URL (`url`)
|
||||||
|
* and any other, adapter-specific customizations.
|
||||||
|
* (See https://sailsjs.com/config/datastores for help.)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
default: {
|
||||||
|
adapter: 'sails-disk',
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* More adapter-specific options
|
||||||
|
*
|
||||||
|
* > For example, for some hosted PostgreSQL providers (like Heroku), the
|
||||||
|
* > extra `ssl: true` option is mandatory and must be provided.
|
||||||
|
*
|
||||||
|
* More info:
|
||||||
|
* https://sailsjs.com/config/datastores
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
inMemoryOnly: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
log: {
|
||||||
|
level: 'warn',
|
||||||
|
},
|
||||||
|
};
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,19 @@
|
|||||||
|
const { expect } = require('chai');
|
||||||
|
|
||||||
|
describe('User (model)', () => {
|
||||||
|
before(async () => {
|
||||||
|
await User.create({
|
||||||
|
email: 'test@test.test',
|
||||||
|
password: 'test',
|
||||||
|
name: 'test',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#find()', () => {
|
||||||
|
it('should return 1 user', async () => {
|
||||||
|
const users = await User.find();
|
||||||
|
|
||||||
|
expect(users).to.have.lengthOf(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
const dotenv = require('dotenv');
|
||||||
|
const sails = require('sails');
|
||||||
|
const rc = require('sails/accessible/rc');
|
||||||
|
|
||||||
|
process.env.NODE_ENV = 'test';
|
||||||
|
|
||||||
|
before(function beforeCallback(done) {
|
||||||
|
this.timeout(5000);
|
||||||
|
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
|
sails.lift(rc('sails'), (error) => {
|
||||||
|
if (error) {
|
||||||
|
return done(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function afterCallback(done) {
|
||||||
|
sails.lower(done);
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue