Skip to content

Commit 859a839

Browse files
committed
Initial Check in.
1 parent dd593e1 commit 859a839

File tree

158 files changed

+3137
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+3137
-0
lines changed

DYRM - node.js.url

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[InternetShortcut]
2+
URL=https://didyoureadme.azurewebsites.net/UserUrls/TagUrls?UserUrlTagId=e1adf4e8-edc7-4443-bde8-aa25bd8af410

apps/app-mocha/.vscode/launch.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
// Use IntelliSense to learn about possible Node.js debug attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"program": "${file}"
12+
},
13+
{
14+
// Name of configuration; appears in the launch configuration drop down menu.
15+
"name": "Run mocha (all)",
16+
// Type of configuration. Possible values: "node", "mono".
17+
"type": "node",
18+
"request": "launch",
19+
// Workspace relative or absolute path to the program.
20+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
21+
// Automatically stop program after launch.
22+
"stopOnEntry": false,
23+
// Command line arguments passed to the program.
24+
"args": [
25+
"test/**/*.js",
26+
"--no-timeouts"
27+
],
28+
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
29+
"cwd": "${workspaceRoot}",
30+
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
31+
"runtimeExecutable": null,
32+
// Environment variables passed to the program.
33+
"env": {
34+
"NODE_ENV": "production"
35+
}
36+
},
37+
{
38+
// Name of configuration; appears in the launch configuration drop down menu.
39+
"name": "Run mocha (current)",
40+
// Type of configuration. Possible values: "node", "mono".
41+
"type": "node",
42+
"request": "launch",
43+
// Workspace relative or absolute path to the program.
44+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
45+
// Automatically stop program after launch.
46+
"stopOnEntry": false,
47+
// Command line arguments passed to the program.
48+
"args": [
49+
"${file}",
50+
"--no-timeouts"
51+
],
52+
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
53+
"cwd": "${workspaceRoot}",
54+
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
55+
"runtimeExecutable": null,
56+
// Environment variables passed to the program.
57+
"env": {
58+
"NODE_ENV": "development"
59+
}
60+
}
61+
]
62+
}
1.14 KB
Binary file not shown.

apps/app-mocha/Ggg.RootOfTheApp.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is the root of the application.
2+
If you are using any IDE, use this folder as application base.
3+
Mocha: Open with VS Code.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
npm install
3+
pause>nul
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@echo off
2+
::
3+
npm install mocha --save-dev
4+
npm install chakram --save-dev
5+
npm install chai --save-dev
6+
npm install sinon --save-dev
7+
pause>nul
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
npm test
3+
pause>nul
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
npm init
3+
pause>nul

apps/app-mocha/package.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "gggjsmochafirst",
3+
"version": "1.0.0",
4+
"description": "Ggg JavaScript Mocha First",
5+
"main": "index.js",
6+
"directories": {
7+
"test": "test"
8+
},
9+
"dependencies": {},
10+
"devDependencies": {
11+
"chakram": "^1.5.0",
12+
"mocha": "^3.4.2",
13+
"sinon": "^2.3.6",
14+
"chai": "^4.0.2"
15+
},
16+
"scripts": {
17+
"test": "mocha"
18+
},
19+
"keywords": [
20+
"ggg",
21+
"js",
22+
"javascript",
23+
"mocha"
24+
],
25+
"author": "aozdemir",
26+
"license": "ISC"
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/* Chakram is an API testing framework designed to perform end to end tests on JSON REST endpoints. */
2+
/* Chakram offers a BDD testing style through Chakram's expect interface. */
3+
4+
var chakram = require('chakram');
5+
var expect = chakram.expect;
6+
7+
// simple response
8+
describe("Chakram", function () {
9+
it("should offer simple HTTP request capabilities", function () {
10+
var response = chakram.get("http://httpbin.org/get");
11+
return response;
12+
});
13+
});
14+
15+
// response 200
16+
describe("Chakram", function () {
17+
it("should provide HTTP specific assertions", function () {
18+
var response = chakram.get("http://httpbin.org/get");
19+
var response = expect(response).to.have.status(200);
20+
return response;
21+
});
22+
});
23+
24+
describe("HTTP assertions", function () {
25+
it("should make HTTP assertions easy", function () {
26+
var response = chakram.get("http://httpbin.org/get?test=chakram");
27+
expect(response).to.have.status(200);
28+
expect(response).to.have.header("content-type", "application/json");
29+
expect(response).not.to.be.encoded.with.gzip;
30+
expect(response).to.comprise.of.json({
31+
args: { test: "chakram" }
32+
});
33+
var waitedResponse = chakram.wait();
34+
return waitedResponse;
35+
});
36+
});
37+
38+
// wait for response
39+
describe("Chakram", function () {
40+
it("should provide a simple async testing framework", function () {
41+
var response = chakram.get("http://httpbin.org/get");
42+
expect(response).to.have.status(200);
43+
expect(response).not.to.have.header('non-existing-header');
44+
var waitedResponse = chakram.wait();
45+
return waitedResponse;
46+
});
47+
});
48+
49+
// Complex Promise Use
50+
// https://github.com/request/request#requestoptions-callback
51+
// Simplified HTTP request client.
52+
describe("Chakram", function () {
53+
it("should support sequential API interaction", function () {
54+
var requestParams = {
55+
headers: {
56+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
57+
}
58+
};
59+
var response = chakram.get("https://api.github.com/", requestParams)
60+
.then(function (apiResponse) {
61+
var emojisUrl = apiResponse.body.emojis_url;
62+
var response = chakram.get(emojisUrl, requestParams);
63+
return response;
64+
})
65+
.then(function (emojiList) {
66+
var cinema = emojiList.body.cinema;
67+
expect(cinema).to.contain("images/icons/emoji");
68+
});
69+
return response;
70+
});
71+
});
72+
73+
describe("BDD + Hooks", function () {
74+
var thingName;
75+
before("post dweet", function () {
76+
thingName = "chakramtest" + Math.floor(Math.random() * 2000);
77+
var postResponse = chakram.post("https://dweet.io/dweet/for/" + thingName, {
78+
testing: "your API"
79+
});
80+
return postResponse;
81+
});
82+
83+
it("should support getting latest dweet", function () {
84+
var postedData = chakram.get("https://dweet.io/get/latest/dweet/for/" + thingName);
85+
return expect(postedData).to.have.json('with[0].content', {
86+
testing: "your API"
87+
});
88+
});
89+
90+
after("update dweet with result", function () {
91+
return chakram.post("https://dweet.io/dweet/for/" + thingName, {
92+
testing: "passed"
93+
});
94+
});
95+
});
96+
97+
// add new property
98+
describe("Extensibility", function () {
99+
before("define teapot", function () {
100+
chakram.addProperty("teapot", function (respObj) {
101+
var statusCode = respObj.response.statusCode;
102+
this.assert(statusCode === 418,
103+
'expected status code ' + statusCode + ' to equal 418',
104+
'expected ' + statusCode + ' to not be equal to 418');
105+
});
106+
});
107+
108+
it("should be able to detect teapots", function () {
109+
var notATeapot = chakram.get("http://httpbin.org/status/200");
110+
var aTeapot = chakram.get("http://httpbin.org/status/418");
111+
expect(notATeapot).to.not.be.teapot;
112+
expect(aTeapot).to.be.teapot;
113+
var waitedResponse = chakram.wait();
114+
return waitedResponse;
115+
});
116+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var assert = require('assert');
2+
3+
// Test Class
4+
describe('Array', function () {
5+
// Test Method
6+
describe('#indexOf()', function () {
7+
// Asserts
8+
it('should return -1 when the value is not present', function () {
9+
assert.equal(-1, [1, 2, 3].indexOf(4));
10+
});
11+
});
12+
});
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var fs = require('fs');
2+
var sinon = require("sinon");
3+
var chakram = require('chakram');
4+
var expect = chakram.expect;
5+
6+
var writeFileStub = sinon.stub(fs, 'writeFile', function (path, data, cb) {
7+
return cb(null);
8+
});
9+
describe('Sinon File Caller', function () {
10+
it("Sinon should call file", function () {
11+
expect(writeFileStub).to.be.called;
12+
});
13+
});
14+
writeFileStub.restore();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"main.css": "static/css/main.cacbacc7.css",
3+
"main.css.map": "static/css/main.cacbacc7.css.map",
4+
"main.js": "static/js/main.99ae270e.js",
5+
"main.js.map": "static/js/main.99ae270e.js.map",
6+
"static\\media\\logo.svg": "static/media/logo.5d5d9eef.svg"
7+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>React App</title><link href="/static/css/main.cacbacc7.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="/static/js/main.99ae270e.js"></script></body></html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "192x192",
8+
"type": "image/png"
9+
}
10+
],
11+
"start_url": "./index.html",
12+
"display": "standalone",
13+
"theme_color": "#000000",
14+
"background_color": "#ffffff"
15+
}

apps/app-react-first/ggg-react-app/build/service-worker.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/app-react-first/ggg-react-app/build/static/css/main.cacbacc7.css

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/app-react-first/ggg-react-app/build/static/css/main.cacbacc7.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/app-react-first/ggg-react-app/build/static/js/main.99ae270e.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/app-react-first/ggg-react-app/build/static/js/main.99ae270e.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import React, { Component } from 'react';
2+
import uuid from 'uuid';
3+
4+
class AddProject extends Component {
5+
constructor() {
6+
super();
7+
this.state = {
8+
newProject: {}
9+
}
10+
}
11+
12+
static defaultProps = {
13+
categories: ["Web Design", "Web Development", "Mobile Development"]
14+
}
15+
16+
handleSubmit(event) {
17+
console.log("handleSubmit", "handleSubmit");
18+
if (this.refs.title.value === '') {
19+
alert('Title is required!');
20+
}
21+
else {
22+
this.setState({
23+
newProject: {
24+
id: uuid.v4(),
25+
title: this.refs.title.value,
26+
category: this.refs.category.value
27+
}
28+
}, function () {
29+
// console.log("this.state", this.state);
30+
this.props.addProject(this.state.newProject);
31+
});
32+
}
33+
event.preventDefault();
34+
}
35+
36+
render() {
37+
let categoryOptions = this.props.categories.map(category => {
38+
return <option key={category} value={category}>{category}</option>
39+
});
40+
41+
return (
42+
<div>
43+
<h3>Add Project</h3>
44+
<form onSubmit={this.handleSubmit.bind(this)}>
45+
<div>
46+
<label>Title</label>
47+
<input type="text" ref="title" />
48+
</div>
49+
<div>
50+
<label>Category</label>
51+
<select ref="category">
52+
{categoryOptions}
53+
</select>
54+
</div>
55+
<br />
56+
<input type="submit" value="Submit" />
57+
</form>
58+
</div>
59+
);
60+
}
61+
}
62+
AddProject.propTypes = {
63+
categories: React.PropTypes.array,
64+
addProject: React.PropTypes.func
65+
}
66+
export default AddProject;

0 commit comments

Comments
 (0)