Skip to content
Snippets Groups Projects
sensor-things.test.js 987 B
Newer Older
  • Learn to ignore specific revisions
  • Briggs, Aaron Shane's avatar
    Briggs, Aaron Shane committed
    import mockConsole from 'jest-mock-console';
    import sinon from 'sinon';
    
    
    import config from 'ui/config';
    
    Briggs, Aaron Shane's avatar
    Briggs, Aaron Shane committed
    import {MOCK_SENSOR_THINGS_DATA} from 'ui/mock-service-data';
    
    import {getSensorThingsURL, fetchDataFromSensorThings} from './sensor-things';
    
    Briggs, Aaron Shane's avatar
    Briggs, Aaron Shane committed
    
    describe('web-services/sensor-things', () => {
        let fakeServer;
        let restoreConsole;
    
        config.SENSOR_THINGS_ENDPOINT = 'fake-sensor-things-endpoint';
    
    Briggs, Aaron Shane's avatar
    Briggs, Aaron Shane committed
    
        beforeEach(() => {
    
    Briggs, Aaron Shane's avatar
    Briggs, Aaron Shane committed
            fakeServer = sinon.createFakeServer();
            restoreConsole = mockConsole();
        });
    
        afterEach(() => {
            fakeServer.restore();
            restoreConsole();
        });
    
        describe('getSensorThingsURL', () => {
            it('Expects url to contain combined agency and site number', () => {
    
                const result = getSensorThingsURL('USGS-01646500', '00065');
                expect(result).toContain("ParameterCode%20eq%20'00065'");
                expect(result).toContain("substringOf('USGS-01646500'%2C%20description)");
    
    Briggs, Aaron Shane's avatar
    Briggs, Aaron Shane committed
    
            });
        });
    });