This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button onclick="sendMessage('start')">Start Listen</button> | |
<button onclick="sendMessage('stop')">Stop Listen</button> | |
<script> | |
let se; | |
navigator.serviceWorker.register('/sw.js').then(data => { | |
se = data.active; | |
console.log('se ready!'); | |
}); | |
function sendMessage(message) { | |
if (!se) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button onclick="sendMessage('start')">Start Listen</button> | |
<button onclick="sendMessage('stop')">Stop Listen</button> | |
<button onclick="sendMessage('notification')">Send a Notification</button> | |
<script> | |
let se; | |
navigator.serviceWorker.register('/sw.js').then(data => { | |
se = data.active; | |
console.log('se ready!'); | |
}); | |
function sendMessage(message) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button onclick="sendMessage('start')">Start Listen</button> | |
<button onclick="sendMessage('stop')">Stop Listen</button> | |
<script> | |
let se; | |
const registration = navigator.serviceWorker.register('/sw.js').then(data => { | |
se = data.active; | |
console.log('ready'); | |
}); | |
function sendMessage(message) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button onclick="sendMessage()">Send message</button> | |
<script> | |
let se; | |
const registration = navigator.serviceWorker.register('/sw.js').then(data => { | |
se = data.active; | |
console.log('ready'); | |
}); | |
function sendMessage() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validateSecuredUrl = function (schema, uri) { | |
validateSecuredUrl.errors = [{keyword: 'secured', message: 'avatar url must be "https" schema', params: {keyword: 'secured'}}]; | |
return uri.indexOf('https://') === 0; | |
}; | |
ajv.addKeyword('securedUrl', { | |
validate: validateSecuredUrl, | |
errors: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validateSecuredUrl = function (schema, uri) { | |
return uri.indexOf('https://') === 0; | |
}; | |
ajv.addKeyword('securedUrl', { | |
validate: validateSecuredUrl, | |
errors: true | |
}); | |
it(`should user's schema be valid`, () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect.extend({ | |
toBeValid(isValid, errorMessage) { | |
return { | |
message: () => isValid ? '' : errorMessage, | |
pass: isValid | |
} | |
} | |
}); | |
it(`should user's schema be valid`, () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it.only(`should user's schema be valid`, () => { | |
const schema = { | |
"type": "array", | |
"items": { | |
"type": "object", | |
"properties": { | |
"fullname": { | |
"type": "string", | |
"minLength": 2 | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import users from './users.json'; | |
const shema = { | |
"type": "array", | |
"items": { | |
"type": "object", | |
"properties": { | |
"fullname": { | |
"type": "string", | |
"minLength": 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"fullname": "your full name" | |
} |