-
-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(models): filter out items with unknown content type (#2192)
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
packages/models/src/Domain/Abstract/TransferPayload/Interfaces/TypeCheck.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { ContentType } from '@standardnotes/common' | ||
import { PayloadTimestampDefaults } from '../../Payload' | ||
import { isCorruptTransferPayload } from './TypeCheck' | ||
|
||
describe('type check', () => { | ||
describe('isCorruptTransferPayload', () => { | ||
it('should return false if is valid', () => { | ||
expect( | ||
isCorruptTransferPayload({ | ||
uuid: '123', | ||
content_type: ContentType.Note, | ||
content: '123', | ||
...PayloadTimestampDefaults(), | ||
}), | ||
).toBe(false) | ||
}) | ||
|
||
it('should return true if uuid is missing', () => { | ||
expect( | ||
isCorruptTransferPayload({ | ||
uuid: undefined as never, | ||
content_type: ContentType.Note, | ||
content: '123', | ||
...PayloadTimestampDefaults(), | ||
}), | ||
).toBe(true) | ||
}) | ||
|
||
it('should return true if is deleted but has content', () => { | ||
expect( | ||
isCorruptTransferPayload({ | ||
uuid: '123', | ||
content_type: ContentType.Note, | ||
content: '123', | ||
deleted: true, | ||
...PayloadTimestampDefaults(), | ||
}), | ||
).toBe(true) | ||
}) | ||
|
||
it('should return true if content type is unknown', () => { | ||
expect( | ||
isCorruptTransferPayload({ | ||
uuid: '123', | ||
content_type: ContentType.Unknown, | ||
content: '123', | ||
...PayloadTimestampDefaults(), | ||
}), | ||
).toBe(true) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters