Guest User

Untitled

a guest
Oct 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. /** Prototype(s):
  2.  
  3. librarySystem('dependency', [], function() {
  4. return 'loaded dependency';
  5. });
  6.  
  7. librarySystem('app', ['dependency'], function(dependency) {
  8. return 'app with ' + dependency;
  9. });
  10.  
  11.  
  12. librarySystem('app'); // 'app with loaded dependency'
  13.  
  14. **/
  15.  
  16. /** Notes:
  17.  
  18. * It should take and array where you can specify other library names that the passed in library depends on
  19. * so for example when the sandwich library also depends on another library eg "meat.js" we can only load it when,
  20. * both are available!
  21.  
  22. * If we call a library with librarySystem('sandwich') it should load the library but also load the meat.js?
  23.  
  24. **/
  25.  
  26. tests({
  27. /** Tests for the default library System as we learned it **/
  28.  
  29. 'it should have access to the librarySystem': function() {
  30. eq(typeof librarySystem !== 'undefined', true);
  31. },
  32. 'it should have access to a single loaded library': function() {
  33. var sandwichLib = librarySystem('app');
  34. eq(typeof sandwichLib !== 'undefined', true);
  35. },
  36. 'it can save new librarys / modules without dependencies': function() {
  37.  
  38. librarySystem('testLib', [], function() {
  39. return 'myTestLib';
  40. })
  41. var testTheTestLib = librarySystem('testLib');
  42. eq(typeof testTheTestLib !== 'undefined', true);
  43. },
  44. /** Tests for the new librarySystem with dependencies **/
  45. 'it should pass in the strings from array into the callback arguments': function() {
  46. librarySystem('app', ['dependency'], function(dependency) {
  47.  
  48. return 'app with ' + dependency;
  49. });
  50.  
  51. eq(librarySystem('app'), 'app with loaded dependency');
  52. },
  53. 'it should be able to be flexible enough to accept any number of dependencies': function() {
  54. librarySystem('name', [], function() {
  55. return 'Gordon';
  56. });
  57.  
  58. librarySystem('company', [], function() {
  59. return 'Watch and Code';
  60. });
  61.  
  62. librarySystem('workBlurb', ['name', 'company'], function(name, company) {
  63. return name + ' works at ' + company;
  64. });
  65.  
  66. librarySystem('workBlurb'); // 'Gordon works at Watch and Code'
  67. }
  68. })
Add Comment
Please, Sign In to add comment