Skip to content

Conversation

@juristr
Copy link
Contributor

@juristr juristr commented Aug 3, 2018

There are basically two things provided here in this PR

  1. Fixes a compilation issue due to duplicate type definitions by @types/jest and the jest-preset-angular

  2. extends the current implementation to allow passing in custom templates.

p.s.: the tests were a bit hard to write because I needed to get a TemplateRef, which is easiest by creating a "Test component" on the fly, which was kind of cumbersome because the TestingModule is created for each test case & also extracts services by using the TestBed injector (i.e. TestBed.get(...)). After you do that, you cannot override a component's template on the fly. Anyway, I added a flag for my test and it works.

The jest-preset-angular already has the necessary types. If both get
installed, then we get build-time errors due to duplicate type definition files
@codecov
Copy link

codecov bot commented Aug 3, 2018

Codecov Report

Merging #95 into develop will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #95      +/-   ##
===========================================
+ Coverage    99.13%   99.13%   +<.01%     
===========================================
  Files           14       14              
  Lines          460      461       +1     
  Branches        79       79              
===========================================
+ Hits           456      457       +1     
  Misses           4        4
Impacted Files Coverage Δ
src/lib/src/models/notifier-notification.model.ts 100% <100%> (ø) ⬆️
...rc/components/notifier-notification.component.html 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e26507...223733a. Read the comment docs.

Copy link
Owner

@itsdevdom itsdevdom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks very good! Could you also add a test case for the new template functionality?

<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" />
</svg>
</button>
<ng-container *ngIf="notification.template; else predefinedNotification" [ngTemplateOutlet]="notification.template" [ngTemplateOutletContext]="{ notification: notification }">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming a shorthand syntax like [ngTemplateOutletContext]="{ notification }" wouldn't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... not sure actually.

@juristr
Copy link
Contributor Author

juristr commented Aug 6, 2018

@dominique-mueller

Could you also add a test case for the new template functionality?

Sure..actually I already had that, but apparently forgot to push that commit as well. Gonna check that and push it up again 👍

@juristr
Copy link
Contributor Author

juristr commented Aug 6, 2018

@dominique-mueller In fact, the test was already there. For some reasons the file has just been reformatted (probably) which is why it seems like the entire file has been committed.

Here's the test I added:

https://github.com/juristr/angular-notifier/blob/fad9457a860c5ece5a54d6a7424fda23073a352b/src/lib/src/components/notifier-notification.component.spec.ts#L75-L112

@itsdevdom
Copy link
Owner

Ah yes, you're right, that's probably why I've overlooked it. Any chance you could fix the formatting issue? Seems like the line breaks are not correct.

@juristr
Copy link
Contributor Author

juristr commented Aug 7, 2018

Any chance you could fix the formatting issue? Seems like the line breaks are not correct.

Why bother, use Prettier? 😉

If you want, I can try to look into it again...probably taking your version and just pasting in my modifications...have to see

@itsdevdom
Copy link
Owner

Seems to be an issue with line breaks, in Visual Studio Code you can easily convert them :)

@juristr juristr force-pushed the feat/dynamic-templates branch from fad9457 to 223733a Compare August 8, 2018 20:20
@juristr
Copy link
Contributor Author

juristr commented Aug 8, 2018

Just tried again...no luck apparently. What line endings are you using in your setting?

P.S. I highly highly recommend going with prettier. avoids these kind of problems 😉. Please let me know. I'm travelling today and tomorrow to speak at ngtalks.io, but would really like to have this merged by Friday in order to conclude some work in my app :). thx

@itsdevdom itsdevdom changed the title Feat/dynamic templates feat(notification): Allow templateRef as notification content Aug 8, 2018
@itsdevdom itsdevdom merged commit d705180 into itsdevdom:develop Aug 8, 2018
@itsdevdom
Copy link
Owner

Merged, and release as 4.1.0 following semver.

@itsdevdom
Copy link
Owner

I thought about prettier as well, but it doesn't 100% match with my personal style guide, in particular with the wide spacing. And I'm not yet ready to give up yet ;D

But for sure a formatter would be great!

@juristr
Copy link
Contributor Author

juristr commented Aug 9, 2018

@dominique-mueller thx for merging 😄. But looks like there's an issue. Seems as if the src code rather than the compiled package has been published on NPM 😅

@itsdevdom
Copy link
Owner

Ah damnit, you're right. I'll fix it with 4.1.1, but it'll have to wait a few hours (I'm not able to push to GitHub from my workplace).

@itsdevdom
Copy link
Owner

Just published 4.1.1, have fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants