1 | var Errors = require('../abstract-error')
|
2 | , AbstractError = Errors.AbstractError
|
3 |
|
4 | module.exports.setUp = function (leveldown, test, testCommon) {
|
5 | test('setUp common', testCommon.setUp)
|
6 | }
|
7 |
|
8 | module.exports.args = function (test) {
|
9 | }
|
10 |
|
11 | module.exports.error = function (test) {
|
12 | test('test AbstractError constants', function (t) {
|
13 | t.equal(AbstractError.Ok, 0)
|
14 | t.equal(AbstractError.NotFound, 1)
|
15 | t.end()
|
16 | })
|
17 |
|
18 | test('test AbstractError Class Methods', function (t) {
|
19 | var err = new AbstractError("", 1)
|
20 | t.ok(AbstractError.isNotFound(err), "should be notFound")
|
21 | t.notOk(AbstractError.isOk(err), "should not be ok")
|
22 | err.code = 0
|
23 | t.ok(AbstractError.isOk(err), "should be ok")
|
24 | t.end()
|
25 | })
|
26 |
|
27 | test('test AbstractError Classes', function (t) {
|
28 | var err = new Errors.NotFoundError()
|
29 | t.ok(AbstractError.isNotFound(err), "should be notFound")
|
30 | t.ok(err.notFound(), "should be notFound")
|
31 | t.notOk(AbstractError.isOk(err), "should not be ok")
|
32 | err.code = 0
|
33 | t.ok(AbstractError.isOk(err), "should be ok")
|
34 | t.notOk(err.notFound(), "should not be notFound")
|
35 | err.code = null
|
36 | t.ok(err.notFound(), "should be notFound")
|
37 | t.end()
|
38 | })
|
39 |
|
40 | test('test AbstractError instance', function (t) {
|
41 | var err = new Errors.InvalidArgumentError("")
|
42 | t.notOk(err.ok(), "should not be ok")
|
43 | t.notOk(err.notFound(), "should not be notFound")
|
44 | t.ok(err.invalidArgument(), "should be invalidArgument")
|
45 | t.equal(err.message, "InvalidArgument")
|
46 | err = new Errors.InvalidArgumentError()
|
47 | t.equal(err.message, "InvalidArgument")
|
48 | t.end()
|
49 | })
|
50 | }
|
51 |
|
52 | module.exports.all = function (leveldown, test, testCommon) {
|
53 | module.exports.setUp(leveldown, test, testCommon)
|
54 | module.exports.args(test)
|
55 | module.exports.error(test)
|
56 | }
|