config.spec.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. import { DebuggerConfig } from '../src/config';
  4. describe('DebuggerConfig', () => {
  5. const kernel = 'python';
  6. let config: DebuggerConfig;
  7. beforeEach(() => {
  8. config = new DebuggerConfig();
  9. });
  10. describe('#getCodeId', () => {
  11. it('should compute a valid code id when the parameters are set', () => {
  12. const [prefix, suffix] = ['foo', 'bar'];
  13. config.setHashParams({ method: 'Murmur2', seed: 'bar', kernel });
  14. config.setTmpFileParams({ prefix, suffix, kernel });
  15. const codeId = config.getCodeId('i = 0', kernel);
  16. expect(codeId.startsWith(prefix)).toBe(true);
  17. expect(codeId.endsWith(suffix)).toBe(true);
  18. });
  19. it('should throw if the kernel does not have hash parameters', () => {
  20. config.setTmpFileParams({ prefix: 'foo', suffix: 'bar', kernel });
  21. expect(() => {
  22. config.getCodeId('i = 0', kernel);
  23. }).toThrow('has no hashing params');
  24. });
  25. it('should throw if the kernel does not have tmp file parameters', () => {
  26. config.setHashParams({ method: 'Murmur2', seed: 'bar', kernel });
  27. expect(() => {
  28. config.getCodeId('i = 0', kernel);
  29. }).toThrow('has no tmp file params');
  30. });
  31. });
  32. });