Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. describe("Course component tests", () => {
  2. var $scope, $compile, $httpBackend, $q;
  3. var compiled;
  4.  
  5. var qtyperesponse = {}
  6.  
  7. beforeEach(module("courses"));
  8.  
  9. beforeEach(inject((_$rootScope_, _$compile_, _$httpBackend_) => {
  10. $scope = _$rootScope_.$new();
  11. $compile = _$compile_;
  12. $httpBackend = _$httpBackend_;
  13. }));
  14. beforeEach(() => {
  15. $httpBackend.whenGET("Home/GetUser").respond({admin:1});
  16. $httpBackend.whenGET("Home/Qtype").respond(response_getcode);
  17.  
  18. });
  19. beforeEach(() => {
  20. //Mocking routeParams
  21. $routeParams = {
  22. id: 4,
  23. id2: 3,
  24. id3: 1
  25. };
  26. var component = '<edit-codes id="4" id2="3" id3="1"></edit-codes>';
  27. compiled = $compile(component)($scope);
  28. $httpBackend.flush();
  29. $scope.$apply();
  30. });
  31.  
  32. it("should have necessary elements initialized", () => {
  33. var html = compiled.html();
  34. var ids = ["desc", "basecode", "weight", "submit"];
  35. ids.forEach(id => {
  36. expect(html).toContain('test-id="' + id + '"');
  37. });
  38. });
  39.  
  40. it("should have correct basecode", () => {
  41. var codemirror = compiled.find(".CodeMirror-line")[0]; //Since there is only one line
  42.  
  43. expect(angular.element(codemirror).html()).toContain(response_getcode.baseCode);
  44. });
  45.  
  46. xit("should have correct text", () => {
  47. $scope.$digest();
  48. var ql_editor = compiled.find('ng-quill-editor')[0];
  49.  
  50. expect(true).toBe(false);
  51. });
  52.  
  53. it("should have correct weight", () => {
  54. var weight = compiled.find('input[test-id="weight"]')[0];
  55. weight = angular.element(weight)
  56.  
  57. expect(weight.val()).toEqual(response_getcode.weight.toString());
  58. });
  59. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement