nbformat.spec.ts 1.1 KB

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