• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

caleb531 / workday-time-calculator / 6758325809

05 Nov 2023 01:16AM UTC coverage: 74.816% (-0.6%) from 75.373%
6758325809

push

github

caleb531
Only render Update Notification into DOM if update is available

221 of 274 branches covered (0.0%)

Branch coverage included in aggregate %.

3 of 16 new or added lines in 1 file covered. (18.75%)

1808 of 2438 relevant lines covered (74.16%)

100.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

44.07
/scripts/components/update-notification.js
1
import m from 'mithril';
2✔
2
import { registerSW } from 'virtual:pwa-register';
2✔
3

2✔
4
class UpdateNotificationComponent {
2✔
5
  // Use Vite PWA plugin to manage service worker updates (source:
2✔
6
  // <https://vite-pwa-org.netlify.app/guide/prompt-for-update.html#importing-virtual-modules>)
2✔
7
  oninit() {
2✔
8
    if (!navigator.serviceWorker) {
44✔
9
      return;
44✔
10
    }
44✔
11
    if (
×
12
      (window.location.hostname === 'localhost' ||
×
13
        window.location.hostname === '127.0.0.1') &&
44!
14
      !sessionStorage.getItem('sw')
×
15
    ) {
44!
16
      return;
×
17
    }
×
18
    this.isUpdateAvailable = false;
×
19
    this.updateSW = registerSW({
×
20
      onNeedRefresh: () => {
×
21
        this.isUpdateAvailable = true;
×
22
        m.redraw();
×
23
      }
×
24
    });
×
25
  }
44✔
26

2✔
27
  update() {
2✔
28
    if (this.updateSW) {
×
29
      this.updateSW();
×
30
    }
×
31
  }
×
32

2✔
33
  view({ attrs: { updateManager } }) {
2✔
34
    return this.isUpdateAvailable
124✔
35
      ? m(
124!
NEW
36
          'div.update-notification',
×
NEW
37
          {
×
NEW
38
            class: this.isUpdateAvailable ? 'update-available' : '',
×
NEW
39
            onclick: () => this.update()
×
NEW
40
          },
×
NEW
41
          m('div.update-notification-bubble', [
×
NEW
42
            m('h2.update-notification-title', 'Update available!'),
×
NEW
43
            m(
×
NEW
44
              'p.update-notification-subtitle',
×
NEW
45
              'Click here to finish updating.'
×
NEW
46
            )
×
NEW
47
          ])
×
NEW
48
        )
×
49
      : null;
124✔
50
  }
124✔
51
}
2✔
52

2✔
53
export default UpdateNotificationComponent;
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc