Skip to content

Commit

Permalink
From Jasmine to Jest conversion
Browse files Browse the repository at this point in the history
Converts fileds_spec and mioq_api_spec from Jasmine to Jest

old_js_file_require_helper - sets function from file(s) to global so they can be accessed in Jest specs, requires files
  • Loading branch information
ZitaNemeckova committed Nov 7, 2018
1 parent af51ff0 commit bcbe889
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/miq_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@ function miqResetSizeTimer() {
}

// Pass fields to server given a URL and fields in name/value pairs
function miqPassFields(url, args) {
window.miqPassFields = function (url, args) {
return url + '?' + $.param(args);
}
};

function miqChartLinkData(col, row, value, category, series, id, message) {
// Create the context menu
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/spec/helpers/old_js_file_require_helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global.window = global;
require('../../../assets/javascripts/miq_application.js');
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
describe('Pass fields to server', function() {
it('returns url fields in name/value pairs', function() {
require('../helpers/old_js_file_require_helper.js');

describe('Pass fields to server', () => {
it('returns url fields in name/value pairs', () => {
var url = '/path/to/infinity';
var args = {'foo': 'bar', 'lorem': 'ipsum'};
expect(miqPassFields(url, args)).toEqual('/path/to/infinity?foo=bar&lorem=ipsum');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
describe('miq_api.js', function() {
it("can base64 encode utf8 passwords", function(done) {
describe('miq_api.js', () => {
it("can base64 encode utf8 passwords", done => {
var getArgs;

spyOn(vanillaJsAPI, 'get').and.callFake(function(_url, args) {
jest.spyOn(vanillaJsAPI, 'get').mockImplementation(function(_url, args) {
getArgs = args;
return Promise.resolve({});
});
Expand Down

0 comments on commit bcbe889

Please sign in to comment.