Skip to content

Commit

Permalink
Add tests for channel parsing of airport
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle committed May 18, 2015
1 parent 6d0b28b commit 5ec636b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions lib/airport.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ function scan(callback) {

exports.scan = scan;
exports.utility = macProvider;
exports.parse = parseAirport;
24 changes: 15 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"name" : "node-wifiscanner",
"version" : "0.2.0",
"description" : "Scan surrounding WiFi access points",
"author": "Maurice Svay <maurice@svay.com>",
"main": "./lib/wifiscanner",
"repository": {
"type": "git",
"url": "git://https://github.com/mauricesvay/node-wifiscanner.git"
}
"name": "node-wifiscanner",
"version": "0.2.0",
"description": "Scan surrounding WiFi access points",
"author": "Maurice Svay <maurice@svay.com>",
"main": "./lib/wifiscanner",
"repository": {
"type": "git",
"url": "git://https://github.com/mauricesvay/node-wifiscanner.git"

This comment has been minimized.

Copy link
@marcbachmann

marcbachmann Jun 15, 2015

I think there is a typo at the protocol part.

This comment has been minimized.

Copy link
@brycekahle

brycekahle Jun 15, 2015

Author Contributor

Yes there is, but I didn't change it.

This comment has been minimized.

Copy link
@mauricesvay

mauricesvay Jun 15, 2015

Owner

Looks like the issue is here since the initial commit

},
"devDependencies": {
"mocha": "^2.2.5"
},
"scripts": {
"test": "mocha tests/*.js"
}
}
22 changes: 22 additions & 0 deletions tests/airport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

var fs = require('fs');
var assert = require('assert');

var airport = require('../lib/airport');

describe('Airport', function() {
it('parses channel information', function() {
var aps = airport.parse(fs.readFileSync('./tests/fixtures/airport/basic.txt', { encoding: 'utf8' }));
assert.ok(aps);
assert.equal(aps.length, 1);
assert.deepEqual(aps[0].channel, '1');
});

it('handles APs with multiple channels', function() {
var aps = airport.parse(fs.readFileSync('./tests/fixtures/airport/multi-channel.txt', { encoding: 'utf8' }));
assert.ok(aps);
assert.equal(aps.length, 1);
assert.deepEqual(aps[0].channel, '157,+1');
});
});
2 changes: 2 additions & 0 deletions tests/fixtures/airport/basic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
testap 40:16:7e:5f:ca:70 0 1 Y -- WPA2(PSK/AES/AES)
2 changes: 2 additions & 0 deletions tests/fixtures/airport/multi-channel.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
testap 40:16:7e:5f:ca:74 -47 157,+1 Y -- WPA2(PSK/AES/AES)

0 comments on commit 5ec636b

Please sign in to comment.