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
name: 🏗 Lint & Build | |
on: workflow_call | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 |
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 sequence = `diamondStep ${[1,2,3,4].reduce((v) => v += 'squareStep ', '')}` | |
const expectedSequence = `${[1,2,3,4,5].reduce(v => v += sequence, '')}`; | |
let output = ''; | |
jest.spyOn(diamondSquare, 'diamondStep').mockImplementation(() => { | |
output += 'diamondStep '; | |
}); | |
jest.spyOn(diamondSquare, 'squareStep').mockImplementation(() => { | |
output += 'squareStep '; |
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('should display an alert if user is logged in and email not verified', () => { | |
app.connectedCallback(); | |
authComponent.isUserEmailVerified.mockReturnValue(false); | |
const spy = vi.spyOn(app, 'alert'); | |
setLoginStatus(true); | |
expect(spy).toHaveBeenCalledWith({message: 'Please verify your email address', title: 'Email not verified'}); | |
}); |
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
describe('alert', () => { | |
it('should display an alert with given message and title', () => { | |
app.connectedCallback(); | |
const message = 'some message'; | |
const title = 'some title'; | |
app.alert({message, title}); | |
const alert = app.shadowRoot?.querySelector('#alert'); | |
expect(alert?.getAttribute('Headline')).toBe(title); | |
expect(alert?.getAttribute('text')).toBe(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
async #isUserRegistered(email: string) { | |
const signInMethods = await fetchSignInMethodsForEmail(getAuth(), email); | |
return signInMethods.length > 0; | |
} | |
async #registerUser(email: string, password: string) { | |
await createUserWithEmailAndPassword(getAuth(), email, password); | |
await sendEmailVerification(getAuth().currentUser!); | |
} |
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 { App } from './app'; | |
customElements.define('yag-app', App); | |
class MockAuth extends HTMLElement { | |
constructor() { | |
super(); | |
authComponent = this; | |
} |
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
#handleAuthChange = () => { | |
this.dispatchEvent(new CustomEvent('user-status-change')); | |
} | |
constructor() { | |
super(); | |
onAuthStateChanged(getAuth(), this.#handleAuthChange); | |
} |
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
function setUserCreds(firebaseAuth: any, successful: boolean, user = { | |
uid: '123', | |
email: 'test@test.com' | |
}) { | |
return async () => { | |
(firebaseAuth.getAuth as any).mockReturnValue({ | |
currentUser: successful ? user : null | |
}); | |
if (successful) firebaseAuth.authChangeCallback(); |
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
constructor() { | |
super(); | |
onAuthStateChanged(getAuth(), () => this.dispatchEvent(new CustomEvent('user-status-change'))); | |
} |
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
function setLogin(firebaseAuth: any, successful: boolean) { | |
(firebaseAuth.signInWithEmailAndPassword as any).mockImplementation(async () => { | |
const user = { | |
uid: '123', | |
email: 'test@test.com' | |
}; | |
(firebaseAuth.getAuth as any).mockReturnValue({ | |
currentUser: successful ? user : null | |
}); |
NewerOlder