|
| 1 | +import { describe, it } from "node:test"; |
| 2 | +import assert from "node:assert/strict"; |
| 3 | +import { weatherModule } from "./test-setup.mjs"; |
| 4 | + |
| 5 | +describe("cardinalWindDirection", () => { |
| 6 | + it("should return N for 0 degrees", () => { |
| 7 | + assert.equal(weatherModule.cardinalWindDirection(0), "N"); |
| 8 | + }); |
| 9 | + |
| 10 | + it("should return N for 360 degrees", () => { |
| 11 | + assert.equal(weatherModule.cardinalWindDirection(360), "N"); |
| 12 | + }); |
| 13 | + |
| 14 | + it("should return NE for 45 degrees", () => { |
| 15 | + assert.equal(weatherModule.cardinalWindDirection(45), "NE"); |
| 16 | + }); |
| 17 | + |
| 18 | + it("should return E for 90 degrees", () => { |
| 19 | + assert.equal(weatherModule.cardinalWindDirection(90), "E"); |
| 20 | + }); |
| 21 | + |
| 22 | + it("should return SE for 135 degrees", () => { |
| 23 | + assert.equal(weatherModule.cardinalWindDirection(135), "SE"); |
| 24 | + }); |
| 25 | + |
| 26 | + it("should return S for 180 degrees", () => { |
| 27 | + assert.equal(weatherModule.cardinalWindDirection(180), "S"); |
| 28 | + }); |
| 29 | + |
| 30 | + it("should return SW for 225 degrees", () => { |
| 31 | + assert.equal(weatherModule.cardinalWindDirection(225), "SW"); |
| 32 | + }); |
| 33 | + |
| 34 | + it("should return W for 270 degrees", () => { |
| 35 | + assert.equal(weatherModule.cardinalWindDirection(270), "W"); |
| 36 | + }); |
| 37 | + |
| 38 | + it("should return NW for 315 degrees", () => { |
| 39 | + assert.equal(weatherModule.cardinalWindDirection(315), "NW"); |
| 40 | + }); |
| 41 | + |
| 42 | + it("should handle intermediate values", () => { |
| 43 | + assert.equal(weatherModule.cardinalWindDirection(22), "NNE"); |
| 44 | + assert.equal(weatherModule.cardinalWindDirection(67), "ENE"); |
| 45 | + assert.equal(weatherModule.cardinalWindDirection(112), "ESE"); |
| 46 | + assert.equal(weatherModule.cardinalWindDirection(157), "SSE"); |
| 47 | + assert.equal(weatherModule.cardinalWindDirection(202), "SSW"); |
| 48 | + assert.equal(weatherModule.cardinalWindDirection(247), "WSW"); |
| 49 | + assert.equal(weatherModule.cardinalWindDirection(292), "WNW"); |
| 50 | + assert.equal(weatherModule.cardinalWindDirection(337), "NNW"); |
| 51 | + }); |
| 52 | + |
| 53 | + it("should handle boundary values", () => { |
| 54 | + assert.equal(weatherModule.cardinalWindDirection(11.24), "N"); |
| 55 | + assert.equal(weatherModule.cardinalWindDirection(11.26), "NNE"); |
| 56 | + assert.equal(weatherModule.cardinalWindDirection(348.74), "NNW"); |
| 57 | + assert.equal(weatherModule.cardinalWindDirection(348.76), "N"); |
| 58 | + }); |
| 59 | +}); |
0 commit comments