Skip to content

Commit

Permalink
add rison link and make test case more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
Corbin Robb authored and Corbin Robb committed Feb 15, 2022
1 parent d88c4fe commit eee8975
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
18 changes: 7 additions & 11 deletions superset-frontend/src/views/CRUD/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,13 @@ test('does not ask for password when the import type is wrong', () => {
test('successfully modified rison to encode correctly', () => {
const problemCharacters = '& # ? ^ { } [ ] | " = + `';

const testObject = problemCharacters.split(' ').reduce((a, c) => {
// eslint-disable-next-line no-param-reassign
a[c] = c;
return a;
}, {});
problemCharacters.split(' ').forEach(char => {
const testObject = { test: char };

const actualEncoding = rison.encode(testObject);
const actualEncoding = rison.encode(testObject);
const expectedEncoding = `(test:'${char}')`; // Ex: (test:'&')

const expectedEncoding =
"('\"':'\"','#':'#','&':'&','+':'+','=':'=','?':'?','[':'[',']':']','^':'^','`':'`','{':'{','|':'|','}':'}')";

expect(actualEncoding).toEqual(expectedEncoding);
expect(rison.decode(actualEncoding)).toEqual(testObject);
expect(actualEncoding).toEqual(expectedEncoding);
expect(rison.decode(actualEncoding)).toEqual(testObject);
});
});
4 changes: 2 additions & 2 deletions superset-frontend/src/views/CRUD/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import { FetchDataConfig } from 'src/components/ListView';
import SupersetText from 'src/utils/textUtils';
import { Dashboard, Filters } from './types';

// Modifies the rison encoding slightly to match the backend's
// rison encoding/decoding. Applies globally. Code pulled from rison.js
// Modifies the rison encoding slightly to match the backend's rison encoding/decoding. Applies globally.
// Code pulled from rison.js (https://github.com/Nanonid/rison), rison is licensed under the MIT license.
(() => {
const risonRef: {
not_idchar: string;
Expand Down

0 comments on commit eee8975

Please sign in to comment.