nbformat.spec.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. import * as nbformat from '@jupyterlab/nbformat';
  4. const VALIDATE = nbformat.validateMimeValue;
  5. describe('@jupyterlab/nbformat', () => {
  6. describe('validateMimeValue', () => {
  7. it('should return true for a valid json object', () => {
  8. expect(VALIDATE('application/json', { foo: 1 })).toBe(true);
  9. });
  10. it('should return true for a valid json-like object', () => {
  11. expect(VALIDATE('application/foo+json', { foo: 1 })).toBe(true);
  12. });
  13. it('should return true for a valid string object', () => {
  14. expect(VALIDATE('text/plain', 'foo')).toBe(true);
  15. });
  16. it('should return true for a valid array of strings object', () => {
  17. expect(VALIDATE('text/plain', ['foo', 'bar'])).toBe(true);
  18. });
  19. it('should return false for a json type with string data', () => {
  20. expect(VALIDATE('application/foo+json', 'bar')).toBe(false);
  21. });
  22. it('should return false for a string type with json data', () => {
  23. expect(VALIDATE('foo/bar', { foo: 1 })).toBe(false);
  24. });
  25. });
  26. });