Skip to content

Commit

Permalink
chore: add title test
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Jan 2, 2024
1 parent ab17fcd commit f3937f2
Showing 1 changed file with 43 additions and 19 deletions.
62 changes: 43 additions & 19 deletions packages/theme/src/services/title/title.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,6 @@ describe('Service: Title', () => {
}
}

class TestDocument {
querySelector(): NzSafeAny {
return {
childNodes: [],
firstChild: {
textContent: 'a'
}
};
}
querySelectorAll(): NzSafeAny {
return {
childNodes: [],
firstChild: {
textContent: 'a'
}
};
}
}

let title: TestTitleService;
let srv: TitleService;
let i18n: AlainI18NService;
Expand Down Expand Up @@ -227,11 +208,54 @@ describe('Service: Title', () => {

describe('should be hava title via element', () => {
it('with element', fakeAsync(() => {
class TestDocument {
querySelector(): NzSafeAny {
return {
childNodes: [],
firstChild: {
textContent: 'a'
}
};
}
querySelectorAll(): NzSafeAny {
return {
childNodes: [],
firstChild: {
textContent: 'a'
}
};
}
}
genModule([{ provide: DOCUMENT, useClass: TestDocument }]);
srv.setTitle();
tick(srv.DELAY_TIME + 1);
expect(title.setTitle).toHaveBeenCalledWith('a');
}));
it('with element and has children', fakeAsync(() => {
class TestDocument {
querySelector(): NzSafeAny {
return {
childNodes: [
{
nodeType: 2,
textContent: 'b'
},
{
nodeType: 3,
textContent: 'b'
}
],
firstChild: {
textContent: 'a'
}
};
}
}
genModule([{ provide: DOCUMENT, useClass: TestDocument }]);
srv.setTitle();
tick(srv.DELAY_TIME + 1);
expect(title.setTitle).toHaveBeenCalledWith('b');
}));
it('without element', fakeAsync(() => {
genModule([]);
srv.setTitle();
Expand Down

0 comments on commit f3937f2

Please sign in to comment.