Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding sub total and sorting capabilities #34

Merged
merged 3 commits into from
Mar 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions udmd/api/src/__tests__/device/dao/mongo/MongoDeviceDAO.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import { MongoDeviceDAO } from '../../../../device/dao/mongodb/MongoDeviceDAO';
import { Device, SearchOptions, SORT_DIRECTION } from '../../../../device/model';
import { createDevices } from '../../data';

const mockDevices: Device[] = createDevices(100);

// mongo objects
let connection: MongoClient;
let db: Db;
let deviceCollection: Collection;

// object under test
let mongoDeviceDAO: MongoDeviceDAO;
const mockDevices: Device[] = createDevices(100);

// mocks
// spies
let findSpy;
let sortSpy;
let limitSpy;
Expand All @@ -26,14 +30,12 @@ afterAll(async () => {
});

beforeEach(async () => {
// object under test
mongoDeviceDAO = new MongoDeviceDAO(db);

// data prep
deviceCollection = db.collection('device');
await deviceCollection.insertMany(mockDevices);

// spies
findSpy = jest.spyOn(Collection.prototype, 'find');
sortSpy = jest.spyOn(FindCursor.prototype, 'sort');
limitSpy = jest.spyOn(FindCursor.prototype, 'limit');
Expand All @@ -43,8 +45,8 @@ beforeEach(async () => {
afterEach(async () => {
await db.collection('device').deleteMany({});

// jest.resetAllMocks();
// jest.restoreAllMocks();
jest.resetAllMocks();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u ended up needing these?

jest.restoreAllMocks();
});

describe('MongoDeviceDAO.getDevices', () => {
Expand Down