Skip to content

Commit 19735ab

Browse files
committed
test for new field, itemClassCode
1 parent 6deccc9 commit 19735ab

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

test/gp.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import assert from 'node:assert';
22
import { after, describe, it } from 'node:test';
33
import { releaseAll } from '@cityssm/mssql-multi-pool';
44
import Debug from 'debug';
5-
import { DEBUG_ENABLE_NAMESPACES } from '../debug.config.js';
5+
import { DEBUG_ENABLE_NAMESPACES, DEBUG_NAMESPACE } from '../debug.config.js';
66
import { DynamicsGP } from '../index.js';
77
import { config } from './config.js';
88
Debug.enable(DEBUG_ENABLE_NAMESPACES);
9+
const debug = Debug(`${DEBUG_NAMESPACE}:test:gp`);
910
await describe('dynamics-gp', async () => {
1011
const gp = new DynamicsGP(config.mssql);
1112
const gpMisconfigured = new DynamicsGP({
@@ -107,9 +108,10 @@ await describe('dynamics-gp', async () => {
107108
await it('Retrieves an Item', async () => {
108109
await gp.getItemByItemNumber(config.itemNumber);
109110
const item = await gp.getItemByItemNumber(config.itemNumber);
110-
console.log(item);
111+
debug(item);
111112
assert.ok(item !== undefined);
112113
assert.strictEqual(config.itemNumber, item.itemNumber);
114+
assert.ok(Object.hasOwn(item, 'itemClassCode'));
113115
});
114116
await it('Returns undefined when item number is not found', async () => {
115117
const item = await gp.getItemByItemNumber(config.itemNumberNotFound);
@@ -130,6 +132,7 @@ await describe('dynamics-gp', async () => {
130132
await it('Retrieves Items', async () => {
131133
const items = await gp.getItemsByLocationCodes(config.locationCodes);
132134
assert.ok(items.length > 0);
135+
assert.ok(Object.hasOwn(items[0], 'itemClassCode'));
133136
});
134137
await it('Throws an error when SQL is misconfigured', async () => {
135138
try {
@@ -161,7 +164,7 @@ await describe('dynamics-gp', async () => {
161164
vendorNameDoesNotContain: config.vendorNameDoesNotContain,
162165
lastPurchaseDateMin: new Date('2024-01-01')
163166
});
164-
console.log(vendors);
167+
debug(vendors);
165168
assert.ok(vendors.length > 0);
166169
});
167170
await it('Throws an error when SQL is misconfigured', async () => {

test/gp.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import { after, describe, it } from 'node:test'
44
import { releaseAll } from '@cityssm/mssql-multi-pool'
55
import Debug from 'debug'
66

7-
import { DEBUG_ENABLE_NAMESPACES } from '../debug.config.js'
7+
import { DEBUG_ENABLE_NAMESPACES, DEBUG_NAMESPACE } from '../debug.config.js'
88
import { DynamicsGP } from '../index.js'
99

1010
import { config } from './config.js'
1111

1212
Debug.enable(DEBUG_ENABLE_NAMESPACES)
1313

14+
const debug = Debug(`${DEBUG_NAMESPACE}:test:gp`)
15+
1416
await describe('dynamics-gp', async () => {
1517
const gp = new DynamicsGP(config.mssql)
1618
const gpMisconfigured = new DynamicsGP({
@@ -156,10 +158,12 @@ await describe('dynamics-gp', async () => {
156158
await gp.getItemByItemNumber(config.itemNumber)
157159
const item = await gp.getItemByItemNumber(config.itemNumber)
158160

159-
console.log(item)
161+
debug(item)
160162

161163
assert.ok(item !== undefined)
162164
assert.strictEqual(config.itemNumber, item.itemNumber)
165+
166+
assert.ok(Object.hasOwn(item, 'itemClassCode'))
163167
})
164168

165169
await it('Returns undefined when item number is not found', async () => {
@@ -185,6 +189,8 @@ await describe('dynamics-gp', async () => {
185189
const items = await gp.getItemsByLocationCodes(config.locationCodes)
186190

187191
assert.ok(items.length > 0)
192+
193+
assert.ok(Object.hasOwn(items[0], 'itemClassCode'))
188194
})
189195

190196
await it('Throws an error when SQL is misconfigured', async () => {
@@ -226,7 +232,7 @@ await describe('dynamics-gp', async () => {
226232
lastPurchaseDateMin: new Date('2024-01-01')
227233
})
228234

229-
console.log(vendors)
235+
debug(vendors)
230236

231237
assert.ok(vendors.length > 0)
232238
})

0 commit comments

Comments
 (0)