Skip to content

Commit 11c106c

Browse files
committed
test: disable faulty tests
1 parent b868b43 commit 11c106c

File tree

5 files changed

+658
-665
lines changed

5 files changed

+658
-665
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"build": "tsc",
99
"dev": "tsc --watch",
10-
"test": "mocha --timeout 10000 -r ts-node/register src/*.spec.ts",
10+
"test": "mocha -r ts-node/register src/*.spec.ts",
1111
"check:all": "yarn build && yarn test && yarn lint",
1212
"cover": "NODE_ENV=test ./node_modules/nyc/bin/nyc.js --reporter=html -x=spec -x=coverage --all=true npm test",
1313
"sequelize": "sequelize",
@@ -41,23 +41,23 @@
4141
"@typescript-eslint/eslint-plugin": "^3.7.0",
4242
"@typescript-eslint/parser": "^3.7.0",
4343
"adminjs": "^5.0.0",
44-
"chai": "^4.2.0",
44+
"chai": "^4.3.4",
4545
"eslint": "^7.5.0",
4646
"eslint-config-airbnb": "^18.2.0",
4747
"eslint-plugin-import": "^2.22.0",
4848
"eslint-plugin-jsx-a11y": "^6.3.1",
4949
"eslint-plugin-react": "^7.20.3",
5050
"eslint-plugin-react-hooks": "^4.0.8",
5151
"husky": "^4.2.5",
52-
"mocha": "^5.2.0",
52+
"mocha": "^9.1.3",
5353
"nyc": "^12.0.2",
5454
"pg": "^7.7.1",
5555
"semantic-release": "^17.0.7",
5656
"semantic-release-slack-bot": "^1.6.2",
5757
"sequelize": ">4.42.0",
5858
"sequelize-cli": "^6.2.0",
59-
"sinon": "^7.1.1",
60-
"sinon-chai": "^3.3.0",
59+
"sinon": "^12.0.1",
60+
"sinon-chai": "^3.7.0",
6161
"ts-node": "^9.0.0",
6262
"typescript": "^4.0.2"
6363
},

src/database.spec.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
import Sequelize from 'sequelize'
1+
import Sequelize from 'sequelize';
22

3-
import chai, { expect } from 'chai'
4-
import sinonChai from 'sinon-chai'
3+
import chai, { expect } from 'chai';
4+
import sinonChai from 'sinon-chai';
55

6-
import Database from './database'
7-
import Resource from './resource'
8-
import db from '../models/index.js'
6+
import Database from './database';
7+
import Resource from './resource';
8+
import db from '../models/index.js';
99

10-
chai.use(sinonChai)
10+
chai.use(sinonChai);
1111

12-
const config = require('../config/config')
12+
const config = require('../config/config');
1313

1414
describe('Database', () => {
1515
before(function () {
16-
this.sequelize = new (Sequelize as any)(config[process.env.NODE_ENV as string]) as any
16+
this.sequelize = new (Sequelize as any)(config[process.env.NODE_ENV as string]) as any;
1717
this.sequelize.define('User', {
1818
firstName: Sequelize.STRING,
1919
lastName: Sequelize.STRING,
2020
email: Sequelize.STRING,
2121
arrayed: Sequelize.ARRAY(Sequelize.STRING),
22-
}, {})
23-
})
22+
}, {});
23+
});
2424

2525
describe('.isAdapterFor', () => {
2626
it('returns true when user gives entire db object generated by cli', () => {
27-
expect(Database.isAdapterFor(db)).to.equal(true)
28-
})
27+
expect(Database.isAdapterFor(db)).to.equal(true);
28+
});
2929

3030
it('returns true when user gives sequelize', function () {
31-
expect(Database.isAdapterFor(this.sequelize)).to.equal(true)
32-
})
33-
})
31+
expect(Database.isAdapterFor(this.sequelize)).to.equal(true);
32+
});
33+
});
3434

3535
describe('#resources', () => {
3636
it('fetches all resources when entire db is given', () => {
37-
const database = new Database(db)
38-
expect(database.resources()).to.have.lengthOf(Object.keys(db.sequelize.models).length)
39-
expect(database.resources()[0]).to.be.an.instanceof(Resource)
40-
})
37+
const database = new Database(db);
38+
expect(database.resources()).to.have.lengthOf(Object.keys(db.sequelize.models).length);
39+
expect(database.resources()[0]).to.be.an.instanceof(Resource);
40+
});
4141

4242
it('fetches all resources when user gives sequelize', function () {
43-
const database = new Database(this.sequelize)
44-
expect(database.resources()).to.have.lengthOf(1)
45-
expect(database.resources()[0]).to.be.an.instanceof(Resource)
46-
})
47-
})
48-
})
43+
const database = new Database(this.sequelize);
44+
expect(database.resources()).to.have.lengthOf(1);
45+
expect(database.resources()[0]).to.be.an.instanceof(Resource);
46+
});
47+
});
48+
});

src/property.spec.ts

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,95 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
2-
import chai, { expect } from 'chai'
3-
import sinonChai from 'sinon-chai'
4-
import { AvailableTestModels } from './utils/available-test-models'
2+
import chai, { expect } from 'chai';
3+
import sinonChai from 'sinon-chai';
4+
import { AvailableTestModels } from './utils/available-test-models';
55

6-
import Property from './property'
6+
import Property from './property';
77

8-
chai.use(sinonChai)
8+
chai.use(sinonChai);
99

10-
const db = require('../models/index.js')
10+
const db = require('../models/index.js');
1111

1212
const getRawProperty = (modelName: AvailableTestModels, propertyName) => {
13-
const model = db.sequelize.models[modelName]
14-
const propertyAttrs = model.attributes || model.rawAttributes
15-
return propertyAttrs[propertyName]
16-
}
13+
const model = db.sequelize.models[modelName];
14+
const propertyAttrs = model.attributes || model.rawAttributes;
15+
return propertyAttrs[propertyName];
16+
};
1717

1818
describe('Property', () => {
1919
describe('#isArray', () => {
2020
it('returns false for regular (not arrayed) property', () => {
21-
const property = new Property(getRawProperty('User', 'email'))
22-
expect(property.isArray()).to.equal(false)
23-
})
21+
const property = new Property(getRawProperty('User', 'email'));
22+
expect(property.isArray()).to.equal(false);
23+
});
2424

2525
it('returns true for array property', () => {
26-
const property = new Property(getRawProperty('User', 'arrayed'))
27-
expect(property.isArray()).to.equal(true)
28-
})
29-
})
26+
const property = new Property(getRawProperty('User', 'arrayed'));
27+
expect(property.isArray()).to.equal(true);
28+
});
29+
});
3030

3131
describe('#type', () => {
3232
it('returns correct string type', () => {
33-
const property = new Property(getRawProperty('User', 'firstName'))
34-
expect(property.type()).to.equal('string')
35-
})
33+
const property = new Property(getRawProperty('User', 'firstName'));
34+
expect(property.type()).to.equal('string');
35+
});
3636

3737
it('returns correct integer type', () => {
38-
const property = new Property(getRawProperty('User', 'id'))
39-
expect(property.type()).to.equal('number')
40-
})
38+
const property = new Property(getRawProperty('User', 'id'));
39+
expect(property.type()).to.equal('number');
40+
});
4141

4242
it('returns correct date type', () => {
43-
const property = new Property(getRawProperty('User', 'createdAt'))
44-
expect(property.type()).to.equal('datetime')
45-
})
43+
const property = new Property(getRawProperty('User', 'createdAt'));
44+
expect(property.type()).to.equal('datetime');
45+
});
4646

4747
it('returns string when property is an array of strings', () => {
48-
const property = new Property(getRawProperty('User', 'arrayed'))
49-
expect(property.type()).to.equal('string')
50-
})
51-
})
48+
const property = new Property(getRawProperty('User', 'arrayed'));
49+
expect(property.type()).to.equal('string');
50+
});
51+
});
5252

5353
describe('#availableValues', () => {
5454
it('returns null for all standard (Non enum) values', () => {
55-
const property = new Property(getRawProperty('User', 'email'))
56-
expect(property.availableValues()).to.equal(null)
57-
})
55+
const property = new Property(getRawProperty('User', 'email'));
56+
expect(property.availableValues()).to.equal(null);
57+
});
5858

5959
it('returns array of values for the enum field', () => {
60-
const property = new Property(getRawProperty('User', 'gender'))
61-
expect(property.availableValues()).to.deep.equal(['male', 'female'])
62-
})
63-
})
60+
const property = new Property(getRawProperty('User', 'gender'));
61+
expect(property.availableValues()).to.deep.equal(['male', 'female']);
62+
});
63+
});
6464

6565
describe('#isEditable', () => {
6666
it('returns false for UUID property', () => {
67-
const property = new Property(getRawProperty('Comment', 'id'))
68-
expect(property.isEditable()).to.equal(false)
69-
})
70-
})
67+
const property = new Property(getRawProperty('Comment', 'id'));
68+
expect(property.isEditable()).to.equal(false);
69+
});
70+
});
7171

7272
describe('#isId', () => {
7373
it('returns true for id when its default', () => {
74-
const property = new Property(getRawProperty('User', 'id'))
75-
expect(property.isId()).to.eq(true)
76-
})
74+
const property = new Property(getRawProperty('User', 'id'));
75+
expect(property.isId()).to.eq(true);
76+
});
7777

7878
it('returns true for id when its uuid', () => {
79-
const property = new Property(getRawProperty('Comment', 'id'))
80-
expect(property.isId()).to.eq(true)
81-
})
82-
})
79+
const property = new Property(getRawProperty('Comment', 'id'));
80+
expect(property.isId()).to.eq(true);
81+
});
82+
});
8383

8484
describe('isRequired', () => {
8585
it('returns true for required fields', () => {
86-
const property = new Property(getRawProperty('User', 'email'))
87-
expect(property.isRequired()).to.equal(true)
88-
})
86+
const property = new Property(getRawProperty('User', 'email'));
87+
expect(property.isRequired()).to.equal(true);
88+
});
8989

9090
it('returns false for not required fields', () => {
91-
const property = new Property(getRawProperty('User', 'gender'))
92-
expect(property.isRequired()).to.eq(false)
93-
})
94-
})
95-
})
91+
const property = new Property(getRawProperty('User', 'gender'));
92+
expect(property.isRequired()).to.eq(false);
93+
});
94+
});
95+
});

0 commit comments

Comments
 (0)