Skip to content

Instantly share code, notes, and snippets.

View jayjayjpg's full-sized avatar
🖤
git commit --fixup=HEAD~1

Jessy Jordan jayjayjpg

🖤
git commit --fixup=HEAD~1
View GitHub Profile
@jayjayjpg
jayjayjpg / example8.js
Created August 31, 2022 11:31
test-user-interactions-in-js-apps-example8
let fileInputField = document.querySelector('#file-upload-field');
let uploadEvent = new Event('change');
let fileBlob = { files: [new Blob(['Hello World...'])] };
fileInputField.value = fileBlob.files;
fileInputField.dispatchEvent('change');
@jayjayjpg
jayjayjpg / example7.js
Created August 31, 2022 11:30
test-user-interactions-in-js-apps-example7
targetElement.dispatchEvent(event, additionalEventArguments);
@jayjayjpg
jayjayjpg / example6.js
Created August 31, 2022 11:18
test-user-interactions-in-js-apps-example-6
let myButton = document.querySelector('button');
// emulates a 'click' event dispatched from the selected button element
myButton.click();
@jayjayjpg
jayjayjpg / example5.js
Created August 30, 2022 16:50
test-user-interactions-in-js-apps-accurately-with-emulated-events-example-5
import '@testing-library/jest-dom';
import * as React from 'react';
import Upload from '../src/Upload';
import {render, fireEvent, waitFor, screen} from '@testing-library/react';
test('allows uploading files', async () => {
render(<Upload
title="Update Mokedexx"
description="Add your new companions here 🇰🇷"
label="업로드 한국 모켓몬"
@jayjayjpg
jayjayjpg / example4.js
Last active August 30, 2022 16:45
test-user-interactions-in-js-apps-accurately-with-emulated-events-example-4
// Ember & QUnit
// file-upload/tests/integration/components/upload-test.js
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { click, find, render, triggerEvent } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | mox/upload', function (hooks) {
setupRenderingTest(hooks);
@jayjayjpg
jayjayjpg / example-3.js
Last active August 30, 2022 16:43
test-user-interactions-in-js-apps-accurately-with-emulated-events-example-3
// React
// file-upload/common/Upload.js
import React from 'react';
class UploadComponent extends React.Component {
constructor(props) {
super(props);
this.state = {fileContent: ''};
this.handleFileInput = this.handleFileInput.bind(this);
@jayjayjpg
jayjayjpg / example2.js
Created August 30, 2022 16:36
test-user-interactions-in-js-apps-accurately-with-emulated-events-example-2
// file-upload/app/components/upload.js
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { next } from '@ember/runloop';
export default class UploadComponent extends Component {
@tracked
fileContent = '';
@jayjayjpg
jayjayjpg / example1.hbs
Created August 30, 2022 16:34
test-user-interactions-in-js-apps-accurately-with-emulated-events-example-1
{{! EmberJS }}
{{! file-upload/app/components/upload.hbs }}
<section class="my-file-upload-component">
<h2>{{@title}}</h2>
<p>{{@description}}</p>
<button type="button" {{on "click" this.startUpload}}>
Browse file
import Ember from 'ember';
export default Ember.Component.extend({
});
@jayjayjpg
jayjayjpg / controllers.application.js
Last active April 25, 2019 10:25 — forked from iezer/controllers.application.js
Single Ember Data Stores 3.5b
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});