-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Readme + fragment extending + new tests
- Loading branch information
Showing
6 changed files
with
185 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
require('dotenv').config(); | ||
const test = require('ava'); | ||
const { Table } = require('../src/'); | ||
|
||
test('throws without params', (t) => { | ||
t.throws( | ||
() => { | ||
const orm = new Table(); | ||
}, | ||
{ instanceOf: Error }, | ||
); | ||
}); | ||
|
||
test('still throws without params', (t) => { | ||
t.throws( | ||
() => { | ||
const orm = new Table({ | ||
name: 'ufhreioor', | ||
}); | ||
}, | ||
{ instanceOf: Error }, | ||
); | ||
}); | ||
|
||
test('succesful contructor', (t) => { | ||
let table = new Table({ | ||
name: 'test', | ||
type: 'BASE TABLE', | ||
}); | ||
|
||
t.true(table instanceof Table); | ||
}); | ||
|
||
test('throws adding field', (t) => { | ||
let table = new Table({ | ||
name: 'test', | ||
type: 'BASE TABLE', | ||
}); | ||
|
||
t.throws( | ||
() => { | ||
table.setField(); | ||
}, | ||
{ instanceOf: Error }, | ||
); | ||
}); | ||
|
||
test('succesfuly add field', (t) => { | ||
let table = new Table({ | ||
name: 'test', | ||
type: 'BASE TABLE', | ||
}); | ||
|
||
table.setField({ | ||
name: 'test', | ||
type: 'Integer', | ||
}); | ||
|
||
t.is(table.field('test').type, 'Integer'); | ||
}); | ||
|
||
test('field not found', (t) => { | ||
let table = new Table({ | ||
name: 'test', | ||
type: 'BASE TABLE', | ||
}); | ||
|
||
t.throws( | ||
() => { | ||
table.field('test'); | ||
}, | ||
{ instanceOf: Error }, | ||
); | ||
}); |