Skip to content

Commit

Permalink
+tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krowvin committed Oct 22, 2024
1 parent 4e1c0c8 commit a3c5f3a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 34 deletions.
3 changes: 2 additions & 1 deletion tests/endpoints/Catalog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ test('Test Catalog', async () => {
}).then((data) => {
expect(data?.entries).toBeDefined()
Object.entries(data?.entries).forEach(([key, value]) => {
console.log(value?.name)
expect(value?.name).toBeDefined()
});
console.log(`Returned ${data?.entries?.length} timeseries IDs`)
})

}, 20000)
10 changes: 8 additions & 2 deletions tests/endpoints/Pools.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ test('Test Pools', async () => {
}
})
const p_api = new PoolsApi(config)
await p_api.getCwmsDataPools({
await p_api.getCwmsDataPoolsRaw({
"office": "SWT"
}).then((data) => {
})
.then(async (r)=> {
const data = await r.raw.json()
console.log(data)
return data
})
.then((data) => {
expect(data).toBeDefined()
// data.forEach((category) => {
// expect(category).toBeDefined()
Expand Down
72 changes: 42 additions & 30 deletions tests/endpoints/Ratings.test.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
import { RatingsApi } from "cwmsjs";
import fetch from 'node-fetch';
import { RatingsApi, Configuration } from "cwmsjs";
import fetch from "node-fetch";
global.fetch = fetch;

test('Test Ratings', async () => {
const r_api = new RatingsApi()
r_api.getCwmsDataRatings({
"office": "SWT"
}).then((data) => {
expect(data).toBeDefined()
})
// Fetch the CWMS Rating specification for the SWT OFFICE given a rating mask for keystone lake
r_api.getCwmsDataRatingsSpec({
"office": "SWT",
"ratingIdMask": "KEYS.*"
}).then((data) => {
expect(data?.specs).toBeDefined()
})
// Fetch the CWMS Rating templates for the SPK OFFICE
r_api.getCwmsDataRatingsTemplate({
"office": "SPK"
}).then((data) => {
expect(data?.templates).toBeDefined()
})
test("Test Ratings", async () => {
const config_v2 = new Configuration({
headers: {
accept: "application/json;version=2",
},
});
const r_api = new RatingsApi(config_v2);
await r_api
.getCwmsDataRatings({
office: "SWT",
})
.then((data) => {
expect(data).toBeDefined();
});
// Fetch the CWMS Rating specification for the SWT OFFICE given a rating mask for keystone lake
await r_api
.getCwmsDataRatingsSpec({
office: "SWT",
ratingIdMask: "KEYS.*",
})
.then((data) => {
expect(data?.specs).toBeDefined();
});
// Fetch the CWMS Rating templates for the SPK OFFICE
await r_api
.getCwmsDataRatingsTemplate({
office: "SPK",
})
.then((data) => {
expect(data?.templates).toBeDefined();
});

r_api.getCwmsDataRatingsTemplateWithTemplateId({
"office": "SWT",
"templateId": "Elev-Alt;Stor-Alt.Linear"
}).then(data=> {
expect(data).toBeDefined()
})

}, 30000)
// await r_api
// .getCwmsDataRatingsTemplateWithTemplateId({
// office: "SWT",
// templateId: "Elev-Alt;Stor-Alt.Linear",
// })
// .then((data) => {
// expect(data).toBeDefined();
// });
}, 30000);
2 changes: 1 addition & 1 deletion tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"scripts": {
"jest-modules": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test": "npm run jest-modules -- --runInBand",
"test": "npm run jest-modules --",
"test-cicd": "npm run jest-modules -- --runInBand --ci --detectOpenHandles",
"coverage": "npm run test --coverage",
"link": "cd ../src && npm link && cd ../tests && npm link cwmsjs"
Expand Down

0 comments on commit a3c5f3a

Please sign in to comment.