-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigration-sql-parse.tests.js
More file actions
50 lines (42 loc) · 1.16 KB
/
Copy pathmigration-sql-parse.tests.js
File metadata and controls
50 lines (42 loc) · 1.16 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
'use strict';
// Vendor
const expect = require('chai').expect;
// Local
const parse = require('./migration-sql-parse');
describe('Migration SQL Parser', function() {
describe('parse', function() {
it('no arguments throws error', function() {
expect(function() {
parse();
}).throw(Error);
});
it("' ' is valid",
function() {
expect(parse(' ')).deep.equal({
up: ' ',
down: null,
});
});
it('no optional delimiter returns all as up SQL',
function() {
let sql = '-- Comment\n' +
'create table names (id serial, name text)\n';
expect(parse(sql)).deep.equal({
up: sql,
down: null,
});
});
it('returns both up and down SQL with the default delimiter',
function() {
let upSql = '-- Comment\n' +
'create table names (id serial, name text)\n';
let downSql = '-- Some down sql\n' +
'drop table names';
let sql = upSql + parse.kDefaultDelimiter + downSql;
expect(parse(sql)).deep.equal({
up: upSql,
down: parse.kDefaultDelimiter + downSql,
});
});
});
});