Browse files

fix airport ibss case

  • Loading branch information...
1 parent b3eac3f commit 70b137a18cbdac817926524074044f652ef06ff6 @swdyh committed Aug 11, 2012
Showing with 5 additions and 5 deletions.
  1. +2 −1 lib/wifi_location.js
  2. +3 −4 test/test.js
View
3 lib/wifi_location.js
@@ -53,7 +53,8 @@ function parseAirportOutput(text) {
}
return tmp
})
- return list.slice(1).map(function(i) {
+ var re = /\w\w:(\w\w:){4}/
+ return list.filter(function(i) { return re.test(i[1]) }).map(function(i) {
return [{}].concat(i).reduce(function(r, i, index) {
r[list[0][index - 1]] = i
return r
View
7 test/test.js
@@ -5,10 +5,8 @@ var wifiLocation = require(path.join(__dirname, '..', 'lib', 'wifi_location'))
function testParseAirpotOutput(t) {
var d = wifiLocation.parseAirportOutput(t)
- assert.equal(d.length, 24)
- assert.ok(d[0].SSID)
- assert.ok(d[0].BSSID)
- assert.ok(d[0].RSSI)
+ assert.ok(d.length > 1)
+ assert.ok(d.every(function(i) { return i.SSID && i.BSSID && i.RSSI }))
}
function testParseIwlistOutput(t) {
@@ -33,6 +31,7 @@ function loadOutputText(file) {
}
testParseAirpotOutput(loadOutputText('osx_airport_output.txt'))
+testParseAirpotOutput(loadOutputText('osx_airport_output_ibss.txt'))
testParseIwlistOutput(loadOutputText('linux_iwlist_output.txt'))
testParseIwlistOutput(loadOutputText('linux_iwlist_output_eq.txt'))
testWifiTowers(loadOutputText('osx_airport_output.txt'), 'darwin')

0 comments on commit 70b137a

Please sign in to comment.