Files
superset2/superset/assets/spec/javascripts/explorev2/utils_spec.jsx
Maxime Beauchemin 366ecefbaa Bumping the JS libs to fix the build (#2616)
* bumping the js libs

* New linting rules

* More linting

* More

* Done linting

* npm >=4.5.0

* Bumping node

* Tweaking the build

* Fixing the damn build

* Fixing the apps
2017-04-13 15:04:09 -07:00

60 lines
2.0 KiB
JavaScript

import { it, describe } from 'mocha';
import { expect } from 'chai';
import URI from 'urijs';
import { getExploreUrl } from '../../../javascripts/explorev2/exploreUtils';
describe('utils', () => {
const formData = {
datasource: '1__table',
};
const sFormData = JSON.stringify(formData);
function compareURI(uri1, uri2) {
expect(uri1.toString()).to.equal(uri2.toString());
}
it('getExploreUrl generates proper base url', () => {
// This assertion is to show clearly the value of location.href
// in the context of unit tests.
expect(location.href).to.equal('about:blank');
compareURI(
URI(getExploreUrl(formData, 'base', false, 'http://superset.com')),
URI('/superset/explore/table/1/').search({ form_data: sFormData }),
);
});
it('getExploreUrl generates proper json url', () => {
compareURI(
URI(getExploreUrl(formData, 'json', false, 'superset.com')),
URI('/superset/explore_json/table/1/').search({ form_data: sFormData }),
);
});
it('getExploreUrl generates proper json forced url', () => {
compareURI(
URI(getExploreUrl(formData, 'json', true, 'superset.com')),
URI('/superset/explore_json/table/1/')
.search({ form_data: sFormData, force: 'true' }),
);
});
it('getExploreUrl generates proper csv URL', () => {
compareURI(
URI(getExploreUrl(formData, 'csv', false, 'superset.com')),
URI('/superset/explore_json/table/1/')
.search({ form_data: sFormData, csv: 'true' }),
);
});
it('getExploreUrl generates proper standalone URL', () => {
compareURI(
URI(getExploreUrl(formData, 'standalone', false, 'superset.com')),
URI('/superset/explore/table/1/')
.search({ form_data: sFormData, standalone: 'true' }),
);
});
it('getExploreUrl preserves main URLs params', () => {
compareURI(
URI(getExploreUrl(formData, 'json', false, 'superset.com?foo=bar')),
URI('/superset/explore_json/table/1/')
.search({ foo: 'bar', form_data: sFormData }),
);
});
});