Skip to content

Commit

Permalink
build(app): add tests for share link dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
9inpachi committed Mar 29, 2021
1 parent 2cedfec commit ee13bce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h5>URL options</h5>
id="eventDataType"
(input)="setOptionValue('type', $event.target.value)"
>
<option selected disabled>Select</option>
<option value="jivexml">JiveXML</option>
<option value="json">JSON</option>
</select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,28 @@ describe('ShareLinkDialogComponent', () => {

it('should create', () => {
expect(component).toBeTruthy();
expect(component.baseLink).toBeDefined();
expect(component.shareLink).toBeDefined();
expect(component.embedLink).toBeDefined();
});

it('set options value and update share link', () => {
spyOn(component, 'onOptionsChange').and.callThrough();
component.setOptionValue('test_option', 'test_option_value');
expect(component.onOptionsChange).toHaveBeenCalled();
expect(component.shareLink).toContain('test_option=test_option_value');
// Else case
component.setOptionValue('type', undefined);
});

it('should update copy status', () => {
spyOn(document, 'execCommand').and.callThrough();

const element = document.createElement('div');
element.innerText = 'COPY';
component.copyText('textToCopy', element);

expect(element.innerText).toBe('COPIED');
expect(document.execCommand).toHaveBeenCalledWith('copy');
});
});

0 comments on commit ee13bce

Please sign in to comment.