Spring Boot + npm + Geb ã§å ¥åãã©ã¼ã ãä½ã£ã¦ãã¹ããã ( çªå¤ç·¨ )( MobX ã使ç¨ãã¦ã¿ã )
æ¦è¦
è¨äºä¸è¦§ã¯ãã¡ãã§ãã
Spring Boot + npm + Geb ã§å ¥åãã©ã¼ã ãä½ã£ã¦ãã¹ããã ( çªå¤ç·¨ )( Jest ï¼ axios ï¼ Nock, xhr-mock ã§ãã¹ããæ¸ãã¦ã¿ã ) ã®ç¶ãã§ãã
- ä»åã®æé ã§ç¢ºèªã§ããã®ã¯ä»¥ä¸ã®å 容ã§ãã
åç §ãããµã¤ãã»æ¸ç±
-
Reactã§ã使ããï¼ã·ã³ãã«ãªJavaScriptã¹ãã¼ã管çã©ã¤ãã©ãªã¼ Mobxã試ã
https://www.webprofessional.jp/manage-javascript-application-state-mobx/ mobx - npm
https://www.npmjs.com/package/mobxMobX shopping cart demo
https://jsfiddle.net/mweststrate/vxn7qgdw/jQueryãã©ã°ã¤ã³ãèªä½ããã«ã¯ï¼ï¼$.fnï¼
http://www.buildinsider.net/web/jqueryref/031Mobx vs Reactive Stream Libraries (RxJS, Bacon, etc)
https://github.com/mobxjs/mobx/wiki/Mobx-vs-Reactive-Stream-Libraries-(RxJS,-Bacon,-etc)ããããMobXãã¯ããã人ã¸
http://lealog.hateblo.jp/entry/2016/12/15/113825MobX 3.0.0 ã®å¤æ´ç¹ã«ã¤ãã¦
http://lealog.hateblo.jp/entry/2017/01/11/1406070ããã¯ããã MobX Part.1
http://lealog.hateblo.jp/entry/2016/09/07/1108230ããã¯ããã MobX Part.2
http://lealog.hateblo.jp/entry/2016/09/18/1252020ããã¯ããã MobX Part.3
http://lealog.hateblo.jp/entry/2016/09/27/1851270ããã¯ããã MobX Part.4
http://lealog.hateblo.jp/entry/2016/11/21/104613mobxjs / mobx-utils
https://github.com/mobxjs/mobx-utils
ç®æ¬¡
- MobX ã¨ã¯ï¼
- MobX ãã¤ã³ã¹ãã¼ã«ãã
- extendObservable ã§ããããã£ãï¼ã¤æã¤ã¯ã©ã¹ãå®ç¾©ããåä½ã確èªãã
- extendObservable ã§ããããã£ãï¼ã¤æã¤ã¯ã©ã¹ãå®ç¾©ããåä½ã確èªãã
- autorun ãã computed ã§å®ç¾©ããããããã£ãåç §ãã¦ããå ´åã®åä½ã確èªãã
- autorun ããã¡ã½ãããåç §ãã¦ããå ´åã®åä½ã確èªãã
- autorun ã¯ããããã£ã®å¤ãå¤æ´ããæã ãã§ãªããæåã®å®ç¾©æã«ãé¢æ°ãå®è¡ãã
- when ã¯æ¡ä»¶ãæºãããæã«ï¼åº¦ã ãåä½ãã
- autorunAsync ã¯ããããã£ãæ´æ°ãããæã«åä½ããï¼å®ç¾©æã¯åä½ããªãï¼
æé
MobX ã¨ã¯ï¼
試ãã¦ã¿ãææ³ã¨ãã¦ã¯ã
- ãªãã¸ã§ã¯ãï¼observable ãªãªãã¸ã§ã¯ãã¨ãã¦ãããããå®ç¾©ãã¦ããï¼ã®ããããã£ã®å¤ãå¤æ´ããã¨ããã®ããããã£ãåç §ããé¢æ°ãèªåã§å®è¡ãããä»çµã¿ãè¨è¿°ããããã®ã©ã¤ãã©ãªã
- é¢æ°ãå®è¡ãããå¦ããå¤æããããã®ç£è¦å¯¾è±¡ã®ããããã£ã MobX ãèªåã§å¤å¥ãã¦ãããããããããããããªã便å©ã
ã¨ããæãã§ããã㨠React ã¨ãå ¨ç¶ãã£ããã¨ããªãã®ã§ç¶æ 管çãä½ããããã®ãªã®ããåãããªãã¦ãæ¸ãæ¹ã¨åä½ãç解ããã®ã«çµæ§æéãåããã¾ããããããã¾ã React ã¨çµã¿åããããµã³ãã«ã¯è¦ããã¾ãããVue.js ã¨çµã¿åããããã¨ã¯ãªãããã§ãï¼Vue.js 㯠Vuex ã¨çµã¿åãããã°ããã®ã§ä¸è¦ã¨ãããã¨ã§ããããï¼ï¼ã
MobX ãã¤ã³ã¹ãã¼ã«ãã
npm install --save mobx
ã³ãã³ããå®è¡ãã¦ã¤ã³ã¹ãã¼ã«ãã¾ãã
extendObservable ã§ããããã£ãï¼ã¤æã¤ã¯ã©ã¹ãå®ç¾©ããåä½ã確èªãã
src/test/assets/tests/lib/util ã®ä¸ã« mobx.test.js ã¨ãããã¡ã¤ã«ãæ°è¦ä½æãã以ä¸ã®å 容ãè¨è¿°ãã¾ãã
"use strict"; global.$ = require("jquery"); const mobx = require("mobx"); describe("MobX ã®åä½ç¢ºèª", () => { test("extendObservable ã§ããããã£ãï¼ã¤æã¤ã¯ã©ã¹ãå®ç¾©ããåä½ã確èªãã", () => { document.body.innerHTML = ` <div id="value"></div> `; // mobx.extendObservable ã¡ã½ããã使ç¨ãã¦ãSample ã¯ã©ã¹ã Observable ã¨ãã¦å®ç¾©ãã // // function Sample() {...} ã§å®ç¾©ãããªã以ä¸ã®ããã«è¨è¿°ãã // function Sample() { // mobx.extendObservable(this, { // value: "" // }); // } // class Sample { constructor() { mobx.extendObservable(this, { value: "" }); } } // sample.value ãå¤æ´ãããã $("#value").text() ãæ´æ°ããããå®ç¾©ãã const sample = new Sample(); mobx.autorun(() => { $("#value").text(sample.value); }); // sample.value ã®å¤ãå¤æ´ããã¨ã // mobx.autorun ã§å®ç¾©ããé¢æ°ãå®è¡ããã¦ã // $("#value").text() ã« sample.value ã®å¤ãã»ããããã expect($("#value").text()).toBe(""); sample.value = "test"; expect($("#value").text()).toBe("test"); }); });
ãã®ãã¹ããå®è¡ããã¨æåãã¾ãã
以ä¸ã®ãããªæ¸ãæ¹ã»åä½ã«ãªãã¾ãã
- å¤æ´ãæ¤ç¥ãã¦ä½ããããå
ã¨ãªããªãã¸ã§ã¯ãã
mobx.observable(...)
ãmobx.extendObservable(...)
ã使ç¨ãã¦å®ç¾©ããã - ãªãã¸ã§ã¯ããå¤æ´ããããå®è¡ããé¢æ°ã
mobx.autorun(...)
ã§å®ç¾©ããã - ãªãã¸ã§ã¯ãã®ããããã£ãå¤æ´ããã¨ã
mobx.autorun(...)
ã§å®ç¾©ããé¢æ°ãå®è¡ãããã
extendObservable ã§ããããã£ãï¼ã¤æã¤ã¯ã©ã¹ãå®ç¾©ããåä½ã確èªãã
mobx.autorun(...)
å
ã§åç
§ãã¦ããªãããããã£ãå¤æ´ãã¦ã mobx.autorun(...)
ã§å®ç¾©ããé¢æ°ã¯å®è¡ããã¾ããã
src/test/assets/tests/lib/util/mobx.test.js ã«ä»¥ä¸ã®ãã¹ãã追å ãã¦ç¢ºèªãã¦ã¿ã¾ãã
test("extendObservable ã§ããããã£ãï¼ã¤æã¤ã¯ã©ã¹ãå®ç¾©ããåä½ã確èªãã", () => { document.body.innerHTML = ` <div id="value"></div> `; class Sample { constructor() { mobx.extendObservable(this, { value: "", data: "" }); } } const sample = new Sample(); // mbox.autorun å ã§ã¯ sample.value ããåç §ãã¦ããªã mobx.autorun(() => { console.log(`â â â mobx.autorun: sample.value = ${sample.value}`); $("#value").text(sample.value); }); // sample.value ãå¤æ´ãã㨠mbox.autorun ã§å®ç¾©ããé¢æ°ãå®è¡ããããã // sample.data ãå¤æ´ãã¦ãå®è¡ãããªã console.log("âââ sample.value = \"PASS1\""); sample.value = "PASS1"; console.log("â²â²â² sample.data = \"1\""); sample.data = "1"; console.log("âââ sample.value = \"PASS2\""); sample.value = "PASS2"; });
ãã¹ããå®è¡ããã¨ãsample.value ãå¤æ´ããæã«ã¯ mobx.autorun(...)
ã§å®ç¾©ããé¢æ°ãå®è¡ããã¾ãããsample.data ãå¤æ´ãã¦ãå®è¡ããã¾ããã§ãããMobX ã®æ¹ã§ä½ãå¤æ´ããããé¢æ°ãå®è¡ãããèªåçã«å¤å¥ãã¦ãããããã§ãã
autorun ãã computed ã§å®ç¾©ããããããã£ãåç §ãã¦ããå ´åã®åä½ã確èªãã
mobx.autorun(...)
ã§å®ç¾©ããé¢æ°ãã mobx.computed(...)
ã§å®ç¾©ããããããã£ãåç
§ãã¦ããå ´åãmobx.computed(...)
ã§åç
§ãã¦ããããããã£ãå¤æ´ããã㨠mobx.autorun(...)
ã§å®ç¾©ããé¢æ°ãå®è¡ããã¾ãã
src/test/assets/tests/lib/util/mobx.test.js ã«ä»¥ä¸ã®ãã¹ãã追å ãã¦ç¢ºèªãã¦ã¿ã¾ãã
test("autorun ãã computed ã§å®ç¾©ããããããã£ãåç §ãã¦ããå ´åã®åä½ã確èªãã", () => { document.body.innerHTML = ` <div id="personal"> <input type="text" name="firstname" id="firstname" value=""> <input type="text" name="lastname" id="lastname" value=""> <div id="fullname"></div> </div> `; // mobx.computed() ã§å®ç¾©ãã fullname ããããã£ãã firstname + lastname ã®æåå // ãåå¾ã§ããããã«ãã class Personal { constructor() { mobx.extendObservable(this, { firstname: "", lastname: "", fullname: mobx.computed(() => `${this.firstname}ã${this.lastname}`) }); } } const personal = new Personal(); // mobx.autorun ã§ã¯ personal.fullname ãåç §ãã mobx.autorun(() => { $("#fullname").text(personal.fullname); }); // blur ã¤ãã³ãçºçæã« View ããå ¥åãããå¤ã personal ãªãã¸ã§ã¯ãã«ã»ãããã [ "firstname", "lastname" ].forEach(item => { $("#" + item).on("blur", event => { personal[item] = $(event.target).val(); }); }); // $("#firstname").val() ã« "taro" ã¨å ¥åãã㨠$("#fullname").text() ãå¤æ´ããã $("#firstname").val("taro").blur(); console.log("â â â " + $("#fullname").text()); // $("#lastname").val() ã« "tanaka" ã¨å ¥åãã¦ã $("#fullname").text() ãå¤æ´ããã $("#lastname").val("tanaka").blur(); console.log("â â â " + $("#fullname").text()); });
ãã¹ããå®è¡ããã¨ãpersonal.firstname ãå¤æ´ãã¦ã personal.lastname ãå¤æ´ãã¦ã mobx.autorun(...)
ã§å®ç¾©ããé¢æ°ãå®è¡ããã¦ãããã¨ã確èªã§ãã¾ãã
autorun ããã¡ã½ãããåç §ãã¦ããå ´åã®åä½ã確èªãã
mobx.computed(...)
ã§å®ç¾©ããããããã£ã®å ´å mobx.computed(...)
ããåç
§ããã¦ããããããã£ã®å¤ãå¤æ´ãããã° mobx.autorun(...)
ã§å®ç¾©ããé¢æ°ãå®è¡ããã¾ãããã¡ã½ããã®å ´åã©ããªãã®ã確èªãã¦ã¿ã¾ãã
src/test/assets/tests/lib/util/mobx.test.js ã«ä»¥ä¸ã®ãã¹ãã追å ãã¾ãã
test("autorun ããã¡ã½ãããåç §ãã¦ããå ´åã®åä½ã確èªãã", () => { document.body.innerHTML = ` <div id="personal"> <input type="text" name="firstname" id="firstname" value=""> <input type="text" name="lastname" id="lastname" value=""> <div id="fullname"></div> </div> `; // fullname ã¡ã½ãããã firstname + lastname ã®æåå // ãåå¾ã§ããããã«ãã class Personal { constructor() { mobx.extendObservable(this, { firstname: "", lastname: "", fullname() { return `${this.firstname}ã${this.lastname}` } }); } } const personal = new Personal(); // mobx.autorun ã§ã¯ personal.fullname() ãåç §ãã mobx.autorun(() => { $("#fullname").text(personal.fullname()); }); // blur ã¤ãã³ãçºçæã« View ããå ¥åãããå¤ã personal ãªãã¸ã§ã¯ãã«ã»ãããã [ "firstname", "lastname" ].forEach(item => { $("#" + item).on("blur", event => { personal[item] = $(event.target).val(); }); }); // $("#firstname").val() ã« "taro" ã¨å ¥åãã㨠$("#fullname").text() ãå¤æ´ããã $("#firstname").val("taro").blur(); console.log("â â â " + $("#fullname").text()); // $("#lastname").val() ã« "tanaka" ã¨å ¥åãã¦ã $("#fullname").text() ãå¤æ´ããã $("#lastname").val("tanaka").blur(); console.log("â â â " + $("#fullname").text()); });
ãã¹ããå®è¡ããã¨ãå
ç¨ã¨åæ§ã« personal.firstname ãå¤æ´ãã¦ã personal.lastname ãå¤æ´ãã¦ã mobx.autorun(...)
ã§å®ç¾©ããé¢æ°ãå®è¡ããã¦ãããã¨ã確èªã§ãã¾ãã
autorun ã¯ããããã£ã®å¤ãå¤æ´ããæã ãã§ãªããæåã®å®ç¾©æã«ãé¢æ°ãå®è¡ãã
mobx.autorun(...)
ã§å®ç¾©ããé¢æ°ã¯ããããã£ãå¤æ´ãããæã ãã§ãªããæåã®å®ç¾©æã«ãå®è¡ããã¾ããå®è¡ããæã«ç£è¦ããããããã£ããã§ãã¯ããããã§ããmobx.when(...)
ã mobx.autorunAsync(...)
ã¯æåã®å®ç¾©æã«ã¯å®è¡ããã¾ããã
mobx.autorunAsync(...)
ã¯å®ç¾©æã«å®è¡ããªãã¦ãç£è¦ããããããã£ãå¤å¥ã§ãããããªã®ã§ mobx.autorun(...)
ãå®ç¾©æã«å®è¡ããªãã¦ãããæ°ãããã®ã§ããããããããåããã¾ããã§ããããã
src/test/assets/tests/lib/util/mobx.test.js ã«ä»¥ä¸ã®ãã¹ãã追å ãã¦ç¢ºèªãã¦ã¿ã¾ãã
test("autorun ã¯ããããã£ã®å¤ãå¤æ´ããæã ãã§ãªããæåã®å®ç¾©æã«ãé¢æ°ãå®è¡ãã", () => { class Sample { constructor() { mobx.extendObservable(this, { value: "" }); } } let cnt = 0; const sample = new Sample(); console.log("(1) mobx.autorun ã¯å®ç¾©æã«ï¼åº¦å®è¡ããã"); mobx.autorun(() => { console.log("mobx.autorun ã®é¢æ°ãå®è¡ããã¾ãã"); $("#value").text(sample.value); cnt++; }); console.log("(2) mobx.autorun ã¯ããããã£ãå¤æ´ãã¦ãå®è¡ããã"); sample.value = "1"; });
ãã¹ããå®è¡ããã¨ãæåã®å®ç¾©æã«ã mobx.autorun(...)
ã«æ¸¡ããé¢æ°ãå®è¡ããã¦ãããã¨ã確èªã§ãã¾ãã
ã¾ã以ä¸ã®ããã«æåã®å®è¡æã« sample.value
ãåç
§ããªãã¨ã
test("autorun ã®ååå®è¡æã«ããããã£ãåç §ããªãã¨ãããããã£ãå¤æ´ãã¦ãé¢æ°ã¯å®è¡ãããªã", () => { class Sample { constructor() { this.autorunFirstFlg = true; mobx.extendObservable(this, { value: "" }); } } let cnt = 1; const sample = new Sample(); console.log("(1) mobx.autorun ã®æåã®å®ç¾©æã«ããããã£ãåç §ããªãããã«ãã"); mobx.autorun(() => { console.log(`${cnt}åç®: mobx.autorun ã®é¢æ°ãå®è¡ããã¾ãã`); if (sample.autorunFirstFlg) { sample.autorunFirstFlg = false; return; } // æåã®å®è¡æã«ã¯ãããéããªã $("#value").text(sample.value); cnt++; }); console.log("(2) ããããã£ãå¤æ´ãã¦ã mobx.autorun ã¯å®è¡ãããªã"); sample.value = "1"; });
ããããã£ãå¤æ´ãã¦ã mobx.autorun(...)
ã«æ¸¡ããé¢æ°ã¯å®è¡ããã¾ããã
when ã¯æ¡ä»¶ãæºãããæã«ï¼åº¦ã ãåä½ãã
mobx.autorun(...)
ã§å®ç¾©ããé¢æ°ã¯åç
§ãã¦ããããããã£ãå¤æ´ãããã°ä½åº¦ã§ãå®è¡ããã¾ãããmobx.when(...)
ã¯æ¡ä»¶ãæºãããæã«ï¼åº¦ã ãå®è¡ããã¾ãã
src/test/assets/tests/lib/util/mobx.test.js ã«ä»¥ä¸ã®ãã¹ãã追å ãã¦ç¢ºèªãã¦ã¿ã¾ãã
test("when ã¯æ¡ä»¶ãæºãããæã«ï¼åº¦ã ãåä½ãã", () => { document.body.innerHTML = ` <div id="value"></div> `; class Sample { constructor() { mobx.extendObservable(this, { value: "", whenExecuteFlg: false }); } } let cnt = 1; const sample = new Sample(); console.log("mobx.when ã¯æåã®å®ç¾©æã«ã¯å®è¡ãããªã"); mobx.when( // 第ï¼å¼æ°ã®é¢æ°ã®æ¡ä»¶ãæºãããæã ãã第ï¼å¼æ°ã®é¢æ°ãå®è¡ããã // ã¾ã第ï¼å¼æ°ã®æ¡ä»¶ã§åç §ããå¤æ°ã¯ observable ã§ãªããã°ãããªã () => sample.whenExecuteFlg === true, () => { console.log(`${cnt}åç®: mobx.when ã®é¢æ°ãå®è¡ããã¾ãã`); $("#value").text(sample.value); cnt++; } ); // sample.value ã®å¤ãå¤æ´ããããã§ã¯ $("#value").text() ã«ã¯åæ ãããªã sample.value = "test"; expect($("#value").text()).toBe(""); // sample.whenExecuteFlg ã true ã«ããã¨åæ ããã sample.whenExecuteFlg = true; expect($("#value").text()).toBe("test"); // sample.whenExecuteFlg ã false ã«æ»ãã¦å度 true ã«ãã¦ãããã mobx.when ã¯å®è¡ãããªã sample.whenExecuteFlg = false; sample.value = "sample"; sample.whenExecuteFlg = true; expect($("#value").text()).toBe("test"); });
ãã¹ããå®è¡ããã¨ãï¼åº¦ã ãå®è¡ããããã¨ã確èªã§ãã¾ãã
MobX-utils ã® fromPromise ã¡ã½ããã使ç¨ãã¦ãéåæã«ãã¼ã¿ãåå¾ãã¦å¦çãããµã³ãã«ãä½æãã¦ã¿ã¾ãã
ã¾ã㯠npm install --save mobx-utils
ã³ãã³ããå®è¡ã㦠MobX-utils ãã¤ã³ã¹ãã¼ã«ãã¾ãã
src/test/assets/tests/lib/util/mobx.test.js ã«ä»¥ä¸ã®ãã¹ãã追å ãã¾ãã
"use strict"; global.$ = require("jquery"); const mobx = require("mobx"); const mobxUtils = require("mobx-utils"); const openWeatherMapHelper = require("lib/util/OpenWeatherMapHelper.js"); const xhrmock = require('xhr-mock'); describe("MobX ã®åä½ç¢ºèª", () => { beforeEach(() => { xhrmock.setup(); }); afterEach(() => { xhrmock.teardown(); }); .......... test("when + mobx-utils.fromPromise ã®ãµã³ãã«", done => { // xhr-mock ã§ã¢ãã¯ãå®ç¾©ãã xhrmock.get(/^http:\/\/api\.openweathermap\.org\/data\/2\.5\/weather/ , (req, res) => { return res .status(200) .body({ weather: [ { id: 500, main: "Rain", description: "light rain", icon: "10d" } ], name: "Tokyo" }); }); document.body.innerHTML = ` <div id="weather"></div> `; // mobx-utils ã® fromPromise ã¡ã½ããã使ç¨ã㦠// openWeatherMapHelper.getCurrentWeatherDataByCityName ãå¼ã³åºã const result = mobxUtils.fromPromise( openWeatherMapHelper.getCurrentWeatherDataByCityName("Tokyo")); // éåæå¦çãå®äºããã ( result.state ã "pending" ã§ãªããªã£ãã )ã // åå¾ãã天æ°ã $("#weather").text() ã«ã»ãããã mobx.when( () => result.state !== "pending", () => { const json = result.value.data; $("#weather").text(json.weather[0].main); } ); // 1ç§å¾ã« $("#weather").text() ã«ã¢ãã¯ã§å®ç¾©ãã天æ°("Rain")ãã»ããããã¦ãããã¨ã確èªãã expect($("#wheather").text()).toBe(""); setTimeout(() => { expect($("#weather").text()).toBe("Rain"); done(); }, 1000); }); });
ãã¹ããå®è¡ããã¨æåãããã¨ã確èªã§ãã¾ãã
autorunAsync ã¯ããããã£ãæ´æ°ãããæã«åä½ããï¼å®ç¾©æã¯åä½ããªãï¼
mobx.autorunAsync(...)
ã¯ããããã£ãæ´æ°ãããã¨éåæã§å¦çãå®è¡ãã¾ããmobx.autorun(...)
ã¯å®ç¾©æã«ãå®è¡ããã¾ããã mobx.autorunAsync(...)
ã¯å®ç¾©æã«ã¯å®è¡ããã¾ããã
src/test/assets/tests/lib/util/mobx.test.js ã«ä»¥ä¸ã®ãã¹ãã追å ãã¦ç¢ºèªãã¦ã¿ã¾ãã
test("autorunAsync 㯠observable ãªããããã£ãå¤æ´ãããæã«åä½ããï¼å®ç¾©æã¯åä½ããªãï¼", done => { // xhr-mock ã§ã¢ãã¯ãå®ç¾©ãã xhrmock.get(/^http:\/\/api\.openweathermap\.org\/data\/2\.5\/weather/ , (req, res) => { return res .status(200) .body({ weather: [ { id: 500, main: "Rain", description: "light rain", icon: "10d" } ], name: "Tokyo" }); }); document.body.innerHTML = ` <div id="area"> <input type="text" name="name" id="name" value=""> <div id="weather"></div> </div> `; class Area { constructor() { mobx.extendObservable(this, { name: "", weather: "" }); } } const area = new Area(); // area.name ãæ´æ°ãããã OpenWeatherMap ã® API ã§å¤©æ°ãåå¾ããarea.weather ã«ã»ãããã mobx.autorunAsync(async () => { console.log("(3) area.name ãæ´æ°ãããã OpenWeatherMap ã® API ã§å¤©æ°ãåå¾ããarea.weather ã«ã»ãããã"); const res = await openWeatherMapHelper.getCurrentWeatherDataByCityName(area.name); const json = res.data; area.weather = json.weather[0].main; }); // area.weather ãæ´æ°ãããã $("#weather").text() ã«ã»ãããã mobx.autorun(() => { console.log("(4) area.weather ãæ´æ°ãããã $(\"#weather\").text() ã«ã»ãããã"); $("#weather").text(area.weather); }); // $("#name").val() ã«å ¥åãããå¤ã area.name ã«ã»ãããã $("#name").on("blur", event => { console.log("(2) $(\"#name\").val() ã«å ¥åãããå¤ã area.name ã«ã»ãããã"); area.name = $(event.target).val(); }); console.log("(1) $(\"#name\").val() ã« Tokyo ã¨å ¥åãã"); $("#name").val("Tokyo").blur(); setTimeout(() => { console.log("(5) $(\"#weather\").text() ã« Rain ãã»ããããã¦ãããã¨ã確èªãã"); expect($("#weather").text()).toBe("Rain"); done(); }, 1000); });
ãã¹ããå®è¡ããã¨ãå®ç¾©æã«ã¯å®è¡ããããé¢æ°å ã§åç §ãã¦ããããããã£ãæ´æ°ãããæã ãå®è¡ããããã¨ã確èªã§ãã¾ãã
ããå°ã試ããããã¨ãããã®ã§ç¶ãã¾ãã
å±¥æ´
2018/01/06
åççºè¡ã