-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports.error = function (code) { | ||
switch (code) { | ||
case 11: | ||
return 'ALREADY CONNECTED'; | ||
case 12: | ||
return 'NOT CONNECTED'; | ||
case 13: | ||
return 'CONNECT FAILED'; | ||
case 21: | ||
return 'INVALID FUNCTION ID'; | ||
case 31: | ||
return 'TIMEOUT'; | ||
case 41: | ||
return 'INVALID PARAMETER'; | ||
case 42: | ||
return 'FUNCTION NOT SUPPORTED'; | ||
default: | ||
return 'UNKNOWN'; | ||
} | ||
}; |
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,34 @@ | ||
import test from 'ava'; | ||
|
||
const errorOutput = require('./error.js'); | ||
|
||
test('Error Code 11', t => { | ||
t.is(errorOutput.error(11), 'ALREADY CONNECTED'); | ||
}); | ||
|
||
test('Error Code 12', t => { | ||
t.is(errorOutput.error(12), 'NOT CONNECTED'); | ||
}); | ||
|
||
test('Error Code 13', t => { | ||
t.is(errorOutput.error(13), 'CONNECT FAILED'); | ||
}); | ||
|
||
test('Error Code 21', t => { | ||
t.is(errorOutput.error(21), 'INVALID FUNCTION ID'); | ||
}); | ||
|
||
test('Error Code 31', t => { | ||
t.is(errorOutput.error(31), 'TIMEOUT'); | ||
}); | ||
|
||
test('Error Code 41', t => { | ||
t.is(errorOutput.error(41), 'INVALID PARAMETER'); | ||
}); | ||
|
||
test('Error Code 42', t => { | ||
t.is(errorOutput.error(42), 'FUNCTION NOT SUPPORTED'); | ||
}); | ||
test('Unknown Error Code', t => { | ||
t.is(errorOutput.error(123), 'UNKNOWN'); | ||
}); |