LoadingManager.tests.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* global QUnit */
  2. import { LoadingManager } from '../../../../src/loaders/LoadingManager.js';
  3. import { Loader } from '../../../../src/loaders/Loader.js';
  4. export default QUnit.module( 'Loaders', () => {
  5. QUnit.module( 'LoadingManager', () => {
  6. // INSTANCING
  7. QUnit.todo( 'Instancing', ( assert ) => {
  8. // constructor( onLoad, onProgress, onError )
  9. assert.ok( false, 'everything\'s gonna be alright' );
  10. } );
  11. // PUBLIC
  12. QUnit.todo( 'onStart', ( assert ) => {
  13. // Refer to #5689 for the reason why we don't set .onStart
  14. // in the constructor
  15. assert.ok( false, 'everything\'s gonna be alright' );
  16. } );
  17. QUnit.todo( 'onLoad', ( assert ) => {
  18. assert.ok( false, 'everything\'s gonna be alright' );
  19. } );
  20. QUnit.todo( 'onProgress', ( assert ) => {
  21. assert.ok( false, 'everything\'s gonna be alright' );
  22. } );
  23. QUnit.todo( 'onError', ( assert ) => {
  24. assert.ok( false, 'everything\'s gonna be alright' );
  25. } );
  26. QUnit.todo( 'itemStart', ( assert ) => {
  27. assert.ok( false, 'everything\'s gonna be alright' );
  28. } );
  29. QUnit.todo( 'itemEnd', ( assert ) => {
  30. assert.ok( false, 'everything\'s gonna be alright' );
  31. } );
  32. QUnit.todo( 'itemError', ( assert ) => {
  33. assert.ok( false, 'everything\'s gonna be alright' );
  34. } );
  35. QUnit.todo( 'resolveURL', ( assert ) => {
  36. assert.ok( false, 'everything\'s gonna be alright' );
  37. } );
  38. QUnit.todo( 'setURLModifier', ( assert ) => {
  39. assert.ok( false, 'everything\'s gonna be alright' );
  40. } );
  41. QUnit.todo( 'addHandler', ( assert ) => {
  42. // addHandler( regex, loader )
  43. assert.ok( false, 'everything\'s gonna be alright' );
  44. } );
  45. QUnit.todo( 'removeHandler', ( assert ) => {
  46. // removeHandler( regex )
  47. assert.ok( false, 'everything\'s gonna be alright' );
  48. } );
  49. QUnit.todo( 'getHandler', ( assert ) => {
  50. // getHandler( file )
  51. assert.ok( false, 'everything\'s gonna be alright' );
  52. } );
  53. // OTHERS
  54. QUnit.test( 'addHandler/getHandler/removeHandler', ( assert ) => {
  55. const loadingManager = new LoadingManager();
  56. const loader = new Loader();
  57. const regex1 = /\.jpg$/i;
  58. const regex2 = /\.jpg$/gi;
  59. loadingManager.addHandler( regex1, loader );
  60. assert.equal( loadingManager.getHandler( 'foo.jpg' ), loader, 'Returns the expected loader.' );
  61. assert.equal( loadingManager.getHandler( 'foo.jpg.png' ), null, 'Returns null since the correct file extension is not at the end of the file name.' );
  62. assert.equal( loadingManager.getHandler( 'foo.jpeg' ), null, 'Returns null since file extension is wrong.' );
  63. loadingManager.removeHandler( regex1 );
  64. loadingManager.addHandler( regex2, loader );
  65. assert.equal( loadingManager.getHandler( 'foo.jpg' ), loader, 'Returns the expected loader when using a regex with "g" flag.' );
  66. assert.equal( loadingManager.getHandler( 'foo.jpg' ), loader, 'Returns the expected loader when using a regex with "g" flag. Test twice, see #17920.' );
  67. } );
  68. } );
  69. } );