Skip to content

Commit

Permalink
Remove util.ajax: deprecated since v3.0.0 (katspaugh#2033)
Browse files Browse the repository at this point in the history
* removed ajax util as deprecated

* updated changelog

* removed ajax tests
  • Loading branch information
marizuccara committed Aug 3, 2020
1 parent b14f723 commit d857abb
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 170 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Next (unreleased)
- Spectrogram plugin: move to separate directory (#1996)
- Mediasession plugin: move to separate directory (#2020)
- Timeline plugin: move to separate directory (#2018)
- Remove `util.ajax`: deprecated since v3.0.0 (#2033)

4.0.1 (23.06.2020)
------------------
Expand Down
84 changes: 0 additions & 84 deletions spec/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,90 +4,6 @@ import WaveSurfer from '../src/wavesurfer.js';

import TestHelpers from './test-helpers.js';

/** @test {util.ajax} */
describe('util.ajax:', function() {
const defaultUrl = TestHelpers.EXAMPLE_FILE_PATH;

it('can load an arraybuffer', function(done) {
const options = {
url: defaultUrl,
responseType: 'arraybuffer'
};
const instance = WaveSurfer.util.ajax(options);
instance.once('success', (data, e) => {
// url
expect(e.target.responseURL).toContain(options.url);

// responseType
expect(instance.xhr.responseType).toBe(options.responseType);

// returned data is an arraybuffer
expect(data).toEqual(jasmine.any(ArrayBuffer));

done();
});
});

it('fires the error event when the file is not found', function(done) {
const options = {
url: '/foo/bar'
};
const instance = WaveSurfer.util.ajax(options);
instance.once('error', e => {
// url
expect(e.target.responseURL).toContain(options.url);

// error message
expect(e.target.statusText).toBe('Not Found');
expect(e.target.status).toBe(404);

done();
});
});

it('fires the progress event during loading', function(done) {
const options = {
url: defaultUrl,
responseType: 'arraybuffer'
};
const instance = WaveSurfer.util.ajax(options);
instance.once('progress', e => {
// url
expect(e.target.responseURL).toContain(options.url);

// progress message
expect(e.target.statusText).toBe('OK');
expect(e.target.status).toBe(200);

done();
});
});

it('accepts custom request headers and credentials', function(done) {
const options = {
url: defaultUrl,
responseType: 'arraybuffer',
xhr: {
withCredentials: true,
requestHeaders: [
{
key: 'Authorization',
value: 'my-token'
}
]
}
};
const instance = WaveSurfer.util.ajax(options);
instance.once('success', (data, e) => {
// with credentials
expect(e.target.withCredentials).toBeTrue();

// XXX: find a way to retrieve request headers
done();
});
});
});

/** @test {util.fetchFile} */
describe('util.fetchFile:', function() {
const audioExampleUrl = TestHelpers.EXAMPLE_FILE_PATH;
Expand Down
85 changes: 0 additions & 85 deletions src/util/ajax.js

This file was deleted.

1 change: 0 additions & 1 deletion src/util/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as ajax } from './ajax';
export { default as getId } from './get-id';
export { default as max } from './max';
export { default as min } from './min';
Expand Down

0 comments on commit d857abb

Please sign in to comment.