From 5b6941a6f9e12fb513a9c6427204d4110544d808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= Date: Tue, 28 Mar 2023 21:36:26 +0300 Subject: [PATCH 1/8] test card title directive --- .../src/lib/tests/card-title.directive.spec.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/tests/card-title.directive.spec.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tests/card-title.directive.spec.ts b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-title.directive.spec.ts new file mode 100644 index 0000000000..10360e23aa --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-title.directive.spec.ts @@ -0,0 +1,18 @@ +import { createHostFactory, SpectatorHost } from '@ngneat/spectator'; +import { CardTitle } from '../components'; + +describe('AbpCardTitleDirective', () => { + let spectator: SpectatorHost; + + const createHost = createHostFactory(CardTitle); + + beforeEach(() => (spectator = createHost(`
CardTitle
`))); + + it('should create an instance', () => { + expect(spectator).toBeTruthy(); + }); + + it('should have class card-title', () => { + expect(spectator.element.classList).toContain('card-title'); + }); +}); From e513481bf04fc8c56f702cc977de9d31f361f397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= Date: Tue, 28 Mar 2023 21:37:07 +0300 Subject: [PATCH 2/8] test subtitle directive --- .../lib/tests/card-subtitle.directive.spec.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/tests/card-subtitle.directive.spec.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tests/card-subtitle.directive.spec.ts b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-subtitle.directive.spec.ts new file mode 100644 index 0000000000..4995067635 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-subtitle.directive.spec.ts @@ -0,0 +1,22 @@ +import { createHostFactory, SpectatorHost } from '@ngneat/spectator'; +import { CardSubtitle } from '../components'; + +describe('AbpCardSubtitleDirective', () => { + let spectator: SpectatorHost; + + const createHost = createHostFactory(CardSubtitle); + + beforeEach(() => (spectator = createHost(`

CardSubtitle

`))); + + it('should create an instance', () => { + expect(spectator).toBeTruthy(); + }); + + it('should have class card-subtitle', () => { + expect(spectator.element.classList).toContain('card-subtitle'); + }); + + it('should have CardSubtitle text', () => { + expect(spectator.element.textContent).toContain('CardSubtitle'); + }); +}); From ce0fbea7104028a68033df928d6962ee483195d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= Date: Tue, 28 Mar 2023 21:37:29 +0300 Subject: [PATCH 3/8] test card-body component --- .../src/lib/tests/card-body.component.spec.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/tests/card-body.component.spec.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tests/card-body.component.spec.ts b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-body.component.spec.ts new file mode 100644 index 0000000000..83cc302625 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-body.component.spec.ts @@ -0,0 +1,46 @@ +import { createHostFactory, SpectatorHost } from '@ngneat/spectator'; +import { CardBodyComponent } from '../components'; + +describe('AbpCardBodyComponent', () => { + let spectator: SpectatorHost; + + const createHost = createHostFactory(CardBodyComponent); + + beforeEach( + () => + (spectator = createHost( + ` +

Body

+
`, + { + hostProps: { attributes: { autofocus: '', name: 'abp-card-body' } }, + }, + )), + ); + + it('should create an instance', () => { + expect(spectator).toBeTruthy(); + }); + + it('should have class card-body', () => { + expect(spectator.element.classList).toContain('card-body'); + }); + + it('should have div', () => { + expect(spectator.query('div')).toBeTruthy(); + }); + + it('should have background-color red', () => { + expect((spectator.query('div') as HTMLElement).style.backgroundColor).toEqual('red'); + }); + + it('should have p tag', () => { + expect(spectator.query('p')).toBeTruthy(); + }); + + it('should have p tag with Body text', () => { + expect(spectator.query('p').textContent).toContain('Body'); + }); +}); From a43bb497bdf2d6a2587c876b17c6b32b19e9ff74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= Date: Tue, 28 Mar 2023 21:38:46 +0300 Subject: [PATCH 4/8] test card-footer component --- .../lib/tests/card-footer.component.spec.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/tests/card-footer.component.spec.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tests/card-footer.component.spec.ts b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-footer.component.spec.ts new file mode 100644 index 0000000000..2b98479b9f --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-footer.component.spec.ts @@ -0,0 +1,46 @@ +import { createHostFactory, SpectatorHost } from '@ngneat/spectator'; +import { CardFooterComponent } from '../components'; + +describe('AbpCardFooterComponent', () => { + let spectator: SpectatorHost; + + const createHost = createHostFactory(CardFooterComponent); + + beforeEach( + () => + (spectator = createHost( + ` +

Footer

+
`, + { + hostProps: { attributes: { autofocus: '', name: 'abp-card-footer' } }, + }, + )), + ); + + it('should create an instance', () => { + expect(spectator).toBeTruthy(); + }); + + it('should have class card-footer', () => { + expect(spectator.element.classList).toContain('card-footer'); + }); + + it('should have div', () => { + expect(spectator.query('div')).toBeTruthy(); + }); + + it('should have background-color red', () => { + expect((spectator.query('div') as HTMLElement).style.backgroundColor).toEqual('red'); + }); + + it('should have p tag', () => { + expect(spectator.query('p')).toBeTruthy(); + }); + + it('should have p tag with Footer text', () => { + expect((spectator.query('p') as HTMLElement).textContent).toContain('Footer'); + }); +}); From fa184b2162684d805d5d1b1d8c58cd484f5d122b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= Date: Tue, 28 Mar 2023 22:24:54 +0300 Subject: [PATCH 5/8] test card-header component --- .../lib/tests/card-header.component.spec.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/tests/card-header.component.spec.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tests/card-header.component.spec.ts b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-header.component.spec.ts new file mode 100644 index 0000000000..279cfe90bf --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-header.component.spec.ts @@ -0,0 +1,37 @@ +import { createHostFactory, SpectatorHost } from '@ngneat/spectator'; +import { CardHeaderComponent } from '../components'; + +describe('AbpCardHeaderComponent', () => { + let spectator: SpectatorHost; + const createHost = createHostFactory(CardHeaderComponent); + + beforeEach( + () => + (spectator = createHost( + ` + Header + `, + { + hostProps: { attributes: { autofocus: '', name: 'abp-card-header' } }, + }, + )), + ); + + it('should create an instance', () => { + expect(spectator).toBeTruthy(); + }); + + it('should have class card-header', () => { + expect(spectator.element.classList).toContain('card-header'); + }); + + it('should have background-color red', () => { + expect((spectator.query('div') as HTMLElement).style.backgroundColor).toEqual('red'); + }); + + it('should have Header text', () => { + expect(spectator.element.textContent).toContain('Header'); + }); +}); From 64eeb5a13329f4c2d3f4c0f54c799e8f713a21c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= Date: Tue, 28 Mar 2023 22:25:37 +0300 Subject: [PATCH 6/8] test card-header directive --- .../lib/tests/card-header.directive.spec.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/tests/card-header.directive.spec.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tests/card-header.directive.spec.ts b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-header.directive.spec.ts new file mode 100644 index 0000000000..d811014447 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-header.directive.spec.ts @@ -0,0 +1,28 @@ +import { createHostFactory, SpectatorHost } from '@ngneat/spectator'; +import { CardHeader } from '../components'; + +describe('AbpCardHeaderDirective', () => { + let spectator: SpectatorHost; + + const createHost = createHostFactory(CardHeader); + + beforeEach( + () => + (spectator = createHost( + `
+
`, + { + hostProps: { attributes: { autofocus: '', name: 'abp-card-header' } }, + }, + )), + ); + + it('should create an instance', () => { + expect(spectator).toBeTruthy(); + }); + + it('should have class card-header', () => { + expect(spectator.element.classList).toContain('card-header'); + }); +}); From dca52ecff015d292a083c50ce964a95609062a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= Date: Tue, 28 Mar 2023 22:26:02 +0300 Subject: [PATCH 7/8] test card-img-top directive --- .../lib/tests/card-img-top.directive.spec.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/tests/card-img-top.directive.spec.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tests/card-img-top.directive.spec.ts b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-img-top.directive.spec.ts new file mode 100644 index 0000000000..2a1ee9cff3 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/tests/card-img-top.directive.spec.ts @@ -0,0 +1,25 @@ +import { createHostFactory, SpectatorHost } from '@ngneat/spectator'; +import { CardImgTop } from '../components'; + +describe('AbpCardImgTopDirective', () => { + let spectator: SpectatorHost; + + const createHost = createHostFactory(CardImgTop); + + beforeEach( + () => + (spectator = createHost( + ``, + )), + ); + + it('should create an instance', () => { + expect(spectator).toBeTruthy(); + }); + + it('should have class card-img-top', () => { + expect(spectator.element.classList).toContain('card-img-top'); + }); +}); From 4a08de662e958008869ddb2a275b925ac034c8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Can=20Y=C4=B1lmaz?= Date: Tue, 28 Mar 2023 22:26:21 +0300 Subject: [PATCH 8/8] test card component --- .../src/lib/tests/card.component.spec.ts | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/tests/card.component.spec.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tests/card.component.spec.ts b/npm/ng-packs/packages/theme-shared/src/lib/tests/card.component.spec.ts new file mode 100644 index 0000000000..3dbc2156f1 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/tests/card.component.spec.ts @@ -0,0 +1,75 @@ +import { createHostFactory, SpectatorHost } from '@ngneat/spectator/jest'; +import { + CardComponent, + CardBodyComponent, + CardFooterComponent, + CardHeaderComponent, + CardHeader, + CardTitle, + CardImgTop, + CardSubtitle, +} from '../components/card'; + +describe('CardComponent', () => { + let spectator: SpectatorHost; + + const createHost = createHostFactory({ + component: CardComponent, + declarations: [ + CardHeaderComponent, + CardTitle, + CardSubtitle, + CardBodyComponent, + CardImgTop, + CardFooterComponent, + ], + }); + + beforeEach( + () => + (spectator = createHost( + ` + + + Card title +

Card subtitle

+
+ + +

Some quick example text to build on the card title and make up the bulk of the card's content.

+
+ + Go somewhere + +
+ `, + { + hostProps: { attributes: { autofocus: '', name: 'abp-card' } }, + }, + )), + ); + + it('should display the card-header', () => { + expect(spectator.query('abp-card-header')).toBeTruthy(); + }); + + it('should display the card-title', () => { + expect(spectator.query('abp-card-title')).toBeTruthy(); + }); + + it('should display the card-subtitle', () => { + expect(spectator.query('p[abp-card-subtitle]')).toBeTruthy(); + }); + + it('should display the card-body', () => { + expect(spectator.query('abp-card-body')).toBeTruthy(); + }); + + it('should display the card-img-top', () => { + expect(spectator.query('abp-card-img-top')).toBeTruthy(); + }); + + it('should display the card-footer', () => { + expect(spectator.query('abp-card-footer')).toBeTruthy(); + }); +});