-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aurélien Allienne
committed
Jan 23, 2018
1 parent
c9c472f
commit a1fbb80
Showing
19 changed files
with
322 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Florian Orpelière | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
function testDestructuring(arrayIndex, objectName, restLength){ | ||
// Vous ne devez rien changer ici, juste utiliser les mêmes noms de variable | ||
return arrayIndex + objectName + restLength.length; | ||
} | ||
|
||
|
||
module.exports = {testDestructuring}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const {testDestructuring} = require('./exo.js'); | ||
|
||
describe('Test exercise for bases', function () { | ||
|
||
let instanceToTest; | ||
|
||
it('Test testDestructuring() 1', () => { | ||
expect(testDestructuring([1,2,3], {name: 'plop'}, 1, 2, 'plop', 'test')).toBe('2plop4'); | ||
}); | ||
|
||
it('Test testDestructuring() 2', () => { | ||
expect(testDestructuring([1,2,3], {name: 'foo'}, 1, 2, 'plop')).toBe('2foo3'); | ||
}); | ||
|
||
it('Test testDestructuring() 3', () => { | ||
expect(testDestructuring([1,2,3], undefined, 1, 2, 'plop')).toBe('2toto3'); | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Cat { | ||
} | ||
|
||
class MainCoon { | ||
} | ||
|
||
module.exports = {Cat, MainCoon}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const {MainCoon} = require('./exo.js'); | ||
|
||
describe('Test exercise for classes', function () { | ||
|
||
let instanceToTest; | ||
|
||
beforeEach(() => { | ||
spyOn(console, 'log'); | ||
instanceToTest = new MainCoon('Garfield', 'red'); | ||
}); | ||
|
||
it('Is create correctly', () => expect(instanceToTest).toBeDefined()); | ||
|
||
it('Have a name', () => expect(instanceToTest.name).toBe('Garfield')); | ||
|
||
it('Have a color', () => expect(instanceToTest.color).toBe('red')); | ||
|
||
it('Have a meow()', () => expect(instanceToTest.meow).toBeDefined()); | ||
|
||
it('Have a sleep()', () => expect(instanceToTest.sleep).toBeDefined()); | ||
|
||
it('Have a play()', () => { | ||
instanceToTest.play(); | ||
expect(console.log.calls.count()).toBe(2); | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const generator = function* { | ||
|
||
}; | ||
|
||
module.exports = {generator}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const {generator} = require('./exo.js'); | ||
|
||
describe('Test exercise for classes', function () { | ||
|
||
let instanceToTest; | ||
|
||
beforeEach(() => { | ||
instanceToTest = generator(); | ||
}); | ||
|
||
it('Fibonacci rocks', () => { | ||
expect(instanceToTest.next().value).toBe(0); | ||
expect(instanceToTest.next().value).toBe(1); | ||
expect(instanceToTest.next().value).toBe(1); | ||
expect(instanceToTest.next().value).toBe(2); | ||
expect(instanceToTest.next().value).toBe(3); | ||
expect(instanceToTest.next().value).toBe(5); | ||
expect(instanceToTest.next().value).toBe(8); | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test module</title> | ||
</head> | ||
<body> | ||
|
||
<script src="bundle.js"></script> | ||
</body> | ||
</html> |
Empty file.
Empty file.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
function exercise1Fn () { | ||
let exercise1 = new Promise(() => { | ||
/* votre solution ici */ | ||
}); | ||
|
||
return exercise1./* votre solution ici */ | ||
} | ||
|
||
function exercise2Fn () { | ||
let exercise2 = new Promise(() => { | ||
/* votre solution ici */ | ||
}); | ||
|
||
return exercise2./* votre solution ici */ | ||
} | ||
|
||
function exercise3Fn () { | ||
let exercise3 = Promise.resolve(1); | ||
|
||
function plusFive(value) { | ||
/* votre solution ici */ | ||
} | ||
|
||
function multiplyByTwo(value) { | ||
/* votre solution ici */ | ||
} | ||
|
||
function minusFour(value) { | ||
/* votre solution ici */ | ||
} | ||
|
||
return exercise3./* votre solution ici */; | ||
} | ||
|
||
module.exports = {exercise1Fn, exercise2Fn, exercise3Fn}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const {exercise1Fn, exercise2Fn, exercise3Fn} = require('./exo.js'); | ||
|
||
describe('Test exercise for promises', function () { | ||
|
||
let instanceToTest; | ||
|
||
beforeEach(() => { | ||
spyOn(console, 'log'); | ||
}); | ||
|
||
it('Exercise 1', done => { | ||
expect(exercise1Fn).toBeDefined(); | ||
exercise1Fn().then(value => { | ||
expect(value).toBe(undefined); | ||
expect(console.log.calls.count()).toBe(1); | ||
expect(console.log).toHaveBeenCalledWith('I love promise'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Exercise 2', done => { | ||
expect(exercise2Fn).toBeDefined(); | ||
exercise2Fn().then(value => { | ||
expect(value).toBe(undefined); | ||
expect(console.log.calls.count()).toBe(1); | ||
expect(console.log).toHaveBeenCalledWith('I hate rejection'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Exercise 3', done => { | ||
expect(exercise3Fn).toBeDefined(); | ||
exercise3Fn().then(value => { | ||
expect(value).toBe(8); | ||
done(); | ||
}); | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let traps = { | ||
/* votre solution ici */ | ||
}; | ||
|
||
module.exports = {traps}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const {traps} = require('./exo.js'); | ||
|
||
describe('Test exercice for proxies', function () { | ||
it('testing that the setter only sets unique strings', () => { | ||
let pseudos = []; | ||
let pseudosProxy = new Proxy( pseudos, traps); | ||
|
||
pseudosProxy.push('badass', 'badass'); | ||
|
||
expect(pseudosProxy.length).toBe(1); | ||
expect(pseudos.length).toBe(1); | ||
}); | ||
it('testing that the setter only sets uppercase', () => { | ||
let pseudos = []; | ||
let pseudosProxy = new Proxy( pseudos, traps); | ||
|
||
pseudosProxy.push('BadAsS', 'SuPerMan'); | ||
|
||
expect(pseudosProxy[0]).toBe('badass'); | ||
expect(pseudosProxy[1]).toBe('superman'); | ||
}); | ||
it('testing that the getter doesnt get special chars from the proxy', () => { | ||
let pseudos = []; | ||
let pseudosProxy = new Proxy( pseudos, traps); | ||
|
||
pseudosProxy.push('iMa_Ro%%oR_P3wn€R', 'xXXc4tSl4yer$$XXx'); | ||
|
||
expect(pseudosProxy[0]).toBe('ima_roor_p3wnr'); | ||
expect(pseudosProxy[1]).toBe('xxxc4tsl4yerxxx'); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"spec_files": [ | ||
"**/*spec.js" | ||
], | ||
"stopSpecOnExpectationFailure": false, | ||
"random": false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
0 info it worked if it ends with ok | ||
1 verbose cli [ '/Users/florianorpeliere/.nvm/versions/node/v6.9.5/bin/node', | ||
1 verbose cli '/Users/florianorpeliere/.nvm/versions/node/v6.9.5/bin/npm', | ||
1 verbose cli 'run', | ||
1 verbose cli 'bases' ] | ||
2 info using npm@3.10.10 | ||
3 info using node@v6.9.5 | ||
4 verbose run-script [ 'prebases', 'bases', 'postbases' ] | ||
5 info lifecycle esnext-training@0.0.1~prebases: esnext-training@0.0.1 | ||
6 silly lifecycle esnext-training@0.0.1~prebases: no script for prebases, continuing | ||
7 info lifecycle esnext-training@0.0.1~bases: esnext-training@0.0.1 | ||
8 verbose lifecycle esnext-training@0.0.1~bases: unsafe-perm in lifecycle true | ||
9 verbose lifecycle esnext-training@0.0.1~bases: PATH: /Users/florianorpeliere/.nvm/versions/node/v6.9.5/lib/node_modules/npm/bin/node-gyp-bin:/Users/florianorpeliere/Projects/ESNext-training/node_modules/.bin:/Users/florianorpeliere/App/google-cloud-sdk/bin:/Users/florianorpeliere/.nvm/versions/node/v6.9.5/bin:/Users/florianorpeliere/App/apache-maven-3.3.9/bin:/Users/florianorpeliere/.yarn/bin:/Users/florianorpeliere/Projects/depot_tools/:/Users/florianorpeliere/anaconda/bin:/Users/florianorpeliere/.cabal/bin:/Applications/ghc-7.10.1.app/Contents/bin:/Users/florianorpeliere/Library/Android/sdk/platform-tools:/usr/local/share/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/usr/local/go/bin: | ||
10 verbose lifecycle esnext-training@0.0.1~bases: CWD: /Users/florianorpeliere/Projects/ESNext-training | ||
11 silly lifecycle esnext-training@0.0.1~bases: Args: [ '-c', 'jasmine exercises/bases/test.spec.js' ] | ||
12 silly lifecycle esnext-training@0.0.1~bases: Returned: code: 1 signal: null | ||
13 info lifecycle esnext-training@0.0.1~bases: Failed to exec bases script | ||
14 verbose stack Error: esnext-training@0.0.1 bases: `jasmine exercises/bases/test.spec.js` | ||
14 verbose stack Exit status 1 | ||
14 verbose stack at EventEmitter.<anonymous> (/Users/florianorpeliere/.nvm/versions/node/v6.9.5/lib/node_modules/npm/lib/utils/lifecycle.js:255:16) | ||
14 verbose stack at emitTwo (events.js:106:13) | ||
14 verbose stack at EventEmitter.emit (events.js:191:7) | ||
14 verbose stack at ChildProcess.<anonymous> (/Users/florianorpeliere/.nvm/versions/node/v6.9.5/lib/node_modules/npm/lib/utils/spawn.js:40:14) | ||
14 verbose stack at emitTwo (events.js:106:13) | ||
14 verbose stack at ChildProcess.emit (events.js:191:7) | ||
14 verbose stack at maybeClose (internal/child_process.js:877:16) | ||
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) | ||
15 verbose pkgid esnext-training@0.0.1 | ||
16 verbose cwd /Users/florianorpeliere/Projects/ESNext-training | ||
17 error Darwin 16.5.0 | ||
18 error argv "/Users/florianorpeliere/.nvm/versions/node/v6.9.5/bin/node" "/Users/florianorpeliere/.nvm/versions/node/v6.9.5/bin/npm" "run" "bases" | ||
19 error node v6.9.5 | ||
20 error npm v3.10.10 | ||
21 error code ELIFECYCLE | ||
22 error esnext-training@0.0.1 bases: `jasmine exercises/bases/test.spec.js` | ||
22 error Exit status 1 | ||
23 error Failed at the esnext-training@0.0.1 bases script 'jasmine exercises/bases/test.spec.js'. | ||
23 error Make sure you have the latest version of node.js and npm installed. | ||
23 error If you do, this is most likely a problem with the esnext-training package, | ||
23 error not with npm itself. | ||
23 error Tell the author that this fails on your system: | ||
23 error jasmine exercises/bases/test.spec.js | ||
23 error You can get information on how to open an issue for this project with: | ||
23 error npm bugs esnext-training | ||
23 error Or if that isn't available, you can get their info via: | ||
23 error npm owner ls esnext-training | ||
23 error There is likely additional logging output above. | ||
24 verbose exit [ 1, true ] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "esnext-training", | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"bases": "jasmine exercises/bases/test.spec.js", | ||
"promises": "jasmine exercises/promises/test.spec.js", | ||
"classes": "jasmine exercises/classes/test.spec.js", | ||
"proxies": "jasmine exercises/proxies/test.spec.js", | ||
"generators": "jasmine exercises/generators/test.spec.js", | ||
"modules": "rollup exercises/modules/module-A.js -o exercises/modules/bundle.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/florianorpeliere/ESNext-training.git" | ||
}, | ||
"keywords": [ | ||
"es6", | ||
"es2015", | ||
"ItsJustJavaScript", | ||
"js", | ||
"training" | ||
], | ||
"author": "Florian Orpeliere", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/florianorpeliere/ESNext-training/issues" | ||
}, | ||
"homepage": "https://github.com/florianorpeliere/ESNext-training#readme", | ||
"devDependencies": { | ||
"jasmine": "^2.5.3" | ||
}, | ||
"dependencies": { | ||
"rollup": "^0.41.4" | ||
} | ||
} |