mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
checking in docs for github.io page
This commit is contained in:
8
docs/step2-04/demo/index.html
Normal file
8
docs/step2-04/demo/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
For this step, we look at unit testing. Run
|
||||
<pre>npm test</pre>
|
||||
in the command line.
|
||||
<script type="text/javascript" src="../../step2-04/demo/step2-04/demo.js"></script></body>
|
||||
</html>
|
||||
32
docs/step2-04/demo/src/index.spec.ts
Normal file
32
docs/step2-04/demo/src/index.spec.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { square } from '.';
|
||||
|
||||
describe('jest example', () => {
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
it('should be able to give the square of two numbers', () => {
|
||||
console.log('test');
|
||||
expect(square(5)).toBe(25);
|
||||
});
|
||||
|
||||
it('should increment counter', () => {
|
||||
const { increment } = require('.');
|
||||
expect(increment()).toBe(1);
|
||||
});
|
||||
|
||||
it('should decrement counter', () => {
|
||||
const { decrement } = require('.');
|
||||
expect(decrement()).toBe(-1);
|
||||
});
|
||||
|
||||
it('should retrieve count', () => {
|
||||
const { decrement, getCount, increment } = require('.');
|
||||
increment();
|
||||
increment();
|
||||
decrement();
|
||||
increment();
|
||||
|
||||
expect(getCount()).toBe(2);
|
||||
});
|
||||
});
|
||||
17
docs/step2-04/demo/src/index.ts
Normal file
17
docs/step2-04/demo/src/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
let counter = 0;
|
||||
|
||||
export function getCount() {
|
||||
return counter;
|
||||
}
|
||||
|
||||
export function increment() {
|
||||
return ++counter;
|
||||
}
|
||||
|
||||
export function decrement() {
|
||||
return --counter;
|
||||
}
|
||||
|
||||
export function square(x: number) {
|
||||
return x * x;
|
||||
}
|
||||
14
docs/step2-04/demo/src/store/index.ts
Normal file
14
docs/step2-04/demo/src/store/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export type FilterTypes = 'all' | 'active' | 'completed';
|
||||
|
||||
export interface TodoItem {
|
||||
label: string;
|
||||
completed: boolean;
|
||||
}
|
||||
|
||||
export interface Store {
|
||||
todos: {
|
||||
[id: string]: TodoItem;
|
||||
};
|
||||
|
||||
filter: FilterTypes;
|
||||
}
|
||||
101
docs/step2-04/demo/step2-04/demo.js
Normal file
101
docs/step2-04/demo/step2-04/demo.js
Normal file
@@ -0,0 +1,101 @@
|
||||
/******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = "./step2-04/demo/src/index.ts");
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ({
|
||||
|
||||
/***/ "./step2-04/demo/src/index.ts":
|
||||
/*!************************************!*\
|
||||
!*** ./step2-04/demo/src/index.ts ***!
|
||||
\************************************/
|
||||
/*! exports provided: getCount, increment, decrement, square */
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getCount\", function() { return getCount; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"increment\", function() { return increment; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"decrement\", function() { return decrement; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"square\", function() { return square; });\nvar counter = 0;\nfunction getCount() {\n return counter;\n}\nfunction increment() {\n return ++counter;\n}\nfunction decrement() {\n return --counter;\n}\nfunction square(x) {\n return x * x;\n}\n\n\n//# sourceURL=webpack:///./step2-04/demo/src/index.ts?");
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
Reference in New Issue
Block a user