Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe("Course component tests", () => {
- var $scope, $compile, $httpBackend, $q;
- var compiled;
- var qtyperesponse = {}
- beforeEach(module("courses"));
- beforeEach(inject((_$rootScope_, _$compile_, _$httpBackend_) => {
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- $httpBackend = _$httpBackend_;
- }));
- beforeEach(() => {
- $httpBackend.whenGET("Home/GetUser").respond({admin:1});
- $httpBackend.whenGET("Home/Qtype").respond(response_getcode);
- });
- beforeEach(() => {
- //Mocking routeParams
- $routeParams = {
- id: 4,
- id2: 3,
- id3: 1
- };
- var component = '<edit-codes id="4" id2="3" id3="1"></edit-codes>';
- compiled = $compile(component)($scope);
- $httpBackend.flush();
- $scope.$apply();
- });
- it("should have necessary elements initialized", () => {
- var html = compiled.html();
- var ids = ["desc", "basecode", "weight", "submit"];
- ids.forEach(id => {
- expect(html).toContain('test-id="' + id + '"');
- });
- });
- it("should have correct basecode", () => {
- var codemirror = compiled.find(".CodeMirror-line")[0]; //Since there is only one line
- expect(angular.element(codemirror).html()).toContain(response_getcode.baseCode);
- });
- xit("should have correct text", () => {
- $scope.$digest();
- var ql_editor = compiled.find('ng-quill-editor')[0];
- expect(true).toBe(false);
- });
- it("should have correct weight", () => {
- var weight = compiled.find('input[test-id="weight"]')[0];
- weight = angular.element(weight)
- expect(weight.val()).toEqual(response_getcode.weight.toString());
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement