@@ -4805,7 +4805,8 @@ exports['Tessel.AP'] = {
4805
4805
test . expect ( 4 ) ;
4806
4806
4807
4807
var settings = {
4808
- ssid : 'TestNetwork'
4808
+ ssid : 'TestNetwork' ,
4809
+ security : 'none'
4809
4810
} ;
4810
4811
var ip = '192.168.1.101' ;
4811
4812
@@ -4875,6 +4876,43 @@ exports['Tessel.AP'] = {
4875
4876
} ) ;
4876
4877
} ,
4877
4878
4879
+ createGetAccessPointIPThrowsError : function ( test ) {
4880
+ test . expect ( 2 ) ;
4881
+
4882
+ var settings = {
4883
+ ssid : 'TestNetwork'
4884
+ } ;
4885
+ var testError = 'This is a test' ;
4886
+
4887
+ this . exec . restore ( ) ;
4888
+ this . exec = sandbox . stub ( childProcess , 'exec' ) . callsFake ( ( cmd , callback ) => {
4889
+ if ( cmd === 'uci get network.lan.ipaddr' ) {
4890
+ callback ( testError ) ;
4891
+ } else {
4892
+ callback ( ) ;
4893
+ }
4894
+ } ) ;
4895
+
4896
+ this . tessel . network . ap . on ( 'create' , ( ) => {
4897
+ test . fail ( 'should not connect' ) ;
4898
+ test . done ( ) ;
4899
+ } ) ;
4900
+
4901
+ this . tessel . network . ap . on ( 'error' , ( error ) => {
4902
+ test . equal ( error , testError , 'error event fires correctly' ) ;
4903
+ } ) ;
4904
+
4905
+ this . tessel . network . ap . create ( settings , ( error ) => {
4906
+ if ( error ) {
4907
+ test . equal ( error , testError , 'error should be passed into callback' ) ;
4908
+ test . done ( ) ;
4909
+ } else {
4910
+ test . fail ( 'should not connect' ) ;
4911
+ test . done ( ) ;
4912
+ }
4913
+ } ) ;
4914
+ } ,
4915
+
4878
4916
reset : function ( test ) {
4879
4917
test . expect ( 5 ) ;
4880
4918
@@ -4906,6 +4944,42 @@ exports['Tessel.AP'] = {
4906
4944
} ) ;
4907
4945
} ,
4908
4946
4947
+ resetErrorCallback : function ( test ) {
4948
+ test . expect ( 5 ) ;
4949
+
4950
+ const testError = new Error ( 'Testing error' ) ;
4951
+ this . exec . restore ( ) ;
4952
+ this . exec = sandbox . stub ( childProcess , 'exec' ) . callsFake ( ( cmd , callback ) => {
4953
+ callback ( testError ) ;
4954
+ } ) ;
4955
+
4956
+ this . tessel . network . ap . on ( 'reset' , ( ) => {
4957
+ test . ok ( true , 'reset event is fired' ) ;
4958
+ } ) ;
4959
+
4960
+ this . tessel . network . ap . on ( 'off' , ( ) => {
4961
+ test . ok ( true , 'off event is fired' ) ;
4962
+ } ) ;
4963
+
4964
+ this . tessel . network . ap . on ( 'disable' , ( ) => {
4965
+ test . ok ( true , 'disable event is fired' ) ;
4966
+ } ) ;
4967
+
4968
+ this . tessel . network . ap . on ( 'error' , ( error ) => {
4969
+ test . ok ( error ) ;
4970
+ } ) ;
4971
+
4972
+ this . tessel . network . ap . reset ( ( error ) => {
4973
+ if ( error ) {
4974
+ test . ok ( error ) ;
4975
+ test . done ( ) ;
4976
+ } else {
4977
+ test . fail ( error ) ;
4978
+ test . done ( ) ;
4979
+ }
4980
+ } ) ;
4981
+ } ,
4982
+
4909
4983
disable : function ( test ) {
4910
4984
test . expect ( 2 ) ;
4911
4985
@@ -4927,6 +5001,30 @@ exports['Tessel.AP'] = {
4927
5001
} ) ;
4928
5002
} ,
4929
5003
5004
+ disableErrorCallback : function ( test ) {
5005
+ test . expect ( 2 ) ;
5006
+
5007
+ const testError = new Error ( 'Testing error' ) ;
5008
+ this . exec . restore ( ) ;
5009
+ this . exec = sandbox . stub ( childProcess , 'exec' ) . callsFake ( ( cmd , callback ) => {
5010
+ callback ( testError ) ;
5011
+ } ) ;
5012
+
5013
+ this . tessel . network . ap . on ( 'error' , ( error ) => {
5014
+ test . ok ( error ) ;
5015
+ } ) ;
5016
+
5017
+ this . tessel . network . ap . disable ( ( error ) => {
5018
+ if ( error ) {
5019
+ test . ok ( error ) ;
5020
+ test . done ( ) ;
5021
+ } else {
5022
+ test . fail ( error ) ;
5023
+ test . done ( ) ;
5024
+ }
5025
+ } ) ;
5026
+ } ,
5027
+
4930
5028
enable : function ( test ) {
4931
5029
test . expect ( 2 ) ;
4932
5030
@@ -4946,5 +5044,29 @@ exports['Tessel.AP'] = {
4946
5044
test . done ( ) ;
4947
5045
}
4948
5046
} ) ;
5047
+ } ,
5048
+
5049
+ enableErrorCallback : function ( test ) {
5050
+ test . expect ( 2 ) ;
5051
+
5052
+ const testError = new Error ( 'Testing error' ) ;
5053
+ this . exec . restore ( ) ;
5054
+ this . exec = sandbox . stub ( childProcess , 'exec' ) . callsFake ( ( cmd , callback ) => {
5055
+ callback ( testError ) ;
5056
+ } ) ;
5057
+
5058
+ this . tessel . network . ap . on ( 'error' , ( error ) => {
5059
+ test . ok ( error ) ;
5060
+ } ) ;
5061
+
5062
+ this . tessel . network . ap . enable ( ( error ) => {
5063
+ if ( error ) {
5064
+ test . ok ( error ) ;
5065
+ test . done ( ) ;
5066
+ } else {
5067
+ test . fail ( error ) ;
5068
+ test . done ( ) ;
5069
+ }
5070
+ } ) ;
4949
5071
}
4950
5072
} ;
0 commit comments