22'use strict'
33
44// prepare environment for js-data-adapter-tests
5- require ( 'babel-polyfill' )
5+ import 'babel-polyfill'
66
7- var JSData = require ( 'js-data' )
8- var JSDataAdapterTests = require ( 'js-data-adapter-tests' )
9- var JSDataRethinkDB = require ( './' )
7+ import * as JSData from 'js-data'
8+ import JSDataAdapterTests from 'js-data-adapter-tests'
9+ import * as JSDataRethinkDB from './src/index'
1010
11- var assert = global . assert = JSDataAdapterTests . assert
11+ const assert = global . assert = JSDataAdapterTests . assert
1212global . sinon = JSDataAdapterTests . sinon
1313
1414JSDataAdapterTests . init ( {
@@ -28,16 +28,46 @@ JSDataAdapterTests.init({
2828 ]
2929} )
3030
31- require ( './test/handleErrors.test' )
31+ describe ( 'RethinkDBAdapter#handleErrors(err)' , function ( ) {
32+ it ( 'should do nothing when passed a falsy value' , function ( ) {
33+ var Test = this
34+ assert . doesNotThrow ( function ( ) {
35+ Test . $$adapter . _handleErrors ( false )
36+ } )
37+ } )
38+ it ( 'should do nothing when errors is 0' , function ( ) {
39+ var Test = this
40+ assert . doesNotThrow ( function ( ) {
41+ Test . $$adapter . _handleErrors ( {
42+ errors : 0
43+ } )
44+ } )
45+ } )
46+ it ( 'should throw an error when errors > 0 && first_error is a string' , function ( ) {
47+ var Test = this
48+ var errorString = 'error string'
49+ assert . throws ( function ( ) {
50+ Test . $$adapter . _handleErrors ( {
51+ errors : 1 ,
52+ first_error : errorString
53+ } )
54+ } , Error , errorString )
55+ } )
56+ it ( 'should throw a generic error when errors > 0 && first_error is nothing' , function ( ) {
57+ var Test = this
58+ assert . throws ( function ( ) {
59+ Test . $$adapter . _handleErrors ( {
60+ errors : 1
61+ } )
62+ } , Error , 'Unknown RethinkDB Error' )
63+ } )
64+ } )
3265
3366describe ( 'exports' , function ( ) {
3467 it ( 'should have correct exports' , function ( ) {
35- assert ( JSDataRethinkDB . default )
3668 assert ( JSDataRethinkDB . RethinkDBAdapter )
37- assert ( JSDataRethinkDB . RethinkDBAdapter === JSDataRethinkDB . default )
3869 assert ( JSDataRethinkDB . OPERATORS )
3970 assert ( JSDataRethinkDB . OPERATORS [ '==' ] )
4071 assert ( JSDataRethinkDB . version )
41- assert ( JSDataRethinkDB . version . full )
4272 } )
4373} )
0 commit comments