create-sipere 0.9.2 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sipere",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "main": "create-sipere.js",
5
5
  "bin": {
6
6
  "create-sipere": "create-sipere.js"
@@ -1,11 +1,7 @@
1
1
  import Sequelize from 'sequelize'
2
2
  import dotenvFlow from 'dotenv-flow'
3
3
 
4
- if (process.env.NODE_ENV === 'test') {
5
- dotenvFlow.config({ path: '.env.test' })
6
- }else {
7
- dotenvFlow.config()
8
- }
4
+ dotenvFlow.config()
9
5
 
10
6
  const sequelize = new Sequelize(
11
7
  process.env.DB_NAME,
@@ -4,7 +4,7 @@
4
4
  "description": "Express API with simple Sequelize",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "NODE_ENV=test mocha",
7
+ "test": "NODE_ENV=test mocha --file test/mocha.setup.js 'test/**/*.spec.js'",
8
8
  "dev": "nodemon app",
9
9
  "start": "node app"
10
10
  },
@@ -16,7 +16,7 @@
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
18
  "@dotenvx/dotenvx": "^1.51.0",
19
- "@sipere/op-cli": "^0.9.1",
19
+ "@sipere/op-cli": "^0.9.2",
20
20
  "bcryptjs": "^2.4.3",
21
21
  "cors": "^2.8.5",
22
22
  "dotenv-flow": "^4.1.0",
@@ -0,0 +1,8 @@
1
+ import sequelize from '../app/database/database.js'
2
+
3
+ before(async() => {
4
+ await sequelize.sync({ force: true })
5
+ })
6
+ after(async() => {
7
+ await sequelize.close()
8
+ })
@@ -5,8 +5,8 @@ describe('/api/register and /api/login', () => {
5
5
  const restype= 'application/json; charset=utf-8'
6
6
  var token = null
7
7
 
8
- it('post /register ', function(done) {
9
- supertest(app)
8
+ it('post /register ', async () => {
9
+ await supertest(app)
10
10
  .post('/api/register')
11
11
  .set('Accept', 'application/json')
12
12
  .send({
@@ -16,11 +16,11 @@ describe('/api/register and /api/login', () => {
16
16
  password_confirmation: 'titok'
17
17
  })
18
18
  .expect('Content-Type', restype)
19
- .expect(201, done)
19
+ .expect(201)
20
20
 
21
21
  })
22
- it('post /login ', (done) => {
23
- supertest(app)
22
+ it('post /login ', async () => {
23
+ const res = await supertest(app)
24
24
  .post('/api/login')
25
25
  .set('Accept', 'application/json')
26
26
  .send({
@@ -28,16 +28,17 @@ describe('/api/register and /api/login', () => {
28
28
  password: 'titok'
29
29
  })
30
30
  .expect('Content-Type', restype)
31
- .expect(200, done)
32
- .expect(res => {
33
- token = res.body.accessToken
34
- })
31
+ .expect(200)
32
+ token = res.body.accessToken
33
+ if(!token) {
34
+ throw new Error('No token')
35
+ }
35
36
  })
36
- it('get /users ', function(done) {
37
- supertest(app)
37
+ it('get /users ', async () => {
38
+ await supertest(app)
38
39
  .get('/api/users')
39
40
  .set('Accept', 'application/json')
40
41
  .set('Authorization', 'Bearer ' + token)
41
- .expect(200, done)
42
+ .expect(200)
42
43
  })
43
44
  })