Skip to content

Commit

Permalink
Merge pull request #3 from TextureHQ/eng-2344/conditions-support
Browse files Browse the repository at this point in the history
Added conditions support
  • Loading branch information
slava-ovchinnikov committed Jul 25, 2024
2 parents a160b91 + acdf9ba commit 2b2efd7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "weather-plus",
"version": "0.0.15",
"version": "0.0.16",
"description": "Weather Plus is a powerful wrapper around various Weather APIs that simplifies adding weather data to your application",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/weatherPlus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ describe('WeatherPlus Library', () => {
unitCode: "wmoUnit:degC",
qualityControl: "V",
},
textDescription: "Sunny",
}
},
]
Expand All @@ -112,6 +113,10 @@ describe('WeatherPlus Library', () => {
value: 20,
unit: 'C',
},
conditions: {
value: 'Sunny',
unit: 'string',
}
}
expect(response).toEqual(expectedResponse);
});
Expand Down
6 changes: 6 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface IWeatherData {
dewPoint: IDewPoint;
humidity: IRelativeHumidity;
temperature: ITemperature;
conditions: IConditions;
}

export interface ITemperature {
Expand All @@ -17,4 +18,9 @@ export interface IRelativeHumidity {
export interface IDewPoint {
value: number;
unit: 'C' | 'F';
}

export interface IConditions {
value: string;
unit: 'string';
}
5 changes: 5 additions & 0 deletions src/providers/nws/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('convertToWeatherData', () => {
dewpoint: { value: 20, unitCode: "wmoUnit:degC" },
temperature: { value: 20, unitCode: "wmoUnit:degC" },
relativeHumidity: { value: 50, unitCode: "wmoUnit:percent" },
textDescription: "Sunny",
},
};

Expand All @@ -111,6 +112,10 @@ describe('convertToWeatherData', () => {
value: 20,
unit: 'C',
},
conditions: {
value: 'Sunny',
unit: 'string',
},
};

const result = convertToWeatherData(observation);
Expand Down
4 changes: 4 additions & 0 deletions src/providers/nws/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ export function convertToWeatherData(observation: any): IWeatherData {
value: properties.temperature.value,
unit: properties.temperature.unitCode === 'wmoUnit:degC' ? 'C' : 'F',
},
conditions: {
value: properties.textDescription,
unit: 'string',
}
};
}

0 comments on commit 2b2efd7

Please sign in to comment.