schema.test.js
2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict';
const chai = require('chai'),
expect = chai.expect,
Support = require(__dirname + '/../support'),
current = Support.sequelize;
describe(Support.getTestDialectTeaser('Model') + 'Schemas', () => {
if (current.dialect.supports.schemas) {
const Project = current.define('project'),
Company = current.define('company', {}, {
schema: 'default',
schemaDelimiter: '&'
});
describe('schema', () => {
it('should work with no default schema', () => {
expect(Project._schema).to.be.null;
});
it('should apply default schema from define', () => {
expect(Company._schema).to.equal('default');
});
it('should be able to override the default schema', () => {
expect(Company.schema('newSchema')._schema).to.equal('newSchema');
});
it('should be able nullify schema', () => {
expect(Company.schema(null)._schema).to.be.null;
});
it('should support multiple, coexistent schema models', () => {
const schema1 = Company.schema('schema1'),
schema2 = Company.schema('schema1');
expect(schema1._schema).to.equal('schema1');
expect(schema2._schema).to.equal('schema1');
});
});
describe('schema delimiter', () => {
it('should work with no default schema delimiter', () => {
expect(Project._schemaDelimiter).to.equal('');
});
it('should apply default schema delimiter from define', () => {
expect(Company._schemaDelimiter).to.equal('&');
});
it('should be able to override the default schema delimiter', () => {
expect(Company.schema(Company._schema, '^')._schemaDelimiter).to.equal('^');
});
it('should support multiple, coexistent schema delimiter models', () => {
const schema1 = Company.schema(Company._schema, '$'),
schema2 = Company.schema(Company._schema, '#');
expect(schema1._schemaDelimiter).to.equal('$');
expect(schema2._schemaDelimiter).to.equal('#');
});
});
}
});