Skip to content

Instantly share code, notes, and snippets.

View wlee221's full-sized avatar
🙃

William Lee wlee221

🙃
View GitHub Profile
class TestableClass {
public foo() { /* do something */ }
public bar() { /* do something */ }
}
class TestableClassTest {
// test suite for Foo
@Nested
class Foo {
@wlee221
wlee221 / createCommitStatus.js
Last active March 20, 2023 23:22
createCommitStatus example
const { status_context, description, state, sha, target_url, owner, repo } = process.env;
if (state.length === 0 || !["error", "failure", "pending", "success"].includes(state)) {
core.setFailed('"state" input cannot be empty.');
return;
}
if (!["error", "failure", "pending", "success"].includes(state)) {
core.setFailed('"state" must be a string input with possible value of (...).');
return;
import { useState } from 'react';
import { Amplify, Auth } from 'aws-amplify';
import {
withAuthenticator,
AccountSettings,
Alert,
Button,
Card,
Flex,
Heading,
Angular
+ <div class="amplify-flex amplify-field amplify-textfield amplify-passwordfield>
<label class="amplify-label" />
<div class="amplify-fieldgroup amplify-flex">
+ <div class="amplify-field-group__field-wrapper">
<input class="amplify-input amplify-fieldgroup__control />
</div>
<div class="amplify-field-group__outer-end">
- <button class="amplify-input amplify-fieldgroup__control amplify-field__show-password />
Feature: Reset Password
...
(adding a new scenario below:)
Scenario:
When I type my "username" with status "CONFIRMED"
And I intercept '{ "headers": { "X-Amz-Target": "AWSCognitoIdentityProviderService.ForgotPassword" } }' with fixture "reset-password"
And I click the "Send code" button
Then I will be redirected to the confirm forgot password page
@wlee221
wlee221 / angular.json
Last active June 13, 2022 18:32
Remove CommonJS or AMD dependencies optimization bailouts warnings for AWS Amplify
// add `allowedCommonJsDependencies` to `projects.architect.build.options`:
"build": {
"builder": "@angular-devkit/build-angular:browser",
...
"options": {
"allowedCommonJsDependencies": [
"@aws-crypto/crc32",
"@aws-crypto/sha256-browser",
"@aws-crypto/sha256-js",
@wlee221
wlee221 / signUp.ts
Created October 22, 2021 22:31
abstracting out "states" with typescript
import { get } from 'lodash';
import { ActionObject, createMachine, sendUpdate, StatesConfig } from 'xstate';
import { Auth } from 'aws-amplify';
import { passwordMatches, runValidators } from '../../../validators';
import { AuthEvent, SignUpContext } from '../../../types';
import {
clearError,
clearFormValues,
@wlee221
wlee221 / vue.config.js
Last active October 12, 2021 13:53
Vue 3: `vue.config.js` configuration for Amplify UI Components
module.exports = {
chainWebpack: config => {
config.module
.rule('vue')
.use('vue-loader')
.tap(options => {
options.compilerOptions = {
...(options.compilerOptions || {}),
isCustomElement: tag => tag.startsWith('amplify-')
};
@wlee221
wlee221 / types.d.ts
Created September 22, 2021 19:10
types.d.ts
// workaround for using typescript strict mode with amplify-js.
// src/types.d.ts
declare module 'graphql/language/ast' { export type DocumentNode = any }
declare module 'graphql/error/GraphQLError' { export type GraphQLError = any }
@wlee221
wlee221 / aws-exports.d.ts
Created September 22, 2021 18:23
aws-exports.d.ts
// put this at the same level as aws-exports
declare const awsmobile: Record<string, any>
export default awsmobile;