config.test.js 1.77 KB
import expect from 'expect.js';
import muk from 'muk';
import info from '../../src/lib/interface';
import Config from '../../src/lib/directive/config';

describe('config.js', function() {
    describe('init', function() {
        it('expect prower filter stayTime frequency exits', function() {
            let config = new Config();
            expect(config.reproc[info.setPower.input]).to.be.eql(config.prePower);
            expect(config.reproc[info.setFilter.input]).to.be.eql(config.preFilter);
            expect(config.reproc[info.setAntStayTime.input]).to.be.eql(config.preStayTime);
            expect(config.reproc[info.setFrequency.input]).to.be.eql(config.preFrequency);
        });
    });
    describe('prePower', function() {
        it('input [15, 15, 0, 0] expect F30F0F0000', function() {
            let config = new Config();
            expect(config.prePower([15, 15, 0, 0])).to.be(info.setPower.input + '0F0F0000');
        });
    });
    describe('preFilter', function() {
        it('input {on:"1",rssi:-27.5} epxect F701FEED00',
            function() {
                let config = new Config();
                expect(config.preFilter({
                    on: '1',
                    rssi: -27.5
                })).to.be(info.setFilter.input + '01FEED00');
            });
    });
    describe('preStayTime', function() {
        it('input 100 expect CA00000064', function() {
            let config = new Config();
            expect(config.preStayTime(100)).to.be(info.setAntStayTime.input + '00000064');
        });
    });
    describe('preFrequency', function() {
        it('input 10 expect BF0A000000', function() {
            let config = new Config();
            expect(config.preFrequency(10)).to.be(info.setFrequency.input + '0A000000')
        });
    });

});