Skip to content

Commit

Permalink
test(AutoIncrementID): add test for when field is not a number
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Sep 1, 2023
1 parent b41b8ee commit ca1bb67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Basic Suite AutoIncrementID should Error if the schema field is not an number 1`] = `"Field \\"nonNumberField\\" is not a Number or BigInt!"`;

exports[`Basic Suite AutoIncrementID should throw a error if "overwriteModelName" is a function but returns a empty string 1`] = `"\\"overwriteModelname\\" is a function, but did return a falsy type or is not a string!"`;

exports[`Basic Suite AutoIncrementID should throw a error if "overwriteModelName" is a function but returns not a string 1`] = `"\\"overwriteModelname\\" is a function, but did return a falsy type or is not a string!"`;
Expand Down
7 changes: 7 additions & 0 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,5 +550,12 @@ describe('Basic Suite', () => {
expect(err.message).toMatchSnapshot();
}
});

it('should Error if the schema field is not an number', () => {
const schema = new mongoose.Schema({
nonNumberField: String,
});
expect(() => schema.plugin(AutoIncrementID, { field: 'nonNumberField' })).toThrowErrorMatchingSnapshot();
});
});
});

0 comments on commit ca1bb67

Please sign in to comment.